添加一些关于midi播放的项目
This commit is contained in:
+368
@@ -0,0 +1,368 @@
|
||||
;------------------------------------------------;
|
||||
; Constants
|
||||
|
||||
.equ RAMTOP = 0x60 ; SRAM top address
|
||||
.equ RAMTOP100 = 0x100 ; For memory mapped I/O devices
|
||||
|
||||
|
||||
.equ bit0 = 0b00000001
|
||||
.equ bit1 = 0b00000010
|
||||
.equ bit2 = 0b00000100
|
||||
.equ bit3 = 0b00001000
|
||||
.equ bit4 = 0b00010000
|
||||
.equ bit5 = 0b00100000
|
||||
.equ bit6 = 0b01000000
|
||||
.equ bit7 = 0b10000000
|
||||
|
||||
|
||||
.def T0L = r0
|
||||
.def T0H = r1
|
||||
.def T2L = r2
|
||||
.def T2H = r3
|
||||
.def T4L = r4
|
||||
.def T4H = r5
|
||||
.def T6L = r6
|
||||
.def T6H = r7
|
||||
.def T8L = r8
|
||||
.def T8H = r9
|
||||
.def T10L = r10
|
||||
.def T10H = r11
|
||||
.def T12L = r12
|
||||
.def T12H = r13
|
||||
.def T14L = r14
|
||||
.def T14H = r15
|
||||
|
||||
|
||||
.def AL = r16
|
||||
.def AH = r17
|
||||
.def BL = r18
|
||||
.def BH = r19
|
||||
.def CL = r20
|
||||
.def CH = r21
|
||||
.def DL = r22
|
||||
.def DH = r23
|
||||
.def EL = r24
|
||||
.def EH = r25
|
||||
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Push/Pop register pair
|
||||
;
|
||||
; pushw Z
|
||||
|
||||
.macro pushw
|
||||
push @0H
|
||||
push @0L
|
||||
.endm
|
||||
|
||||
.macro popw
|
||||
pop @0L
|
||||
pop @0H
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Load/store word from/to direct memory/immediate
|
||||
;
|
||||
; ldsw Z,mem
|
||||
; ldiw Z,imm
|
||||
|
||||
.macro ldiw
|
||||
ldi @0L,low(@1)
|
||||
ldi @0H,high(@1)
|
||||
.endm
|
||||
|
||||
.macro ldsw
|
||||
lds @0L,@1
|
||||
lds @0H,@1+1
|
||||
.endm
|
||||
|
||||
.macro stsw
|
||||
sts @0+1,@1H
|
||||
sts @0,@1L
|
||||
.endm
|
||||
|
||||
.macro lddw
|
||||
ldd @0L,@1
|
||||
ldd @0H,@1+1
|
||||
.endm
|
||||
|
||||
.macro stdw
|
||||
std @0+1,@1H
|
||||
std @0,@1L
|
||||
.endm
|
||||
|
||||
.macro ldw
|
||||
ld @0L,@1
|
||||
ld @0H,@1
|
||||
.endm
|
||||
|
||||
.macro stw
|
||||
st @0,@1L
|
||||
st @0,@1H
|
||||
.endm
|
||||
|
||||
.macro inw
|
||||
in @0L,@1L
|
||||
in @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro outw
|
||||
out @0H,@1H
|
||||
out @0L,@1L
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Store immediate into indirect memory via r16
|
||||
;
|
||||
; sti Z,imm
|
||||
; stdi Z+d,imm
|
||||
|
||||
.macro sti
|
||||
ldi r16,@1
|
||||
st @0,r16
|
||||
.endm
|
||||
|
||||
.macro stdi
|
||||
ldi r16,@1
|
||||
std @0,r16
|
||||
.endm
|
||||
|
||||
.macro muli
|
||||
ldi r16,@1
|
||||
mul @0,r16
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; add/sub/subc/cp/cpc/lsl/lsr/rol/ror to register pair
|
||||
;
|
||||
|
||||
.macro addiw
|
||||
subi @0L,low(-(@1))
|
||||
sbci @0H,high(-(@1))
|
||||
.endm
|
||||
|
||||
.macro subiw
|
||||
subi @0L,low(@1)
|
||||
sbci @0H,high(@1)
|
||||
.endm
|
||||
|
||||
.macro addw
|
||||
add @0L,@1L
|
||||
adc @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro adcw
|
||||
adc @0L,@1L
|
||||
adc @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro subw
|
||||
sub @0L,@1L
|
||||
sbc @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro sbcw
|
||||
sbc @0L,@1L
|
||||
sbc @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro cpw
|
||||
cp @0L,@1L
|
||||
cpc @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro cpcw
|
||||
cpc @0L,@1L
|
||||
cpc @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro cpiw
|
||||
cpi @0L,low(@1)
|
||||
ldi r16,high(@1)
|
||||
cpc @0H,r16
|
||||
.endm
|
||||
|
||||
.macro andw
|
||||
and @0L,@1L
|
||||
and @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro andiw
|
||||
andi @0L,low(@1)
|
||||
andi @0H,high(@1)
|
||||
.endm
|
||||
|
||||
.macro orw
|
||||
or @0L,@1L
|
||||
or @0H,@1H
|
||||
.endm
|
||||
|
||||
.macro oriw
|
||||
ori @0L,low(@1)
|
||||
ori @0H,high(@1)
|
||||
.endm
|
||||
|
||||
.macro lslw
|
||||
lsl @0L
|
||||
rol @0H
|
||||
.endm
|
||||
|
||||
.macro lsrw
|
||||
lsr @0H
|
||||
ror @0L
|
||||
.endm
|
||||
|
||||
.macro asrw
|
||||
asr @0H
|
||||
ror @0L
|
||||
.endm
|
||||
|
||||
.macro rolw
|
||||
rol @0L
|
||||
rol @0H
|
||||
.endm
|
||||
|
||||
.macro rorw
|
||||
ror @0H
|
||||
ror @0L
|
||||
.endm
|
||||
|
||||
.macro clrw
|
||||
clr @0L
|
||||
clr @0H
|
||||
.endm
|
||||
|
||||
.macro comw
|
||||
com @0L
|
||||
com @0H
|
||||
.endm
|
||||
|
||||
.macro negw
|
||||
com @0H
|
||||
neg @0L
|
||||
brne PC+2
|
||||
inc @0H
|
||||
.endm
|
||||
|
||||
.macro movew
|
||||
mov @0L, @1L
|
||||
mov @0H, @1H
|
||||
.endm
|
||||
|
||||
.macro lpmw
|
||||
lpm @0L, @1
|
||||
lpm @0H, @1
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Store immediate into direct memory via r16
|
||||
;
|
||||
; stsi var,imm
|
||||
|
||||
.macro stsi
|
||||
ldi r16,@1
|
||||
sts @0,r16
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Output port immediate via r16
|
||||
;
|
||||
; outi port,var
|
||||
|
||||
.macro outi
|
||||
ldi r16,@1
|
||||
out @0,r16
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Add immediate to register
|
||||
|
||||
.macro addi
|
||||
subi @0,-(@1)
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Long branch
|
||||
|
||||
|
||||
.macro rjne
|
||||
breq PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
.macro rjeq
|
||||
brne PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
.macro rjcc
|
||||
brcs PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
.macro rjcs
|
||||
brcc PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
.macro rjtc
|
||||
brts PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
.macro rjts
|
||||
brtc PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
.macro rjge
|
||||
brlt PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
.macro rjlt
|
||||
brge PC+2
|
||||
rjmp @0
|
||||
.endm
|
||||
|
||||
|
||||
.macro retcc
|
||||
brcs PC+2
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro retcs
|
||||
brcc PC+2
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro reteq
|
||||
brne PC+2
|
||||
ret
|
||||
.endm
|
||||
|
||||
.macro retne
|
||||
breq PC+2
|
||||
ret
|
||||
.endm
|
||||
|
||||
|
||||
;------------------------------------------------;
|
||||
; Move single bit between two registers
|
||||
;
|
||||
; bmov dstreg,dstbit,srcreg.srcbit
|
||||
|
||||
.macro movb
|
||||
bst @2,@3
|
||||
bld @0,@1
|
||||
.endm
|
||||
|
||||
|
||||
+499
@@ -0,0 +1,499 @@
|
||||
;For Elise (3/8, 60bpm)
|
||||
|
||||
;<time tick> <note> <note> ...
|
||||
; 1
|
||||
120 E5
|
||||
150 Dis5
|
||||
|
||||
; 2
|
||||
180 E5
|
||||
210 Dis5
|
||||
240 E5
|
||||
270 H5
|
||||
300 D5
|
||||
330 C5
|
||||
|
||||
; 3
|
||||
360 A5 A3
|
||||
390 E3
|
||||
420 A4
|
||||
450 C4
|
||||
480 E4
|
||||
510 A5
|
||||
|
||||
; 4
|
||||
540 H5 E2
|
||||
570 E3
|
||||
600 Gis3
|
||||
630 E4
|
||||
660 Gis4
|
||||
690 H5
|
||||
|
||||
; 5
|
||||
720 C5 A3
|
||||
750 E3
|
||||
780 A4
|
||||
810 E4
|
||||
840 E5
|
||||
870 Dis5
|
||||
|
||||
; 6
|
||||
900 E5
|
||||
930 Dis5
|
||||
960 E5
|
||||
990 H5
|
||||
1020 D5
|
||||
1050 C5
|
||||
|
||||
; 7
|
||||
1080 A5 A3
|
||||
1110 E3
|
||||
1140 A4
|
||||
1170 C4
|
||||
1200 E4
|
||||
1230 A5
|
||||
|
||||
; 8
|
||||
1260 H5 E2
|
||||
1290 E3
|
||||
1320 Gis3
|
||||
1350 E4
|
||||
1380 C5
|
||||
1410 H5
|
||||
|
||||
; 9
|
||||
1440 A5 A3
|
||||
1470 E3
|
||||
1500 A4
|
||||
1560 E5
|
||||
1590 Dis5
|
||||
|
||||
; 10
|
||||
1620 E5
|
||||
1650 Dis5
|
||||
1680 E5
|
||||
1710 H5
|
||||
1740 D5
|
||||
1770 C5
|
||||
|
||||
; 11
|
||||
1800 A5 A3
|
||||
1830 E3
|
||||
1860 A4
|
||||
1890 C4
|
||||
1920 E4
|
||||
1950 A5
|
||||
|
||||
; 12
|
||||
1980 H5 E2
|
||||
2010 E3
|
||||
2040 Gis3
|
||||
2070 E4
|
||||
2100 Gis4
|
||||
2130 H5
|
||||
|
||||
; 13
|
||||
2160 C5 A3
|
||||
2190 E3
|
||||
2220 A4
|
||||
2250 E4
|
||||
2280 E5
|
||||
2310 Dis5
|
||||
|
||||
; 14
|
||||
2340 E5
|
||||
2370 Dis5
|
||||
2400 E5
|
||||
2430 H5
|
||||
2460 D5
|
||||
2490 C5
|
||||
|
||||
; 15
|
||||
2520 A5 A3
|
||||
2550 E3
|
||||
2580 A4
|
||||
2610 C4
|
||||
2640 E4
|
||||
2670 A5
|
||||
|
||||
; 16
|
||||
2700 H5 E2
|
||||
2730 E3
|
||||
2760 Gis3
|
||||
2790 E4
|
||||
2820 C5
|
||||
2850 H5
|
||||
|
||||
; 17
|
||||
2880 A5 A3
|
||||
2910 E3
|
||||
2940 A4
|
||||
2970 H5
|
||||
3000 C5
|
||||
3030 D5
|
||||
|
||||
; 18
|
||||
3060 E5 C3
|
||||
3090 G3
|
||||
3120 C4
|
||||
3150 G4
|
||||
3180 F5
|
||||
3210 E5
|
||||
|
||||
; 19
|
||||
3240 D5 G2
|
||||
3270 G3
|
||||
3300 A4
|
||||
3330 F4
|
||||
3360 E5
|
||||
3390 D5
|
||||
|
||||
; 20
|
||||
3420 C5 A3
|
||||
3450 E3
|
||||
3480 A4
|
||||
3510 E4
|
||||
3540 D5
|
||||
3570 C5
|
||||
|
||||
; 21
|
||||
3600 H5 E2
|
||||
3630 E3
|
||||
3660 E4
|
||||
3690 E4
|
||||
3720 E5
|
||||
3750 E4
|
||||
|
||||
; 22
|
||||
3780 E5
|
||||
3810 E5
|
||||
3840 E6
|
||||
3870 Dis5
|
||||
3900 E5
|
||||
3930 Dis5
|
||||
|
||||
; 23
|
||||
3960 E5
|
||||
3990 Dis5
|
||||
4020 E5
|
||||
4050 Dis5
|
||||
4080 E5
|
||||
4110 Dis5
|
||||
|
||||
; 24
|
||||
4140 E5
|
||||
4170 Dis5
|
||||
4200 E5
|
||||
4230 H5
|
||||
4260 D5
|
||||
4290 C5
|
||||
|
||||
; 25
|
||||
4320 A5 A3
|
||||
4350 E3
|
||||
4380 A4
|
||||
4410 C4
|
||||
4440 E4
|
||||
4470 A5
|
||||
|
||||
; 26
|
||||
4500 H5 E2
|
||||
4530 E3
|
||||
4560 Gis3
|
||||
4590 E4
|
||||
4620 Gis4
|
||||
4650 H5
|
||||
|
||||
; 27
|
||||
4680 C5 A3
|
||||
4710 E3
|
||||
4740 A4
|
||||
4770 E4
|
||||
4800 E5
|
||||
4830 Dis5
|
||||
|
||||
; 28
|
||||
4860 E5
|
||||
4890 Dis5
|
||||
4920 E5
|
||||
4950 H5
|
||||
4980 D5
|
||||
5010 C5
|
||||
|
||||
; 29
|
||||
5040 A5 A3
|
||||
5070 E3
|
||||
5100 A4
|
||||
5130 C4
|
||||
5160 E4
|
||||
5190 A5
|
||||
|
||||
; 30
|
||||
5220 H5 E2
|
||||
5250 E3
|
||||
5280 Gis3
|
||||
5310 E4
|
||||
5340 C5
|
||||
5370 H5
|
||||
|
||||
; 31
|
||||
5400 A5 A3
|
||||
5430 E3
|
||||
5460 A4
|
||||
5490 H5
|
||||
5520 C5
|
||||
5550 D5
|
||||
|
||||
; 32
|
||||
5580 E5 C3
|
||||
5610 G3
|
||||
5640 C4
|
||||
5670 G4
|
||||
5700 F5
|
||||
5730 E5
|
||||
|
||||
; 33
|
||||
5760 D5 G2
|
||||
5790 G3
|
||||
5820 A4
|
||||
5850 F4
|
||||
5880 E5
|
||||
5910 D5
|
||||
|
||||
; 34
|
||||
5940 C5 A3
|
||||
5970 E3
|
||||
6000 A4
|
||||
6030 E4
|
||||
6060 D5
|
||||
6090 C5
|
||||
|
||||
; 35
|
||||
6120 H5 E2
|
||||
6150 E3
|
||||
6180 E4
|
||||
6210 E4
|
||||
6240 E5
|
||||
6270 E4
|
||||
|
||||
; 36
|
||||
6300 E5
|
||||
6330 E5
|
||||
6360 E6
|
||||
6390 Dis5
|
||||
6420 E5
|
||||
6450 Dis5
|
||||
|
||||
; 37
|
||||
6480 E5
|
||||
6510 Dis5
|
||||
6540 E5
|
||||
6570 Dis5
|
||||
6600 E5
|
||||
6630 Dis5
|
||||
|
||||
; 38
|
||||
6660 E5
|
||||
6690 Dis5
|
||||
6720 E5
|
||||
6750 H5
|
||||
6780 D5
|
||||
6810 C5
|
||||
|
||||
; 39
|
||||
6840 A5 A3
|
||||
6870 E3
|
||||
6900 A4
|
||||
6930 C4
|
||||
6960 E4
|
||||
6990 A5
|
||||
|
||||
; 40
|
||||
7020 H5 E2
|
||||
7050 E3
|
||||
7080 Gis3
|
||||
7110 E4
|
||||
7140 Gis4
|
||||
7170 H5
|
||||
|
||||
; 41
|
||||
7200 C5 A3
|
||||
7230 E3
|
||||
7260 A4
|
||||
7290 E4
|
||||
7320 E5
|
||||
7350 Dis5
|
||||
|
||||
; 42
|
||||
7380 E5
|
||||
7410 Dis5
|
||||
7440 E5
|
||||
7470 H5
|
||||
7500 D5
|
||||
7530 C5
|
||||
|
||||
; 43
|
||||
7560 A5 A3
|
||||
7590 E3
|
||||
7620 A4
|
||||
7650 C4
|
||||
7680 E4
|
||||
7710 A5
|
||||
|
||||
; 44
|
||||
7740 H5 E2
|
||||
7770 E3
|
||||
7800 Gis3
|
||||
7830 E4
|
||||
7860 C5
|
||||
7890 H5
|
||||
|
||||
; 45
|
||||
7920 A5 A3
|
||||
7950 E3
|
||||
7980 A4
|
||||
8010 C5 E4 C4 B4
|
||||
8040 C5 F4 C4 A4
|
||||
8070 C5 G4 E4 B4 G3
|
||||
|
||||
; 46
|
||||
8100 C5 F3
|
||||
8130 A4
|
||||
8160 C4
|
||||
8190 A4
|
||||
8220 F5 C4
|
||||
8250 A4
|
||||
8265 E5
|
||||
|
||||
; 47
|
||||
8280 E5 F3
|
||||
8310 B4
|
||||
8340 D4
|
||||
8370 B4
|
||||
8400 B6 D4
|
||||
8430 B4
|
||||
8445 A6
|
||||
|
||||
; 48
|
||||
8460 A6 F3
|
||||
8490 G5 E4
|
||||
8520 F5 B4 G3 F3
|
||||
8550 E5 E4
|
||||
8580 D5 B4 G3 F3
|
||||
8610 C5 E4
|
||||
|
||||
; 49
|
||||
8640 B5 F3
|
||||
8670 A4
|
||||
8700 A5 C4
|
||||
8730 A4
|
||||
8760 A5 C4
|
||||
8775 G4
|
||||
8790 A5 A4
|
||||
8805 B5
|
||||
|
||||
; 50
|
||||
8820 C5 F3
|
||||
8850 A4
|
||||
8880 C4
|
||||
8910 A4
|
||||
8940 D5 C4
|
||||
8970 Dis5 A4
|
||||
|
||||
; 51
|
||||
9000 E5 E3
|
||||
9030 A4
|
||||
9060 C4
|
||||
9090 E5 A4
|
||||
9120 F5 D4 D3
|
||||
9150 A5 F3
|
||||
|
||||
; 52
|
||||
9180 C5 G3
|
||||
9210 E4
|
||||
9240 G3
|
||||
9270 E4
|
||||
9300 D5 G3
|
||||
9330 G4
|
||||
9345 H5
|
||||
|
||||
; 53
|
||||
9360 D5 E4 C4
|
||||
9375 G5
|
||||
9390 G4
|
||||
9405 G5
|
||||
9420 A5
|
||||
9435 G5
|
||||
9450 H5 G4 F4
|
||||
9465 G5
|
||||
9480 C5 G4 E4
|
||||
9495 G5
|
||||
9510 D5 G4 F4 D4
|
||||
9525 G5
|
||||
|
||||
; 54
|
||||
9540 E5 G4 E4 C4
|
||||
9555 G5
|
||||
9570 C6
|
||||
9585 H6
|
||||
9600 A6 A4 F3
|
||||
9615 G5
|
||||
9630 F5
|
||||
9645 E5
|
||||
9660 D5 H4 G3
|
||||
9675 G5
|
||||
9690 F5
|
||||
9705 D5
|
||||
|
||||
; 55
|
||||
9720 D5 E4 C4
|
||||
9735 G5
|
||||
9750 G4
|
||||
9765 G5
|
||||
9780 A5
|
||||
9795 G5
|
||||
9810 H5 G4 F4
|
||||
9825 G5
|
||||
9840 C5 G4 E4
|
||||
9855 G5
|
||||
9870 D5 G4 F4 D4
|
||||
9885 G5
|
||||
|
||||
; 56
|
||||
9900 E5 G4 E4 C4
|
||||
9915 G5
|
||||
9930 C6
|
||||
9945 H6
|
||||
9960 A6 A4 F3
|
||||
9975 G5
|
||||
9990 F5
|
||||
10005 E5
|
||||
10020 D5 H4 G3
|
||||
10035 G5
|
||||
10050 F5
|
||||
10065 D5
|
||||
|
||||
; 57
|
||||
10080 E5 A4 Gis3
|
||||
10095 F5
|
||||
10110 E5
|
||||
10125 Dis5
|
||||
10140 E5
|
||||
10155 H5
|
||||
10170 E5
|
||||
10185 Dis5
|
||||
10200 E5
|
||||
10215 H5
|
||||
10230 E5
|
||||
10245 Dis5
|
||||
|
||||
; 58
|
||||
10260 E5
|
||||
10350 H5
|
||||
10380 E5
|
||||
10410 Dis5
|
||||
|
||||
; 59
|
||||
10440 E5
|
||||
|
||||
10800 EoS
|
||||
@@ -0,0 +1,297 @@
|
||||
;‘c•ê‚Æ‚Ì‘z‚¢�o from DCTV (4/4 19bpm)
|
||||
|
||||
;<time tick> <note> <note> ...
|
||||
; 1
|
||||
0 B5
|
||||
2 Dis3
|
||||
100 B4
|
||||
150 Gis4
|
||||
175 G4
|
||||
200 Dis4
|
||||
|
||||
; 2
|
||||
400 C4
|
||||
404 Dis4 G3
|
||||
408 C3
|
||||
600 B3
|
||||
|
||||
; 3
|
||||
800 Gis3
|
||||
804 Gis4
|
||||
806 C4 F2
|
||||
900 C3
|
||||
950 G4
|
||||
975 F4
|
||||
1000 C4 F3
|
||||
1150 Dis4
|
||||
|
||||
; 4
|
||||
1200 D4
|
||||
1202 B4
|
||||
1203 F3
|
||||
1205 B3
|
||||
1400 F3
|
||||
1450 D4
|
||||
1500 C4
|
||||
1550 B4
|
||||
|
||||
; 5
|
||||
1600 B5
|
||||
1602 G2
|
||||
1650 D3
|
||||
1700 G3
|
||||
1750 D4
|
||||
1800 D5
|
||||
1900 B5
|
||||
|
||||
; 6
|
||||
2000 B5
|
||||
2003 C3
|
||||
2100 G3
|
||||
2197 C4
|
||||
2200 E4
|
||||
2201 G4
|
||||
2203 C5 B4
|
||||
|
||||
; 7
|
||||
2400 Gis4
|
||||
2404 F3
|
||||
2500 C4
|
||||
2550 Dis4
|
||||
2600 Gis4
|
||||
2700 B5
|
||||
2750 C5
|
||||
|
||||
; 8
|
||||
2800 C5
|
||||
2802 B3
|
||||
2900 F3
|
||||
2925 Dis4
|
||||
2950 Gis4
|
||||
2975 C5
|
||||
2996 B3
|
||||
2999 B4
|
||||
3000 D4
|
||||
3001 F4
|
||||
3002 B5
|
||||
|
||||
; 9
|
||||
3200 B5
|
||||
3202 Dis3
|
||||
3300 B4
|
||||
3350 Gis4
|
||||
3375 G4
|
||||
3400 Dis4
|
||||
3402 B4
|
||||
|
||||
; 10
|
||||
3600 B4
|
||||
3602 Dis4 C3
|
||||
3700 G3
|
||||
3800 B3
|
||||
3900 D4
|
||||
3950 Dis4
|
||||
|
||||
; 11
|
||||
4000 C4
|
||||
4002 Gis4
|
||||
4006 F2
|
||||
4100 C3
|
||||
4150 G4
|
||||
4175 F4
|
||||
4200 C4
|
||||
4202 F3
|
||||
4300 C4
|
||||
4350 Dis4
|
||||
|
||||
; 12
|
||||
4400 D4
|
||||
4401 F3
|
||||
4402 B4 B3
|
||||
4600 F3
|
||||
4650 D4
|
||||
4700 C4
|
||||
4750 B4
|
||||
|
||||
; 13
|
||||
4800 B5
|
||||
4802 G3
|
||||
4850 B4
|
||||
4900 D4
|
||||
4902 D3
|
||||
4950 G4
|
||||
5000 B5
|
||||
5002 G3
|
||||
5150 D5
|
||||
|
||||
; 14
|
||||
5200 B5
|
||||
5202 C3
|
||||
5300 G3
|
||||
5400 C4
|
||||
5401 E4
|
||||
5402 G4
|
||||
5403 B4
|
||||
5405 C5
|
||||
|
||||
; 15
|
||||
5600 C4 F3
|
||||
5602 Gis4 Gis3
|
||||
5604 Dis4
|
||||
5800 F3
|
||||
5850 Gis4
|
||||
5900 B5
|
||||
5950 C5
|
||||
|
||||
; 16
|
||||
6000 F4
|
||||
6003 Gis4 Dis5
|
||||
6005 B3
|
||||
6100 F3
|
||||
6200 F4
|
||||
6203 B5
|
||||
6206 D5 B4
|
||||
|
||||
; 17
|
||||
6400 Dis4
|
||||
6403 G4
|
||||
6405 B5
|
||||
6407 B4 Dis3
|
||||
6600 Dis3
|
||||
6650 G4
|
||||
6700 Gis4
|
||||
6750 B5
|
||||
|
||||
; 18
|
||||
6800 C4
|
||||
6801 Dis4
|
||||
6802 B4 C5
|
||||
7000 Gis3
|
||||
|
||||
; 19
|
||||
7200 B3 D4
|
||||
7202 F3 F4
|
||||
7204 B4
|
||||
7400 B4
|
||||
7450 F4
|
||||
7500 G4
|
||||
7550 Gis4
|
||||
|
||||
; 20
|
||||
7600 D4
|
||||
7603 G4
|
||||
7605 B5 G3
|
||||
7800 D3
|
||||
7900 G3
|
||||
|
||||
; 21
|
||||
8000 C3 G3
|
||||
8001 Dis4 C4
|
||||
8200 Dis4
|
||||
8203 B3
|
||||
8250 Dis4
|
||||
8300 F4
|
||||
8350 G4
|
||||
|
||||
; 22
|
||||
8400 C4
|
||||
8402 Gis4 F4
|
||||
8404 F2
|
||||
8600 C3
|
||||
8650 F3
|
||||
8700 G4
|
||||
8750 F4
|
||||
|
||||
; 23
|
||||
8800 C4
|
||||
8801 Gis3
|
||||
8802 B3
|
||||
9050 Gis3
|
||||
9100 C4
|
||||
9150 Dis4
|
||||
|
||||
; 24
|
||||
9200 B3
|
||||
9201 D4 B4
|
||||
9202 F3
|
||||
9400 F3
|
||||
|
||||
; 25
|
||||
9600 B5 Dis3
|
||||
9700 B4
|
||||
9750 D4
|
||||
9775 G4
|
||||
9800 B5
|
||||
9900 D5
|
||||
|
||||
; 26
|
||||
10000 E4
|
||||
10004 G4
|
||||
10008 C5 C3
|
||||
10100 G3
|
||||
10200 C4
|
||||
10204 E4
|
||||
10208 G4
|
||||
10210 C5
|
||||
|
||||
; 27
|
||||
10400 Gis4
|
||||
10402 F2
|
||||
10500 C3
|
||||
10550 C4
|
||||
10575 Dis4
|
||||
10600 Gis4 F3
|
||||
10700 B5
|
||||
10750 C5
|
||||
|
||||
; 28
|
||||
10800 D4
|
||||
10804 F4
|
||||
10806 B5 B3
|
||||
10900 F3
|
||||
11000 B4
|
||||
|
||||
; 29
|
||||
11200 D4
|
||||
11204 F4
|
||||
11206 B5 G2
|
||||
11300 D3
|
||||
11400 G3
|
||||
11450 B5
|
||||
11500 C5
|
||||
11550 D5
|
||||
|
||||
; 30
|
||||
11600 C3
|
||||
11604 G3 E4
|
||||
11606 B4 G4
|
||||
11608 B5
|
||||
11800 C5
|
||||
|
||||
; 31
|
||||
12000 F2
|
||||
12003 C3 C4
|
||||
12006 F3
|
||||
12009 Dis4 Gis4
|
||||
12300 G4
|
||||
12350 F4
|
||||
|
||||
; 32
|
||||
12400 B3 C4
|
||||
12402 Gis3 F4
|
||||
12700 D4
|
||||
|
||||
; 33
|
||||
12800 Gis2 B4
|
||||
12803 Dis4 Gis3
|
||||
13000 Dis3
|
||||
|
||||
; 34
|
||||
13200 Dis2
|
||||
13206 B3
|
||||
13212 Dis3
|
||||
13218 G3
|
||||
13224 B4
|
||||
13230 Dis4
|
||||
|
||||
14000 EoS
|
||||
@@ -0,0 +1,198 @@
|
||||
; Kanon (4/4 19bpm)
|
||||
|
||||
;1
|
||||
0 C3
|
||||
1 E4
|
||||
2 A5
|
||||
50 E3
|
||||
75 H5
|
||||
100 G3
|
||||
150 H4 E4
|
||||
200 G3
|
||||
250 H4
|
||||
300 E4
|
||||
350 H4
|
||||
|
||||
;2
|
||||
400 C3
|
||||
401 E4
|
||||
402 A5
|
||||
450 E3
|
||||
475 H5
|
||||
500 G3
|
||||
550 H4 E4
|
||||
600 G3
|
||||
650 H4
|
||||
700 E4
|
||||
750 H4
|
||||
|
||||
;3
|
||||
800 H3
|
||||
801 E4
|
||||
802 A5
|
||||
850 D3
|
||||
875 H5
|
||||
900 Fis3
|
||||
950 A4 D5
|
||||
1000 Fis3
|
||||
1050 A4
|
||||
1100 D4
|
||||
1150 A4
|
||||
|
||||
;4
|
||||
1200 H3
|
||||
1201 E4
|
||||
1202 A5
|
||||
1250 D3
|
||||
1275 H5
|
||||
1300 Fis3
|
||||
1350 A4 D5
|
||||
1400 Fis3
|
||||
1450 A4
|
||||
1500 D4
|
||||
1550 A4
|
||||
|
||||
;5
|
||||
1600 C3
|
||||
1601 E4
|
||||
1602 A5
|
||||
1650 E3
|
||||
1675 H5
|
||||
1700 G3
|
||||
1750 H4 E4
|
||||
1800 G3
|
||||
1850 H4
|
||||
1900 E4
|
||||
1950 H4
|
||||
|
||||
;6
|
||||
2000 C3
|
||||
2001 E4
|
||||
2002 A5
|
||||
2050 E3
|
||||
2075 H5
|
||||
2100 G3
|
||||
2150 H4 E4
|
||||
2200 G3
|
||||
2250 H4
|
||||
2300 E4
|
||||
2350 H4
|
||||
|
||||
;7
|
||||
2400 H3
|
||||
2401 E4
|
||||
2402 A5
|
||||
2450 D3
|
||||
2475 H5
|
||||
2500 Fis3
|
||||
2550 A4 D5
|
||||
2600 Fis3
|
||||
2650 A4
|
||||
2700 D4
|
||||
2750 A4
|
||||
|
||||
;8
|
||||
2800 H3
|
||||
2801 E4
|
||||
2802 A5
|
||||
2850 D3
|
||||
2875 H5
|
||||
2900 Fis3
|
||||
2950 A4 E4
|
||||
2952 E5
|
||||
3000 Fis3
|
||||
3050 D4 D5
|
||||
3100 A4 H5
|
||||
3125 A5
|
||||
3150 E3
|
||||
|
||||
;9
|
||||
3200 E3
|
||||
3201 A4
|
||||
3202 G4
|
||||
3250 G3
|
||||
3300 H4
|
||||
3350 D4
|
||||
3400 H4
|
||||
3450 Fis4
|
||||
3500 G3
|
||||
3550 H4 G4
|
||||
|
||||
;10
|
||||
3600 Dis3
|
||||
3602 G4
|
||||
3650 G3
|
||||
3700 H4
|
||||
3750 Dis4
|
||||
3800 H4 A5
|
||||
3850 G3
|
||||
3875 G4
|
||||
3900 Dis4
|
||||
3950 H4 A5
|
||||
|
||||
;11
|
||||
4000 D3
|
||||
4002 H5
|
||||
4050 Fis3
|
||||
4100 A4
|
||||
4150 D4
|
||||
4200 A4 H5
|
||||
4250 Fis4
|
||||
4275 D5
|
||||
4300 Fis3
|
||||
4350 A4 E5
|
||||
|
||||
;12
|
||||
4400 Cis3
|
||||
4402 H5
|
||||
4450 E3
|
||||
4500 G3
|
||||
4550 H4
|
||||
4600 G3
|
||||
4650 H4 A5
|
||||
4700 E4 G4
|
||||
4750 H4 Fis4
|
||||
|
||||
;13
|
||||
4800 C3
|
||||
4802 E4
|
||||
4850 E3
|
||||
4900 G3
|
||||
4950 H4
|
||||
5000 G3 H5
|
||||
5050 H4
|
||||
5100 E4 A5
|
||||
5150 H4
|
||||
|
||||
;14
|
||||
5200 H3
|
||||
5202 Fis4
|
||||
5250 D3
|
||||
5300 Fis3
|
||||
5350 A4
|
||||
5400 Fis3
|
||||
5450 A4
|
||||
5500 D4
|
||||
5550 A4
|
||||
|
||||
;15
|
||||
5600 E3
|
||||
5602 E4
|
||||
5650 D3
|
||||
5700 Fis3
|
||||
5750 A4
|
||||
5752 A5
|
||||
5800 Fis3
|
||||
5850 A4
|
||||
5900 D4 H5
|
||||
5950 A4
|
||||
|
||||
;16
|
||||
6000 E2
|
||||
6004 D4
|
||||
6007 E5
|
||||
6012 H3
|
||||
6016 E3
|
||||
|
||||
6800 EoS
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# perl mel2asm.pl < mel.txt > melody.asm
|
||||
|
||||
|
||||
foreach (<STDIN>) {
|
||||
chop;
|
||||
s/;.*$//;
|
||||
@lst = split(/ /);
|
||||
if(@lst < 2) { next; }
|
||||
$n = $lst[0] & 255; &putb;
|
||||
$n = $lst[0] >> 8; &putb;
|
||||
$p = 1;
|
||||
while($lst[$p] ne '') {
|
||||
$n = $lst[$p++];
|
||||
if($lst[$p] eq '') { $n .= "|en"; }
|
||||
&putb;
|
||||
}
|
||||
}
|
||||
|
||||
print "\n;$cnt\n";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
sub putb
|
||||
{
|
||||
$cnt++;
|
||||
if($c == 0) {
|
||||
print "\n\t.db $n";
|
||||
} else {
|
||||
print ", $n";
|
||||
}
|
||||
$c = ($c + 1) & 15;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
|
||||
.db 120, 0, E5|en, 150, 0, Dis5|en, 180, 0, E5|en, 210, 0, Dis5|en, 240, 0, E5|en, 14
|
||||
.db 1, H5|en, 44, 1, D5|en, 74, 1, C5|en, 104, 1, A5, A3|en, 134, 1, E3|en, 164
|
||||
.db 1, A4|en, 194, 1, C4|en, 224, 1, E4|en, 254, 1, A5|en, 28, 2, H5, E2|en, 58
|
||||
.db 2, E3|en, 88, 2, Gis3|en, 118, 2, E4|en, 148, 2, Gis4|en, 178, 2, H5|en, 208, 2
|
||||
.db C5, A3|en, 238, 2, E3|en, 12, 3, A4|en, 42, 3, E4|en, 72, 3, E5|en, 102, 3
|
||||
.db Dis5|en, 132, 3, E5|en, 162, 3, Dis5|en, 192, 3, E5|en, 222, 3, H5|en, 252, 3, D5|en
|
||||
.db 26, 4, C5|en, 56, 4, A5, A3|en, 86, 4, E3|en, 116, 4, A4|en, 146, 4, C4|en
|
||||
.db 176, 4, E4|en, 206, 4, A5|en, 236, 4, H5, E2|en, 10, 5, E3|en, 40, 5, Gis3|en
|
||||
.db 70, 5, E4|en, 100, 5, C5|en, 130, 5, H5|en, 160, 5, A5, A3|en, 190, 5, E3|en
|
||||
.db 220, 5, A4|en, 24, 6, E5|en, 54, 6, Dis5|en, 84, 6, E5|en, 114, 6, Dis5|en, 144
|
||||
.db 6, E5|en, 174, 6, H5|en, 204, 6, D5|en, 234, 6, C5|en, 8, 7, A5, A3|en, 38
|
||||
.db 7, E3|en, 68, 7, A4|en, 98, 7, C4|en, 128, 7, E4|en, 158, 7, A5|en, 188, 7
|
||||
.db H5, E2|en, 218, 7, E3|en, 248, 7, Gis3|en, 22, 8, E4|en, 52, 8, Gis4|en, 82, 8
|
||||
.db H5|en, 112, 8, C5, A3|en, 142, 8, E3|en, 172, 8, A4|en, 202, 8, E4|en, 232, 8
|
||||
.db E5|en, 6, 9, Dis5|en, 36, 9, E5|en, 66, 9, Dis5|en, 96, 9, E5|en, 126, 9, H5|en
|
||||
.db 156, 9, D5|en, 186, 9, C5|en, 216, 9, A5, A3|en, 246, 9, E3|en, 20, 10, A4|en
|
||||
.db 50, 10, C4|en, 80, 10, E4|en, 110, 10, A5|en, 140, 10, H5, E2|en, 170, 10, E3|en
|
||||
.db 200, 10, Gis3|en, 230, 10, E4|en, 4, 11, C5|en, 34, 11, H5|en, 64, 11, A5, A3|en
|
||||
.db 94, 11, E3|en, 124, 11, A4|en, 154, 11, H5|en, 184, 11, C5|en, 214, 11, D5|en, 244
|
||||
.db 11, E5, C3|en, 18, 12, G3|en, 48, 12, C4|en, 78, 12, G4|en, 108, 12, F5|en, 138
|
||||
.db 12, E5|en, 168, 12, D5, G2|en, 198, 12, G3|en, 228, 12, A4|en, 2, 13, F4|en, 32
|
||||
.db 13, E5|en, 62, 13, D5|en, 92, 13, C5, A3|en, 122, 13, E3|en, 152, 13, A4|en, 182
|
||||
.db 13, E4|en, 212, 13, D5|en, 242, 13, C5|en, 16, 14, H5, E2|en, 46, 14, E3|en, 76
|
||||
.db 14, E4|en, 106, 14, E4|en, 136, 14, E5|en, 166, 14, E4|en, 196, 14, E5|en, 226, 14
|
||||
.db E5|en, 0, 15, E6|en, 30, 15, Dis5|en, 60, 15, E5|en, 90, 15, Dis5|en, 120, 15, E5|en
|
||||
.db 150, 15, Dis5|en, 180, 15, E5|en, 210, 15, Dis5|en, 240, 15, E5|en, 14, 16, Dis5|en, 44
|
||||
.db 16, E5|en, 74, 16, Dis5|en, 104, 16, E5|en, 134, 16, H5|en, 164, 16, D5|en, 194, 16
|
||||
.db C5|en, 224, 16, A5, A3|en, 254, 16, E3|en, 28, 17, A4|en, 58, 17, C4|en, 88, 17
|
||||
.db E4|en, 118, 17, A5|en, 148, 17, H5, E2|en, 178, 17, E3|en, 208, 17, Gis3|en, 238, 17
|
||||
.db E4|en, 12, 18, Gis4|en, 42, 18, H5|en, 72, 18, C5, A3|en, 102, 18, E3|en, 132, 18
|
||||
.db A4|en, 162, 18, E4|en, 192, 18, E5|en, 222, 18, Dis5|en, 252, 18, E5|en, 26, 19, Dis5|en
|
||||
.db 56, 19, E5|en, 86, 19, H5|en, 116, 19, D5|en, 146, 19, C5|en, 176, 19, A5, A3|en
|
||||
.db 206, 19, E3|en, 236, 19, A4|en, 10, 20, C4|en, 40, 20, E4|en, 70, 20, A5|en, 100
|
||||
.db 20, H5, E2|en, 130, 20, E3|en, 160, 20, Gis3|en, 190, 20, E4|en, 220, 20, C5|en, 250
|
||||
.db 20, H5|en, 24, 21, A5, A3|en, 54, 21, E3|en, 84, 21, A4|en, 114, 21, H5|en, 144
|
||||
.db 21, C5|en, 174, 21, D5|en, 204, 21, E5, C3|en, 234, 21, G3|en, 8, 22, C4|en, 38
|
||||
.db 22, G4|en, 68, 22, F5|en, 98, 22, E5|en, 128, 22, D5, G2|en, 158, 22, G3|en, 188
|
||||
.db 22, A4|en, 218, 22, F4|en, 248, 22, E5|en, 22, 23, D5|en, 52, 23, C5, A3|en, 82
|
||||
.db 23, E3|en, 112, 23, A4|en, 142, 23, E4|en, 172, 23, D5|en, 202, 23, C5|en, 232, 23
|
||||
.db H5, E2|en, 6, 24, E3|en, 36, 24, E4|en, 66, 24, E4|en, 96, 24, E5|en, 126, 24
|
||||
.db E4|en, 156, 24, E5|en, 186, 24, E5|en, 216, 24, E6|en, 246, 24, Dis5|en, 20, 25, E5|en
|
||||
.db 50, 25, Dis5|en, 80, 25, E5|en, 110, 25, Dis5|en, 140, 25, E5|en, 170, 25, Dis5|en, 200
|
||||
.db 25, E5|en, 230, 25, Dis5|en, 4, 26, E5|en, 34, 26, Dis5|en, 64, 26, E5|en, 94, 26
|
||||
.db H5|en, 124, 26, D5|en, 154, 26, C5|en, 184, 26, A5, A3|en, 214, 26, E3|en, 244, 26
|
||||
.db A4|en, 18, 27, C4|en, 48, 27, E4|en, 78, 27, A5|en, 108, 27, H5, E2|en, 138, 27
|
||||
.db E3|en, 168, 27, Gis3|en, 198, 27, E4|en, 228, 27, Gis4|en, 2, 28, H5|en, 32, 28, C5
|
||||
.db A3|en, 62, 28, E3|en, 92, 28, A4|en, 122, 28, E4|en, 152, 28, E5|en, 182, 28, Dis5|en
|
||||
.db 212, 28, E5|en, 242, 28, Dis5|en, 16, 29, E5|en, 46, 29, H5|en, 76, 29, D5|en, 106
|
||||
.db 29, C5|en, 136, 29, A5, A3|en, 166, 29, E3|en, 196, 29, A4|en, 226, 29, C4|en, 0
|
||||
.db 30, E4|en, 30, 30, A5|en, 60, 30, H5, E2|en, 90, 30, E3|en, 120, 30, Gis3|en, 150
|
||||
.db 30, E4|en, 180, 30, C5|en, 210, 30, H5|en, 240, 30, A5, A3|en, 14, 31, E3|en, 44
|
||||
.db 31, A4|en, 74, 31, C5, E4, C4, B4|en, 104, 31, C5, F4, C4, A4|en, 134, 31
|
||||
.db C5, G4, E4, B4, G3|en, 164, 31, C5, F3|en, 194, 31, A4|en, 224, 31, C4|en, 254
|
||||
.db 31, A4|en, 28, 32, F5, C4|en, 58, 32, A4|en, 73, 32, E5|en, 88, 32, E5, F3|en
|
||||
.db 118, 32, B4|en, 148, 32, D4|en, 178, 32, B4|en, 208, 32, B6, D4|en, 238, 32, B4|en
|
||||
.db 253, 32, A6|en, 12, 33, A6, F3|en, 42, 33, G5, E4|en, 72, 33, F5, B4, G3
|
||||
.db F3|en, 102, 33, E5, E4|en, 132, 33, D5, B4, G3, F3|en, 162, 33, C5, E4|en, 192
|
||||
.db 33, B5, F3|en, 222, 33, A4|en, 252, 33, A5, C4|en, 26, 34, A4|en, 56, 34, A5
|
||||
.db C4|en, 71, 34, G4|en, 86, 34, A5, A4|en, 101, 34, B5|en, 116, 34, C5, F3|en, 146
|
||||
.db 34, A4|en, 176, 34, C4|en, 206, 34, A4|en, 236, 34, D5, C4|en, 10, 35, Dis5, A4|en
|
||||
.db 40, 35, E5, E3|en, 70, 35, A4|en, 100, 35, C4|en, 130, 35, E5, A4|en, 160, 35
|
||||
.db F5, D4, D3|en, 190, 35, A5, F3|en, 220, 35, C5, G3|en, 250, 35, E4|en, 24, 36
|
||||
.db G3|en, 54, 36, E4|en, 84, 36, D5, G3|en, 114, 36, G4|en, 129, 36, H5|en, 144, 36
|
||||
.db D5, E4, C4|en, 159, 36, G5|en, 174, 36, G4|en, 189, 36, G5|en, 204, 36, A5|en, 219
|
||||
.db 36, G5|en, 234, 36, H5, G4, F4|en, 249, 36, G5|en, 8, 37, C5, G4, E4|en, 23
|
||||
.db 37, G5|en, 38, 37, D5, G4, F4, D4|en, 53, 37, G5|en, 68, 37, E5, G4, E4
|
||||
.db C4|en, 83, 37, G5|en, 98, 37, C6|en, 113, 37, H6|en, 128, 37, A6, A4, F3|en, 143
|
||||
.db 37, G5|en, 158, 37, F5|en, 173, 37, E5|en, 188, 37, D5, H4, G3|en, 203, 37, G5|en
|
||||
.db 218, 37, F5|en, 233, 37, D5|en, 248, 37, D5, E4, C4|en, 7, 38, G5|en, 22, 38
|
||||
.db G4|en, 37, 38, G5|en, 52, 38, A5|en, 67, 38, G5|en, 82, 38, H5, G4, F4|en, 97
|
||||
.db 38, G5|en, 112, 38, C5, G4, E4|en, 127, 38, G5|en, 142, 38, D5, G4, F4, D4|en
|
||||
.db 157, 38, G5|en, 172, 38, E5, G4, E4, C4|en, 187, 38, G5|en, 202, 38, C6|en, 217
|
||||
.db 38, H6|en, 232, 38, A6, A4, F3|en, 247, 38, G5|en, 6, 39, F5|en, 21, 39, E5|en
|
||||
.db 36, 39, D5, H4, G3|en, 51, 39, G5|en, 66, 39, F5|en, 81, 39, D5|en, 96, 39
|
||||
.db E5, A4, Gis3|en, 111, 39, F5|en, 126, 39, E5|en, 141, 39, Dis5|en, 156, 39, E5|en, 171
|
||||
.db 39, H5|en, 186, 39, E5|en, 201, 39, Dis5|en, 216, 39, E5|en, 231, 39, H5|en, 246, 39
|
||||
.db E5|en, 5, 40, Dis5|en, 20, 40, E5|en, 110, 40, H5|en, 140, 40, E5|en, 170, 40, Dis5|en
|
||||
.db 200, 40, E5|en, 48, 42, EoS|en
|
||||
;1238
|
||||
+380
@@ -0,0 +1,380 @@
|
||||
;----------------------------------------------------------;
|
||||
; Melody Generator (C)ChaN, 2005
|
||||
|
||||
|
||||
.include "tn45def.inc" ;This is included in "Atmel AVR Studio"
|
||||
.include "avr.inc"
|
||||
.include "mg.inc"
|
||||
|
||||
.def _0 = r15
|
||||
.def _Sreg = r14
|
||||
.def _Zreg = r12
|
||||
.def _Yreg = r10
|
||||
.def _TmrH = r9
|
||||
.def _TmrL = r8
|
||||
.def _TmrS = r7
|
||||
|
||||
.equ N_NOTE = 6
|
||||
|
||||
|
||||
;----------------------------------------------------------;
|
||||
; Work Area
|
||||
|
||||
.dseg
|
||||
.org RAMTOP
|
||||
NoteIdx:.byte 1 ; Note rotation index
|
||||
|
||||
Notes: .byte (2+3+1+1+1+1)*N_NOTE
|
||||
.equ ns_freq = 0 ;Angular Speed
|
||||
.equ ns_rptr = 2 ;Wave table read pointer (16.8 fraction)
|
||||
.equ ns_lvl = 5 ;Level
|
||||
.equ ns_wrap = 6 ;Loop Flag
|
||||
.equ ns_loop = 7 ;Loop Count
|
||||
.equ ns_lp = 8 ;Level Pointer
|
||||
.equ nsize = 9 ;size of this structure
|
||||
|
||||
|
||||
;----------------------------------------------------------;
|
||||
; Program Code
|
||||
|
||||
.cseg
|
||||
; Interrupt Vectors (ATtiny45)
|
||||
rjmp reset ; Reset
|
||||
rjmp 0 ; INT0
|
||||
rjmp 0 ; PCINT0
|
||||
rjmp 0 ; TC1_COMA
|
||||
rjmp 0 ; TC1_OVF
|
||||
rjmp 0 ; TC0_OVF
|
||||
rjmp 0 ; EE_RDY
|
||||
rjmp 0 ; ANA_COMP
|
||||
rjmp 0 ; ADC
|
||||
rjmp 0 ; TC1_COMB
|
||||
rjmp isr_tc0_coma ; TC0_COMA
|
||||
; rjmp 0 ; TC0_COMB
|
||||
; rjmp 0 ; WDT
|
||||
; rjmp 0 ; USI_START
|
||||
; rjmp 0 ; USI_OVF
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; Program Code
|
||||
|
||||
reset:
|
||||
clr _0
|
||||
ldiw X, RAMTOP ;Clear RAM
|
||||
ldi AL, 0 ;AL = 0
|
||||
st X+, _0 ; X address of RAM = _0
|
||||
dec AL ; AL = AL-1
|
||||
brne PC-2 ;循环256次?
|
||||
|
||||
; outi OSCCAL, 172 ;Adjust OSCCAL if needed.
|
||||
|
||||
outi PORTB, 0b001101 ;Initalize Port B
|
||||
outi DDRB, 0b010010 ;/
|
||||
|
||||
outi PLLCSR, 0b00000110 ;Initialize TC1 in 250 kHz fast PWM mode.
|
||||
outi TCCR1, 0b01100001 ;Connect TC1 to OC1A
|
||||
outi GTCCR, 0b01100000 ;Connect TC1 to OC1B
|
||||
|
||||
outi OCR0A, 62 ;Initalize TC0 in 32 kHz interval timer.
|
||||
outi TCCR0A, 0b00000010
|
||||
outi TCCR0B, 0b00000010
|
||||
outi TIMSK, (1<<OCIE0A)
|
||||
|
||||
|
||||
start_play:
|
||||
ldiw Z, score*2 ;score地址放到Z,*2是取低字节地址
|
||||
cli ;清全局中断标志
|
||||
clrw _Tmr ;清计数器
|
||||
clr _TmrS ;清timers
|
||||
sei ;开中断
|
||||
|
||||
pl_next:
|
||||
lpmw B, Z+ ;//把Z的数放入B,然后z+1
|
||||
rcall drv_decay ;//调用衰变包络生成函数,遍历每个通道,包络值放到ns_lvl寄存器
|
||||
cli ;//关中断
|
||||
cpw _Tmr, B ;//比较两个字,
|
||||
sei ;开中断
|
||||
brcs PC-5 ;如果C flag==1跳转到pl_next这里;<=B则继续循环
|
||||
|
||||
pl_note:
|
||||
lpm CL, Z+ ;把Z地址的数放入CL,也就是乐谱
|
||||
cpi CL, EoS ;EOS是乐谱结束标志
|
||||
breq start_play ;结束就跳回start_play
|
||||
mov AL, CL ;AL = CL
|
||||
rcall note_on ;调用note_on函数
|
||||
andi CL, en ;
|
||||
breq pl_note ;if CL==0 jmp to pl_note
|
||||
rjmp pl_next ;长跳转(+-2K words),CL部位0调到pl_next
|
||||
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; Note ON
|
||||
;
|
||||
;Call: AL[6:0] = key number
|
||||
;AL是传递过来的乐谱数据,也就是键值
|
||||
|
||||
note_on:
|
||||
pushw Z
|
||||
|
||||
mov ZL, AL ;ZL = AL
|
||||
lsl ZL ;左移一位
|
||||
clr ZH ;ZH = 0
|
||||
addiw Z, tbl_pitch*2 ;加载音高表地址
|
||||
lpmw A, Z+ ;读取音高值到A
|
||||
|
||||
lds YL, NoteIdx ;读取NoteIdx音调循环索引到YL
|
||||
addi YL, 9 ;YL+9
|
||||
cpi YL, 9*N_NOTE ;比较YL和通道数的9倍
|
||||
brcs PC+2 ;YL小于9*N_NOTE跳转到继续+9
|
||||
clr YL ;清掉YL
|
||||
sts NoteIdx, YL ;NoteIdx = YL
|
||||
clr YH ;清掉YH
|
||||
addiw Y, Notes ;YL+Notes
|
||||
|
||||
ldiw B, wt_attack*2 ;加载attach表地址到B寄存器
|
||||
cli ;关中断
|
||||
stdw Y+ns_freq, A ;把A也就是音高值放入ns_freq寄存器,两个字节
|
||||
stdw Y+ns_rptr+1, B ;把B也就是attach值放入ns_rpter+1(波表读取指针)寄存器,两个字节
|
||||
sei ;开中断
|
||||
stdi Y+ns_lvl, 255 ;255放入ns_lvl寄存器
|
||||
std Y+ns_wrap, AL ;AL放入ns_warp
|
||||
std Y+ns_loop, _0 ;_0放入ns_loop
|
||||
std Y+ns_lp, _0 ;_0放入ns_lp
|
||||
|
||||
popw Z
|
||||
ret
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; Decay envelope generation 衰变包络生成器
|
||||
; 1.判断该通道循环标志ns_wrap,如果等于255则不需要生成包络,跳到下一通道
|
||||
; 2.判断循环次数ns_loop,如果循环次数小于12则不需要生成,跳到下一通道
|
||||
; 3.判断层指针,如果层指针小于255,则生成完成,跳到下一通道;否则根据层指针加载包络表数据,并放入ns_lvl变量;
|
||||
; 4.判断是否所有通道处理完,处理完则退出
|
||||
; 该函数也就是遍历所有通道并判断是否需要加载包络表,需要的把包络表(对应层数)数据放到对应通道的ns_lvl变量里面。
|
||||
; N1:对于Flash存储器的间址取数只能使用Z寄存器。由于程序存储器的地址是以字(双字节)为单位的,因此,16位地址指针寄存器Z的高15位为程序存储器的字地址,最低位LSB为“0”时,指字的低字节;为“1”时,指字的高字节。程序中使用伪指令db定义的七段码为一个字节,他保存在一个字的低字节处。如果定义字,应使用伪指令dw。
|
||||
|
||||
drv_decay:
|
||||
pushw Z ;保存地址入栈
|
||||
ldiw Y, Notes ;加载Notes地址
|
||||
dd_lp:
|
||||
ldd AL, Y+ns_wrap ;Has sustain loop not wrapped? 把循环标志数据放入AL
|
||||
ldi AH, 255 ;把255放入AH
|
||||
cp AL, AH ;比较AL和AH
|
||||
breq dd_nxt ;/相等跳转,所以ns_wrap==255时该通道不需要生成包络
|
||||
std Y+ns_wrap, AH ;Clear wrapped flag. AH的数保存到循环标志寄存器,这样下次就不需要再生成包络
|
||||
ldd AL, Y+ns_loop ;循环数放到AL
|
||||
inc AL ;循环次数加1
|
||||
cpi AL, 12 ;循环次数是否到12,12大则C flag=1;
|
||||
brcs PC+2 ;如果C flag==1跳转,也就是小于12次
|
||||
ldi AL, 0 ;大于等于12次则AL清0
|
||||
std Y+ns_loop, AL ;AL数放到ns_loop循环次数寄存器
|
||||
brcs dd_nxt ;循环次数小于12跳转到下一通道
|
||||
ldd ZL, Y+ns_lp ;层指针放到ZL
|
||||
inc ZL ;层指针+1, 如果溢出ZL=0;则Z flag=1;
|
||||
breq dd_nxt ;Z flag==1跳转,即层指针溢出则跳到下一通道
|
||||
std Y+ns_lp, ZL ;不溢出则更新层指针寄存器
|
||||
clr ZH ;ZH = 0
|
||||
addiw Z, envelope*2 ;加载包络表地址到Z,因为包络表是16x16的单字节,存在于Z地址的低8位,所以*2。具体查看上面N1注释.
|
||||
lpm AL, Z ;把Z地址的数据放入AL
|
||||
std Y+ns_lvl, AL ;包络数据放入lvl层变量
|
||||
dd_nxt: adiw YL, 9 ;切换到下一个通道的数组,9是每通道的结构体长度
|
||||
cpi YL, low(Notes+nsize*N_NOTE) ;比较是否处理完所有通道
|
||||
brne dd_lp ;不等跳转,也就是通道还没处理完
|
||||
|
||||
popw Z ;出栈Z
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; 32 kHz wave form synthesising interrupt
|
||||
|
||||
|
||||
isr_tc0_coma:
|
||||
in _Sreg, SREG ;Save regs...
|
||||
movw _Zreg, ZL ;
|
||||
movw _Yreg, YL ;/
|
||||
|
||||
ldiw Y, Notes ;Process all notes
|
||||
clrw T2 ;Clear accumlator
|
||||
tone_lp:
|
||||
ldd EH, Y+ns_rptr ;Load wave table pointer
|
||||
lddw Z, Y+ns_rptr+1 ;/
|
||||
lpm EL, Z ;Get a sample
|
||||
lddw T4, Y+ns_freq ;Load angular speed
|
||||
add EH, T4L ;Increase wave table ptr (next angle)
|
||||
adc ZL, T4H ;
|
||||
adc ZH, _0 ;/
|
||||
cpi ZH, high(wt_end*2) ;Repeat sustain area
|
||||
brcs PC+4 ;
|
||||
subiw Z, (wt_end-wt_loop)*2 ;
|
||||
std Y+ns_wrap, _0 ;/
|
||||
std Y+ns_rptr, EH ;Save wave table ptr
|
||||
stdw Y+ns_rptr+1, Z ;/
|
||||
ldd EH, Y+ns_lvl ;Apply envelope curve
|
||||
MULT ;/
|
||||
addw T2, T0 ;Add the sample to accumlator
|
||||
adiw YL, 9 ;Next note
|
||||
cpi YL, low(Notes+nsize*N_NOTE);
|
||||
brne tone_lp ;/
|
||||
|
||||
asrw T2 ;Divide it by 4
|
||||
asrw T2 ;/
|
||||
ldiw E, 253 ;Clip it between -255 to 253
|
||||
cpw T2, E ;
|
||||
brlt PC+2 ;
|
||||
movw T2L, EL ;
|
||||
ldiw E, -255 ;
|
||||
cpw T2, E ;
|
||||
brge PC+2 ;
|
||||
movw T2L, EL ;/
|
||||
asrw T2 ;Set it to PWM modulator
|
||||
ror T2H ;
|
||||
mov EL, T2L ;
|
||||
subi EL, 0x80 ;
|
||||
mov EH, EL ;
|
||||
com EH ;
|
||||
sbrc T2H, 7 ;
|
||||
inc EL ;
|
||||
out OCR1A, EL ;
|
||||
out OCR1B, EH ;/
|
||||
|
||||
sec ;Increment sequense timer
|
||||
adc _TmrS, _0 ;
|
||||
adc _TmrL, _0 ;
|
||||
adc _TmrH, _0 ;/
|
||||
|
||||
movw ZL, _Zreg ;Restore regs...
|
||||
movw YL, _Yreg ;
|
||||
out SREG, _Sreg ;/
|
||||
|
||||
reti
|
||||
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; Score table
|
||||
;--------------------------------------------------------------------;
|
||||
|
||||
score:
|
||||
.include "melody.asm"
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; Pitch number to angular speed conversion table
|
||||
;--------------------------------------------------------------------;
|
||||
;Since sustain area of wave table, a cycle of fundamental frequency, is sampled
|
||||
;in 128 points, the base frequency becomes 32000/128 = 250 Hz. The wave table
|
||||
;lookup pointer, 16.8 fraction, is increased every sample by these 8.8 fractional
|
||||
;angular speed values.
|
||||
|
||||
tbl_pitch: ; A B H C Cis D Dis E F Fis G Gis
|
||||
.dw 225, 239, 253, 268, 284, 301, 319, 338, 358, 379, 401, 425 ; 220Hz..
|
||||
.dw 451, 477, 506, 536, 568, 601, 637, 675, 715, 758, 803, 851 ; 440Hz..
|
||||
.dw 901, 955, 1011, 1072, 1135, 1203, 1274, 1350, 1430, 1515, 1606, 1701 ; 880Hz..
|
||||
.dw 1802, 1909, 2023, 2143, 2271, 2406, 2549, 2700, 2861, 3031, 3211, 3402 ; 1760Hz..
|
||||
.dw 3604, 3818, 4046, 4286, 4542, 4812, 5098, 5400 ; 3520Hz
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; Envelope Table
|
||||
;--------------------------------------------------------------------;
|
||||
|
||||
envelope:
|
||||
.db 255,252,250,247,245,243,240,238,235,233,231,228,226,224,222,219
|
||||
.db 217,215,213,211,209,207,205,203,201,199,197,195,193,191,189,187
|
||||
.db 185,183,182,180,178,176,174,173,171,169,168,166,164,163,161,159
|
||||
.db 158,156,155,153,152,150,149,147,146,144,143,141,140,139,137,136
|
||||
.db 134,133,132,130,129,128,127,125,124,123,122,120,119,118,117,116
|
||||
.db 115,113,112,111,110,109,108,107,106,105,104,103,102,101,100,99
|
||||
.db 98,97,96,95,94,93,92,91,90,89,88,87,87,86,85,84
|
||||
.db 83,82,82,81,80,79,78,78,77,76,75,75,74,73,72,72
|
||||
.db 71,70,69,69,68,67,67,66,65,65,64,64,63,62,62,61
|
||||
.db 60,60,59,59,58,57,57,56,56,55,55,54,54,53,53,52
|
||||
.db 51,51,50,50,49,49,48,48,48,47,47,46,46,45,45,44
|
||||
.db 44,43,43,43,42,42,41,40,40,39,39,38,38,37,37,36
|
||||
.db 35,35,34,34,33,33,32,31,31,30,30,29,29,28,28,27
|
||||
.db 26,26,25,25,24,24,23,22,22,21,21,20,20,19,19,18
|
||||
.db 17,17,16,16,15,15,14,13,13,12,12,11,11,10,10,9
|
||||
.db 8,8,7,7,6,6,5,4,4,3,3,2,2,1,1,0
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; Wave Table
|
||||
;--------------------------------------------------------------------;
|
||||
; 8bit, 32 ksps, 250 Hz fundamental frequency
|
||||
|
||||
.org 3072/2 ; Bottom stored
|
||||
|
||||
wt_attack: ; Attack area
|
||||
.db 0, 0, 0, 0, 0, 0, -1, -2, -2, -3, -2, -2, -1, 0, 0, 0
|
||||
.db 0, 0, -1, -2, -3, -3, -4, -4, -3, -2, -1, 0, 0, 1, 0, 0
|
||||
.db 0, -1, -2, -3, -3, -2, 0, 0, 2, 4, 5, 5, 5, 3, 1, 0
|
||||
.db -2, -3, -4, -3, -2, 0, 1, 2, 3, 2, 0, -2, -6, -11, -15, -18
|
||||
.db -19, -19, -16, -11, -5, 1, 8, 15, 20, 23, 24, 23, 20, 17, 13, 10
|
||||
.db 7, 6, 6, 8, 10, 13, 16, 18, 20, 20, 20, 19, 18, 18, 18, 18
|
||||
.db 19, 21, 24, 26, 27, 28, 27, 25, 22, 17, 11, 5, 0, -5, -9, -12
|
||||
.db -13, -13, -11, -9, -5, -1, 1, 4, 6, 6, 4, 0, -5, -12, -21, -30
|
||||
.db -39, -48, -56, -62, -66, -69, -70, -71, -70, -70, -70, -71, -72, -75, -77, -79
|
||||
.db -80, -78, -75, -69, -61, -50, -38, -26, -13, -2, 7, 15, 21, 25, 28, 30
|
||||
.db 33, 36, 40, 44, 49, 55, 59, 61, 62, 60, 56, 49, 42, 34, 27, 22
|
||||
.db 20, 21, 25, 33, 42, 52, 63, 72, 80, 86, 89, 90, 89, 87, 84, 81
|
||||
.db 79, 77, 75, 73, 72, 69, 66, 61, 55, 48, 39, 31, 22, 14, 6, 0
|
||||
.db -5, -10, -14, -17, -20, -22, -24, -26, -28, -29, -30, -31, -32, -33, -34, -35
|
||||
.db -36, -37, -39, -41, -44, -48, -52, -57, -63, -70, -77, -85, -94, -102, -110, -116
|
||||
.db -121, -124, -124, -121, -116, -109, -99, -89, -78, -68, -60, -53, -48, -45, -43, -43
|
||||
.db -43, -42, -41, -40, -37, -33, -29, -25, -22, -19, -17, -16, -15, -14, -12, -9
|
||||
.db -4, 2, 11, 22, 34, 46, 57, 67, 75, 81, 84, 86, 87, 86, 86, 85
|
||||
.db 85, 85, 86, 86, 87, 86, 84, 82, 78, 73, 69, 64, 60, 58, 56, 57
|
||||
.db 59, 62, 66, 70, 75, 79, 83, 86, 89, 91, 92, 92, 92, 90, 86, 81
|
||||
.db 73, 63, 52, 38, 24, 9, -5, -19, -31, -42, -50, -57, -61, -64, -66, -67
|
||||
.db -68, -68, -68, -67, -66, -64, -61, -56, -52, -46, -41, -36, -32, -29, -28, -28
|
||||
.db -30, -34, -39, -44, -50, -56, -62, -68, -74, -79, -84, -90, -95, -100, -104, -107
|
||||
.db -108, -108, -107, -103, -98, -92, -84, -76, -67, -58, -49, -40, -32, -24, -16, -8
|
||||
.db -1, 5, 11, 16, 20, 22, 22, 21, 18, 14, 10, 5, 1, -1, -3, -3
|
||||
.db -2, 0, 1, 5, 9, 12, 16, 20, 24, 28, 34, 40, 47, 55, 64, 72
|
||||
.db 81, 89, 96, 101, 105, 108, 108, 108, 107, 105, 103, 101, 100, 98, 96, 93
|
||||
.db 90, 87, 83, 79, 75, 70, 66, 62, 59, 56, 55, 53, 52, 51, 50, 48
|
||||
.db 46, 44, 42, 39, 37, 34, 31, 28, 24, 20, 15, 10, 3, -3, -12, -21
|
||||
.db -30, -39, -48, -57, -65, -72, -79, -85, -90, -95, -99, -103, -106, -109, -110, -112
|
||||
.db -112, -112, -111, -110, -109, -107, -106, -105, -104, -104, -103, -102, -101, -99, -97, -94
|
||||
.db -90, -86, -82, -78, -75, -72, -69, -67, -65, -63, -61, -58, -54, -50, -44, -38
|
||||
.db -31, -23, -16, -10, -4, 1, 6, 10, 14, 18, 23, 27, 32, 38, 43, 49
|
||||
.db 54, 59, 63, 67, 70, 73, 75, 77, 79, 81, 83, 85, 88, 91, 93, 96
|
||||
.db 99, 101, 103, 105, 107, 109, 110, 111, 112, 112, 112, 111, 109, 107, 104, 100
|
||||
.db 96, 92, 88, 83, 79, 75, 70, 65, 60, 55, 49, 43, 36, 30, 24, 18
|
||||
.db 12, 7, 3, 0, -3, -6, -8, -11, -14, -17, -20, -24, -28, -32, -37, -42
|
||||
.db -46, -51, -55, -59, -63, -67, -71, -75, -79, -82, -85, -88, -91, -93, -95, -97
|
||||
.db -98, -100, -101, -102, -103, -104, -104, -104, -103, -101, -99, -96, -93, -89, -86, -83
|
||||
.db -80, -78, -76, -75, -74, -73, -72, -71, -70, -68, -65, -63, -59, -56, -52, -48
|
||||
.db -44, -40, -35, -30, -24, -18, -11, -4, 3, 11, 19, 27, 34, 41, 48, 53
|
||||
.db 58, 63, 67, 71, 75, 79, 82, 86, 89, 92, 94, 95, 96, 97, 98, 98
|
||||
.db 99, 100, 101, 103, 105, 108, 110, 112, 114, 115, 115, 114, 113, 110, 107, 103
|
||||
.db 99, 95, 91, 87, 83, 79, 74, 70, 65, 59, 53, 47, 41, 35, 29, 24
|
||||
.db 19, 14, 11, 7, 4, 1, -1, -5, -9, -14, -19, -25, -31, -37, -43, -50
|
||||
.db -56, -62, -68, -73, -78, -83, -88, -92, -97, -101, -105, -109, -112, -115, -117, -119
|
||||
.db -120, -121, -120, -119, -118, -116, -114, -112, -109, -106, -104, -101, -99, -96, -94, -91
|
||||
.db -88, -85, -81, -78, -74, -70, -66, -62, -57, -53, -49, -45, -41, -37, -32, -27
|
||||
.db -22, -16, -10, -4, 1, 8, 14, 20, 25, 31, 36, 41, 46, 50, 55, 60
|
||||
.db 64, 69, 73, 77, 81, 85, 88, 90, 93, 95, 97, 99, 101, 103, 106, 109
|
||||
.db 112, 115, 118, 121, 123, 125, 126, 126, 125, 125, 123, 121, 119, 117, 115, 112
|
||||
.db 110, 107, 103, 99, 94, 89, 83, 76, 69, 62, 54, 47, 39, 31, 24, 16
|
||||
.db 9, 2, -4, -11, -18, -25, -31, -38, -44, -51, -57, -62, -68, -73, -79, -84
|
||||
.db -88, -93, -97, -102, -106, -109, -113, -116, -119, -121, -123, -124, -125, -126, -127, -127
|
||||
.db -127, -127, -126, -125, -125, -123, -122, -120, -118, -116, -114, -111, -107, -104, -100, -95
|
||||
.db -91, -86, -80, -75, -69, -63, -58, -52, -46, -40, -34, -28, -22, -16, -10, -4
|
||||
|
||||
wt_loop: ; Sustain area
|
||||
.db 0, 5, 11, 17, 23, 28, 34, 39, 45, 50, 55, 60, 65, 69, 74, 78
|
||||
.db 82, 85, 89, 92, 95, 98, 100, 102, 104, 106, 107, 109, 109, 110, 110, 111
|
||||
.db 110, 110, 109, 108, 107, 106, 104, 102, 100, 98, 95, 93, 90, 87, 83, 80
|
||||
.db 76, 72, 68, 64, 59, 55, 50, 46, 41, 36, 31, 26, 21, 15, 10, 5
|
||||
.db 0, -5, -10, -15, -21, -26, -31, -36, -41, -46, -50, -55, -59, -64, -68, -72
|
||||
.db -76, -80, -83, -87, -90, -93, -95, -98, -100, -102, -104, -106, -107, -108, -109, -110
|
||||
.db -110, -111, -110, -110, -109, -109, -107, -106, -104, -102, -100, -98, -95, -92, -89, -85
|
||||
.db -82, -78, -74, -69, -65, -60, -55, -50, -45, -39, -34, -28, -23, -17, -11, -5
|
||||
wt_end:
|
||||
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
:020000020000FC
|
||||
:100000000AC0FECFFDCFFCCFFBCFFACFF9CFF8CFA0
|
||||
:10001000F7CFF6CF73C0FF24A0E6B0E000E0FD927A
|
||||
:100020000A95E9F70DE008BB02E107BB06E007BD52
|
||||
:1000300001E600BF00E60CBD0EE309BD02E00ABD0B
|
||||
:1000400002E003BF00E109BFEEEBF1E0F894882481
|
||||
:100050009924772478942591359131D0F89482169B
|
||||
:1000600093067894D0F345914F3F71F3042F03D05A
|
||||
:100070004078C9F3F0CFFF93EF93E02FEE0FFF2707
|
||||
:10008000EC56F94F05911591C0916000C75FC633DA
|
||||
:1000900008F0CC27C0936000DD27CF59DF4F20E068
|
||||
:1000A0003CE0F894198308833C832B8378940FEF0A
|
||||
:1000B0000D830E83FF82F886EF91FF910895FF93E1
|
||||
:1000C000EF93C1E6D0E00E811FEF011789F01E8388
|
||||
:1000D0000F8103950C3008F000E00F8348F0E885AD
|
||||
:1000E000E39531F0E887FF27EC5FF84F04910D832B
|
||||
:1000F0002996C73941F7EF91FF910895EFB66F0147
|
||||
:100100005E01C1E6D0E0222433249A81EB81FC8198
|
||||
:10011000849148805980940DE51DFF1DF03118F041
|
||||
:10012000E058F040FE829A83FC83EB839D81182E79
|
||||
:1001300087FD8195002490FD080E069491FD080E20
|
||||
:10014000069492FD080E069493FD080E002494FD7B
|
||||
:10015000080E069495FD080E069496FD080E06946A
|
||||
:1001600097FD080E110C1F2C10F401941108200C9F
|
||||
:10017000311C2996C73949F635942794359427942C
|
||||
:100180008DEF90E0281639060CF01C0181E09FEFFE
|
||||
:10019000281639060CF41C01359427943794822DC7
|
||||
:1001A0008058982F909537FC83958EBD9BBD089401
|
||||
:1001B0007F1C8F1C9F1CF601E501EFBE189578008F
|
||||
:1001C000AB9600AAB400ABD200AAF000AB0E01A619
|
||||
:1001D0002C01A94A01A76801248C860193A40198E7
|
||||
:1001E000C2019BE0019FFE01A41C0226873A0293F4
|
||||
:1001F00058029776029F9402A3B202A6D002278CDF
|
||||
:10020000EE02930C03982A039F4803AB6603AA846B
|
||||
:1002100003ABA203AAC003ABDE03A6FC03A91A0426
|
||||
:10022000A73804248C56049374049892049BB00459
|
||||
:100230009FCE04A4EC0426870A059328059746055B
|
||||
:100240009F6405A78205A6A005248CBE0593DC0546
|
||||
:10025000981806AB3606AA5406AB7206AA9006ABEF
|
||||
:10026000AE06A6CC06A9EA06A70807248C260793A3
|
||||
:1002700044079862079B80079F9E07A4BC072687B8
|
||||
:10028000DA0793F8079716089F3408A35208A67058
|
||||
:1002900008278C8E0893AC0898CA089FE808AB061C
|
||||
:1002A00009AA2409AB4209AA6009AB7E09A69C09E8
|
||||
:1002B000A9BA09A7D809248CF60993140A98320A16
|
||||
:1002C0009B500A9F6E0AA48C0A2687AA0A93C80A22
|
||||
:1002D00097E60A9F040BA7220BA6400B248C5E0B0B
|
||||
:1002E000937C0B989A0BA6B80BA7D60BA9F40B2BF3
|
||||
:1002F0008F120C96300C9B4E0CA26C0CAC8A0CAB83
|
||||
:10030000A80C298AC60C96E40C98020DA0200DAB0F
|
||||
:100310003E0DA95C0D278C7A0D93980D98B60D9F14
|
||||
:10032000D40DA9F20DA7100E26872E0E934C0E9F0A
|
||||
:100330006A0E9F880EABA60E9FC40EABE20EAB00FA
|
||||
:100340000FB71E0FAA3C0FAB5A0FAA780FAB960F30
|
||||
:10035000AAB40FABD20FAAF00FAB0E10AA2C10ABA1
|
||||
:100360004A10AA6810AB8610A6A410A9C210A7E074
|
||||
:1003700010248CFE10931C11983A119B58119F76F3
|
||||
:1003800011A494112687B21193D01197EE119F0CEE
|
||||
:1003900012A32A12A64812278C661293841298A2DE
|
||||
:1003A000129FC012ABDE12AAFC12AB1A13AA3813AA
|
||||
:1003B000AB5613A67413A99213A7B013248CCE13B3
|
||||
:1003C00093EC13980A149B28149F4614A4641426D3
|
||||
:1003D00087821493A01497BE149FDC14A7FA14A666
|
||||
:1003E0001815248C3615935415987215A69015A7D8
|
||||
:1003F000AE15A9CC152B8FEA159608169B2616A2CA
|
||||
:100400004416AC6216AB8016298A9E1696BC1698C6
|
||||
:10041000DA16A0F816AB1617A93417278C521793C3
|
||||
:100420007017988E179FAC17A9CA17A7E8172687C9
|
||||
:1004300006189324189F42189F6018AB7E189F9C43
|
||||
:1004400018ABBA18ABD818B7F618AA1419AB3219EA
|
||||
:10045000AA5019AB6E19AA8C19ABAA19AAC819AB64
|
||||
:10046000E619AA041AAB221AAA401AAB5E1AA67C95
|
||||
:100470001AA99A1AA7B81A248CD61A93F41A9812A1
|
||||
:100480001B9B301B9F4E1BA46C1B26878A1B93A8AB
|
||||
:100490001B97C61B9FE41BA3021CA6201C278C3E97
|
||||
:1004A0001C935C1C987A1C9F981CABB61CAAD41C8D
|
||||
:1004B000ABF21CAA101DAB2E1DA64C1DA96A1DA7D0
|
||||
:1004C000881D248CA61D93C41D98E21D9B001E9FB1
|
||||
:1004D0001E1EA43C1E26875A1E93781E97961E9FAA
|
||||
:1004E000B41EA7D21EA6F01E248C0E1F932C1F989C
|
||||
:1004F0004A1F271F1B99681F27201B98861F27222A
|
||||
:100500001F1996A41F2794C21F98E01F9BFE1F98D7
|
||||
:100510001C202C9B3A20984920AB58202B94762005
|
||||
:100520009994209DB22099D020319DEE2099FD20F4
|
||||
:10053000B00C2130942A212E9F48212C1916946644
|
||||
:10054000212B9F842129191694A221279FC02125A0
|
||||
:1005500094DE2198FC21249B1A22983822249B4760
|
||||
:1005600022A2562224986522A574222794922298CA
|
||||
:10057000B0229BCE2298EC22299B0A232A9828237A
|
||||
:100580002B9346239864239B82232B98A0232C1D16
|
||||
:1005900091BE232494DC232796FA239F18249636B1
|
||||
:1005A000249F542429967224A28124A69024291FD2
|
||||
:1005B0009B9F24AEAE24A2BD24AECC24A4DB24AEEB
|
||||
:1005C000EA242622A0F924AE082527229F1725AE6B
|
||||
:1005D00026252922209D3525AE44252B221F9B53FD
|
||||
:1005E00025AE6225B37125B280253018948F25AED3
|
||||
:1005F0009E25ACAD25ABBC25291A96CB25AEDA25B8
|
||||
:10060000ACE925A9F825291F9B0726AE1626A225A9
|
||||
:1006100026AE3426A44326AE52262622A06126AE5C
|
||||
:10062000702627229F7F26AE8E262922209D9D267A
|
||||
:10063000AEAC262B221F9BBB26AECA26B3D926B250
|
||||
:10064000E826301894F726AE0627AC1527AB2427EA
|
||||
:10065000291A963327AE4227AC5127A960272B18B9
|
||||
:10066000976F27AC7E27AB8D27AA9C27ABAB27A61D
|
||||
:10067000BA27ABC927AAD827ABE727A6F627AB0529
|
||||
:1006800028AA1428AB6E28A68C28ABAA28AAC828AA
|
||||
:10069000AB302AFFE100EF00FD000C011C012D0131
|
||||
:1006A0003F01520166017B019101A901C301DD01F6
|
||||
:1006B000FA011802380259027D02A302CB02F602A7
|
||||
:1006C000230353038503BB03F30330046F04B30414
|
||||
:1006D000FA0446059605EB054606A5060A077507C2
|
||||
:1006E000E7075F08DF086609F5098C0A2D0BD70BB1
|
||||
:1006F0008B0C4A0D140EEA0ECE0FBE10BE11CC129A
|
||||
:10070000EA131815FFFCFAF7F5F3F0EEEBE9E7E46E
|
||||
:10071000E2E0DEDBD9D7D5D3D1CFCDCBC9C7C5C3B6
|
||||
:10072000C1BFBDBBB9B7B6B4B2B0AEADABA9A8A698
|
||||
:10073000A4A3A19F9E9C9B999896959392908F8D30
|
||||
:100740008C8B89888685848281807F7D7C7B7A788A
|
||||
:10075000777675747371706F6E6D6C6B6A696867AC
|
||||
:10076000666564636261605F5E5D5C5B5A595857A1
|
||||
:100770005756555453525251504F4E4E4D4C4B4B71
|
||||
:100780004A49484847464545444343424141404021
|
||||
:100790003F3E3E3D3C3C3B3B3A39393838373736B3
|
||||
:1007A000363535343333323231313030302F2F2E2D
|
||||
:1007B0002E2D2D2C2C2B2B2B2A2A29282827272697
|
||||
:1007C00026252524232322222121201F1F1E1E1D12
|
||||
:1007D0001D1C1C1B1A1A1919181817161615151492
|
||||
:1007E00014131312111110100F0F0E0D0D0C0C0B12
|
||||
:1007F0000B0A0A0908080707060605040403030292
|
||||
:0408000002010100F0
|
||||
:100C0000000000000000FFFEFEFDFEFEFF000000F1
|
||||
:100C10000000FFFEFDFDFCFCFDFEFF0000010000EA
|
||||
:100C200000FFFEFDFDFE00000204050505030100B6
|
||||
:100C3000FEFDFCFDFE000102030200FEFAF5F1EEEE
|
||||
:100C4000EDEDF0F5FB01080F1417181714110D0A3C
|
||||
:100C5000070606080A0D10121414141312121212A9
|
||||
:100C60001315181A1B1C1B1916110B0500FBF7F4A2
|
||||
:100C7000F3F3F5F7FBFF010406060400FBF4EBE2D7
|
||||
:100C8000D9D0C8C2BEBBBAB9BABABAB9B8B5B3B18D
|
||||
:100C9000B0B2B5BBC3CEDAE6F3FE070F15191C1EC2
|
||||
:100CA0002124282C31373B3D3E3C38312A221B166B
|
||||
:100CB000141519212A343F485056595A595754513E
|
||||
:100CC0004F4D4B494845423D3730271F160E060011
|
||||
:100CD000FBF6F2EFECEAE8E6E4E3E2E1E0DFDEDD9A
|
||||
:100CE000DCDBD9D7D4D0CCC7C1BAB3ABA29A928C33
|
||||
:100CF000878484878C939DA7B2BCC4CBD0D3D5D531
|
||||
:100D0000D5D6D7D8DBDFE3E7EAEDEFF0F1F2F4F781
|
||||
:100D1000FC020B16222E39434B515456575656554A
|
||||
:100D200055555656575654524E4945403C3A383917
|
||||
:100D30003B3E42464B4F5356595B5C5C5C5A5651A6
|
||||
:100D4000493F34261809FBEDE1D6CEC7C3C0BEBD6E
|
||||
:100D5000BCBCBCBDBEC0C3C8CCD2D7DCE0E3E4E4BD
|
||||
:100D6000E2DED9D4CEC8C2BCB6B1ACA6A19C9895DF
|
||||
:100D7000949495999EA4ACB4BDC6CFD8E0E8F0F8A1
|
||||
:100D8000FF050B1014161615120E0A0501FFFDFDC6
|
||||
:100D9000FE000105090C1014181C22282F374048AA
|
||||
:100DA00051596065696C6C6C6B6967656462605D04
|
||||
:100DB0005A57534F4B46423E3B3837353433323027
|
||||
:100DC0002E2C2A2725221F1C18140F0A03FDF4EBD2
|
||||
:100DD000E2D9D0C7BFB8B1ABA6A19D999693929026
|
||||
:100DE00090909192939596979898999A9B9D9FA28F
|
||||
:100DF000A6AAAEB2B5B8BBBDBFC1C3C6CACED4DA0F
|
||||
:100E0000E1E9F0F6FC01060A0E12171B20262B3131
|
||||
:100E1000363B3F4346494B4D4F515355585B5D6000
|
||||
:100E2000636567696B6D6E6F7070706F6D6B686412
|
||||
:100E3000605C58534F4B46413C37312B241E1812EF
|
||||
:100E40000C070300FDFAF8F5F2EFECE8E4E0DBD67E
|
||||
:100E5000D2CDC9C5C1BDB9B5B1AEABA8A5A3A19F3F
|
||||
:100E60009E9C9B9A99989898999B9DA0A3A7AAADA0
|
||||
:100E7000B0B2B4B5B6B7B8B9BABCBFC1C5C8CCD0AA
|
||||
:100E8000D4D8DDE2E8EEF5FC030B131B2229303544
|
||||
:100E90003A3F43474B4F5256595C5E5F6061626216
|
||||
:100EA00063646567696C6E7072737372716E6B6781
|
||||
:100EB000635F5B57534F4A46413B352F29231D182B
|
||||
:100EC000130E0B070401FFFBF7F2EDE7E1DBD5CED4
|
||||
:100ED000C8C2BCB7B2ADA8A49F9B9793908D8B89D5
|
||||
:100EE000888788898A8C8E909396989B9DA0A2A5CE
|
||||
:100EF000A8ABAFB2B6BABEC2C7CBCFD3D7DBE0E5A3
|
||||
:100F0000EAF0F6FC01080E14191F24292E32373C92
|
||||
:100F10004045494D5155585A5D5F616365676A6D3B
|
||||
:100F2000707376797B7D7E7E7D7D7B79777573703E
|
||||
:100F30006E6B67635E59534C453E362F271F181062
|
||||
:100F40000902FCF5EEE7E1DAD4CDC7C2BCB7B1AC1B
|
||||
:100F5000A8A39F9A96938F8C8987858483828181A9
|
||||
:100F600081818283838586888A8C8E9195989CA1C5
|
||||
:100F7000A5AAB0B5BBC1C6CCD2D8DEE4EAF0F6FC77
|
||||
:100F800000050B11171C22272D32373C41454A4ED4
|
||||
:100F90005255595C5F626466686A6B6D6D6E6E6F08
|
||||
:100FA0006E6E6D6C6B6A686664625F5D5A57535013
|
||||
:100FB0004C4844403B37322E29241F1A150F0A058E
|
||||
:100FC00000FBF6F1EBE6E1DCD7D2CEC9C5C0BCB878
|
||||
:100FD000B4B0ADA9A6A3A19E9C9A9896959493921D
|
||||
:100FE0009291929293939596989A9C9EA1A4A7AB66
|
||||
:100FF000AEB2B6BBBFC4C9CED3D9DEE4E9EFF5FBD0
|
||||
:00000001FF
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
;----------------------------------------------------------;
|
||||
; Melody Generator Include File
|
||||
|
||||
|
||||
.equ A2 = 0 ;220Hz
|
||||
.equ B2 = 1
|
||||
.equ H2 = 2
|
||||
.equ C2 = 3
|
||||
.equ Cis2 = 4
|
||||
.equ D2 = 5
|
||||
.equ Dis2 = 6
|
||||
.equ E2 = 7
|
||||
.equ F2 = 8
|
||||
.equ Fis2 = 9
|
||||
.equ G2 = 10
|
||||
.equ Gis2 = 11
|
||||
.equ A3 = 12 ;440Hz
|
||||
.equ B3 = 13
|
||||
.equ H3 = 14
|
||||
.equ C3 = 15
|
||||
.equ Cis3 = 16
|
||||
.equ D3 = 17
|
||||
.equ Dis3 = 18
|
||||
.equ E3 = 19
|
||||
.equ F3 = 20
|
||||
.equ Fis3 = 21
|
||||
.equ G3 = 22
|
||||
.equ Gis3 = 23
|
||||
.equ A4 = 24 ;880Hz
|
||||
.equ B4 = 25
|
||||
.equ H4 = 26
|
||||
.equ C4 = 27
|
||||
.equ Cis4 = 28
|
||||
.equ D4 = 29
|
||||
.equ Dis4 = 30
|
||||
.equ E4 = 31
|
||||
.equ F4 = 32
|
||||
.equ Fis4 = 33
|
||||
.equ G4 = 34
|
||||
.equ Gis4 = 35
|
||||
.equ A5 = 36 ;1760Hz
|
||||
.equ B5 = 37
|
||||
.equ H5 = 38
|
||||
.equ C5 = 39
|
||||
.equ Cis5 = 40
|
||||
.equ D5 = 41
|
||||
.equ Dis5 = 42
|
||||
.equ E5 = 43
|
||||
.equ F5 = 44
|
||||
.equ Fis5 = 45
|
||||
.equ G5 = 46
|
||||
.equ Gis5 = 47
|
||||
.equ A6 = 48 ;3520Hz
|
||||
.equ B6 = 49
|
||||
.equ H6 = 50
|
||||
.equ C6 = 51
|
||||
.equ Cis6 = 52
|
||||
.equ D6 = 53
|
||||
.equ Dis6 = 54
|
||||
.equ E6 = 55
|
||||
|
||||
.equ EoS = 255 ;End of score
|
||||
.equ en = 128 ;End of line flag
|
||||
|
||||
|
||||
;--------------------------------------------------------------------;
|
||||
; T0 = int8(EL) x .uint8(EH), 32clks
|
||||
|
||||
.macro MULT
|
||||
mov T0H, EL
|
||||
sbrc EL, 7
|
||||
neg EL
|
||||
|
||||
clr T0L
|
||||
sbrc EH, 0
|
||||
add T0L, EL
|
||||
lsr T0L
|
||||
sbrc EH, 1
|
||||
add T0L, EL
|
||||
lsr T0L
|
||||
sbrc EH, 2
|
||||
add T0L, EL
|
||||
lsr T0L
|
||||
sbrc EH, 3
|
||||
add T0L, EL
|
||||
clr T0L
|
||||
sbrc EH, 4
|
||||
add T0L, EL
|
||||
lsr T0L
|
||||
sbrc EH, 5
|
||||
add T0L, EL
|
||||
lsr T0L
|
||||
sbrc EH, 6
|
||||
add T0L, EL
|
||||
lsr T0L
|
||||
sbrc EH, 7
|
||||
add T0L, EL
|
||||
|
||||
lsl T0H
|
||||
mov T0H, _0
|
||||
brcc PC+3
|
||||
neg T0L
|
||||
sbc T0H, T0H
|
||||
.endm
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="Windows-1252" ?>
|
||||
<TKStudioOptions Version="3.00" Author="YinHandong[Òüº®¶¬]">
|
||||
<Projects OPTPES="96,0,0,0,2,0,0,">
|
||||
<Project ProjectGUID="{B5E5CA21-3769-4e16-8D6B-2558BD6CC37A}" Name="mg" ACTCFG="DebugRel">
|
||||
<TARGOPT Name="DebugRel" OPTDF="0">
|
||||
<OPTFFF VAL="<.\mg.asm> {0,1,-1,-1,234,234,804,863,215,3062}" />
|
||||
<OPTFFF VAL="<.\mg.inc> {0,1,-1,-1,208,208,752,834,37,0}" />
|
||||
<OPTFFF VAL="<.\melody.asm> {0,1,-1,-1,260,260,830,889,12,6700}" />
|
||||
<OPTFFF VAL="<.\avr.inc> {2,3,-1,-1,286,286,856,915,0,0}" />
|
||||
</TARGOPT>
|
||||
</Project>
|
||||
</Projects>
|
||||
</TKStudioOptions>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="Windows-1252" ?>
|
||||
<TKStudioProject Name="mg" ProjectGUID="{B5E5CA21-3769-4e16-8D6B-2558BD6CC37A}" BuildTool="8" ToolVer="" Version="3.00" Author="YinHandong[Òüº®¶¬]">
|
||||
<Configurations>
|
||||
<Configuration Name="DebugRel" F_CPU="0" XROM="0,0,0,0#0,0,0,0#0,0,0,0" XRAM="0,0,0,0#0,0,0,0#0,0,0,0" OldName="DebugRel" CLK="20.000000" IROM="1,0x00000000,0x00004000,1#0,0,0,0" IRAM="1,0x00000000,0x00000400,0#0,0,0,0" OldCPU="ATmega168" OPTDBG="1,-1,1,1,1,0,()" DEVICE="ATmega168" VENDOR="Atmel" FAMINY="8" SIMCLK="20.000000">
|
||||
<AVR_Output OutName="0,.\DebugRel\mg" OutType="1" OutMK="0" OutHex="0" OutList="0,.\DebugRel" Debug="1" />
|
||||
<AVR_User BfC="0,<>#0,<>" BfB="0,<>#0,<>" AfB="0,<>#0,<>" Beep="1" SDebug="0" />
|
||||
<AVR_CParam Def="" uDef="" Inc="" Misc="" Opt="0" Code="4" Language="0,0,0,0,0,0" List="0" />
|
||||
<AVR_AsmParam Def="" uDef="" Inc="" Misc="" Code="0,0,0,2" Language="0" List="1" />
|
||||
<AVR_Linker Misc="" UseDef="1" Code="0,0" Sct="" List="1,1" Lib="0,0,0,0,0,0" />
|
||||
<AVR_Debug DbgType="0" sfSIM="1,1,<>,<>" hwSIM="1,1,1,<>" Drv="(),<>" SrvOpt="" />
|
||||
<DeviceProperties Item0="CPU=IRAM(0-0x3FF) IROM(0-0x3FFF) CLOCK(20000000) CPUTYPE(AVR 8-RISC) INFO(311)" Item1='MON=SAVR.DLL("-pATmega168")' Item2='SIM=SAVR.DLL("-pATmega168")' />
|
||||
<DeviceDescription Description="High Performance, Low Power AVR? 8-Bit Microcontroller
Advanced RISC Architecture
¨C 131 Powerful Instructions 
¨C 32 x 8 General Purpose Working Registers
¨C Fully Static Operation
¨C Up to 20 MIPS Throughput at 20 MHz
¨C On-chip 2-cycle Multiplier
High Endurance Non-volatile Memory segments
¨C 16K Bytes of In-System Self-programmable Flash program memory
¨C 512 Bytes EEPROM
¨C 1K Bytes Internal SRAM
¨C Write/Erase cyles: 10,000 Flash/100,000 EEPROM
I/O and Packages
¨C 23 Programmable I/O Lines
¨C 28-pin PDIP, 32-lead TQFP, 28-pad QFN/MLF and 32-pad QFN/MLF" />
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<Filter Name="Source Files" />
|
||||
<File RelativePath="AVR.INC" FileType="5" />
|
||||
<File RelativePath="melody.asm" FileType="2" Output="melody.o" />
|
||||
<File RelativePath="mg.asm" FileType="2" Output="mg.o" />
|
||||
<File RelativePath="mg.inc" FileType="5" />
|
||||
<Filter Name="DebugRel" />
|
||||
</Files>
|
||||
</TKStudioProject>
|
||||
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
# waveform to ASM converter
|
||||
|
||||
if(!open(RHA, "p1.wav")) # source file
|
||||
{ die "File could not opend." }
|
||||
binmode RHA;
|
||||
|
||||
read(RHA, $sign, 4);
|
||||
if($sign ne "RIFF") { die "Not wav file"; }
|
||||
read(RHA, $dmy, 4);
|
||||
read(RHA, $sign, 4);
|
||||
if($sign ne "WAVE") { die "Not wav file"; }
|
||||
|
||||
read(RHA, $sign, 4);
|
||||
if($sign ne "fmt ") { die "Not fmt"; }
|
||||
read(RHA, $siz, 4);
|
||||
$lfmt = unpack('L4', $siz);
|
||||
if($lfmt > 100) { die "Invalid format"; }
|
||||
read(RHA, $cfmt, $lfmt);
|
||||
$id = unpack('S2', substr($cfmt, 0, 2));
|
||||
$nchan = unpack('S2', substr($cfmt, 2, 2));
|
||||
$nsamp = unpack('L4', substr($cfmt, 4, 4));
|
||||
$nrate = unpack('L4', substr($cfmt, 8, 4));
|
||||
$nblk = unpack('S2', substr($cfmt, 12, 2));
|
||||
$nbit = unpack('S2', substr($cfmt, 14, 2));
|
||||
print "id = $id\n";
|
||||
print "channels = $nchan ch\n";
|
||||
print "sampling freq = $nsamp Hz\n";
|
||||
print "data rate = $nrate bytes/sec\n";
|
||||
print "block size = $nblk bytes\n";
|
||||
print "bit/sample = $nbit bit\n";
|
||||
|
||||
if($id != 1) { die "Invalid format (not LPCM)"; } # linear?
|
||||
if($nchan != 1) { die "Invalid format (not Mono)"; } # mono?
|
||||
if($nbit != 16) { die "Invalid format (not 16bit)"; } # 16bit?
|
||||
|
||||
read(RHA, $sign, 4);
|
||||
if($sign ne "data") { die "No data"; }
|
||||
read(RHA, $siz, 4);
|
||||
$ldata = unpack('L4', $siz) / 2;
|
||||
print "samples = $ldata\n";
|
||||
|
||||
$c = 0;
|
||||
while ($ldata--) {
|
||||
read(RHA, $bdat, 2);
|
||||
$val = int(unpack('s2', $bdat) / 256);
|
||||
if($c == 0) {
|
||||
print "\n\t.db $val";
|
||||
} else {
|
||||
print ", $val";
|
||||
}
|
||||
$c = ($c+1) & 15;
|
||||
}
|
||||
print "\n";
|
||||
|
||||
close RHA;
|
||||
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user