diff --git a/demos/lovebyte2023/loveduck_512/speaker_beeps.s b/demos/lovebyte2023/loveduck_512/speaker_beeps.s index 5fb8ba01..de538116 100644 --- a/demos/lovebyte2023/loveduck_512/speaker_beeps.s +++ b/demos/lovebyte2023/loveduck_512/speaker_beeps.s @@ -1,3 +1,6 @@ +; note this is Paul Lutus' red book code +; see music/redbook_sound for more details + ; based on code from here ; http://eightbitsoundandfury.ld8.org/programming.html diff --git a/games/duke/speaker_tone.s b/games/duke/speaker_tone.s index 069cf498..3b53f239 100644 --- a/games/duke/speaker_tone.s +++ b/games/duke/speaker_tone.s @@ -1,3 +1,7 @@ + +; this code is obsolete +; grab music/redbook_sound instead + ; based on code from here ; http://eightbitsoundandfury.ld8.org/programming.html diff --git a/games/mist/TODO b/games/mist/TODO index e6ae022b..6441c439 100644 --- a/games/mist/TODO +++ b/games/mist/TODO @@ -1,3 +1,8 @@ +FIXME: ++ use zx02 compression ++ use updated/proper audio in the speaker_beeps.s (from music/redbook_sound) + + KNOWN BUGS + The bounding box for the button in the fireplace should probably be at least two pixels higher, it's hard to hit diff --git a/games/mist/speaker_beeps.s b/games/mist/speaker_beeps.s index 069cf498..00ebbc0e 100644 --- a/games/mist/speaker_beeps.s +++ b/games/mist/speaker_beeps.s @@ -1,3 +1,6 @@ +; FIXME: replace with updated version from music/redbook_sound +; the notes here aren't exactly right + ; based on code from here ; http://eightbitsoundandfury.ld8.org/programming.html diff --git a/games/mist_hgr/TODO b/games/mist_hgr/TODO index a3361fb8..8ca9a3eb 100644 --- a/games/mist_hgr/TODO +++ b/games/mist_hgr/TODO @@ -15,3 +15,4 @@ sprite movie playing mockingboard on IIc +update speaker_tone diff --git a/games/mist_hgr/speaker_beeps.s b/games/mist_hgr/speaker_beeps.s new file mode 100644 index 00000000..2bf75ff7 --- /dev/null +++ b/games/mist_hgr/speaker_beeps.s @@ -0,0 +1,72 @@ +; OBSOLETE + +; use music/redbook_sound + + +; based on code from here +; http://eightbitsoundandfury.ld8.org/programming.html + +; A,X,Y trashed +; duration also trashed + +NOTE_C3 = 255 +NOTE_CSHARP3 = 241 +NOTE_D3 = 227 +NOTE_DSHARP3 = 214 +NOTE_E3 = 202 +NOTE_F3 = 191 +NOTE_FSHARP3 = 180 +NOTE_G3 = 170 +NOTE_GSHARP3 = 161 +NOTE_A3 = 152 +NOTE_ASHARP3 = 143 +NOTE_B3 = 135 + +NOTE_C4 = 128 +NOTE_CSHARP4 = 121 +NOTE_D4 = 114 +NOTE_DSHARP4 = 108 +NOTE_E4 = 102 +NOTE_F4 = 96 +NOTE_FSHARP4 = 91 +NOTE_G4 = 85 +NOTE_GSHARP4 = 81 +NOTE_A4 = 76 +NOTE_ASHARP4 = 72 +NOTE_B4 = 68 + +NOTE_C5 = 64 +NOTE_CSHARP5 = 60 +NOTE_D5 = 57 +NOTE_DSHARP5 = 54 +NOTE_E5 = 51 +NOTE_F5 = 48 +NOTE_FSHARP5 = 45 +NOTE_G5 = 43 +NOTE_GSHARP5 = 40 +NOTE_A5 = 38 +NOTE_ASHARP5 = 36 +NOTE_B5 = 34 + + + +speaker_tone: + lda $C030 ; click speaker +speaker_loop: + dey ; y never set? + bne slabel1 ; duration roughly 256*? + dec speaker_duration ; (Duration) + beq done_tone +slabel1: + dex + bne speaker_loop + ldx speaker_frequency ; (Frequency) + jmp speaker_tone +done_tone: + rts + +speaker_duration: + .byte $00 +speaker_frequency: + .byte $00 + diff --git a/games/peasant/TODO b/games/peasant/TODO index 17215acd..e5b17520 100644 --- a/games/peasant/TODO +++ b/games/peasant/TODO @@ -1,3 +1,8 @@ +New: +~~~~ +use updated speaker_beeps.s from music/redbook_sound + + QUESTIONS FOR VIDELECTRIX: ~~~~~~~~~~~~~~~~~~~~~~~~~~ + What are the odds of Kerrek appearing each time you enter? diff --git a/games/peasant/speaker_beeps.s b/games/peasant/speaker_beeps.s index 6df0a043..3c3839b6 100644 --- a/games/peasant/speaker_beeps.s +++ b/games/peasant/speaker_beeps.s @@ -1,3 +1,7 @@ +; the sound here is not quite right, use +; music/redbook_audio instead + + ; based on code from here ; http://eightbitsoundandfury.ld8.org/programming.html diff --git a/games/tfv/TODO b/games/tfv/TODO index 54ac71e7..dec88e01 100644 --- a/games/tfv/TODO +++ b/games/tfv/TODO @@ -1,3 +1,5 @@ ++ update speaker_tone.s + short-term: + Finish mockingboard music (victory and battle) + Get battle finished diff --git a/games/tfv/speaker_tone.s b/games/tfv/speaker_tone.s index 069cf498..ca41bf2b 100644 --- a/games/tfv/speaker_tone.s +++ b/games/tfv/speaker_tone.s @@ -1,3 +1,7 @@ +; FIXME: obsolete +; use music/redbook_sound instead + + ; based on code from here ; http://eightbitsoundandfury.ld8.org/programming.html diff --git a/graphics/gr/boxes/rr.s b/graphics/gr/boxes/rr.s index 565c6552..43e7b4a8 100644 --- a/graphics/gr/boxes/rr.s +++ b/graphics/gr/boxes/rr.s @@ -156,6 +156,7 @@ all_good: ; inx ; txa +; old ;NOTE_A3 = $98 ; 152 ;NOTE_B3 = $87 ; 135 @@ -164,6 +165,16 @@ all_good: ;NOTE_E4 = $66 ; 102 ;NOTE_FSHARP4 = $5B ; 91 +; new + +;NOTE_A3 = 223 +;NOTE_B3 = 199 +;NOTE_CSHARP4 = 177 +;NOTE_D4 = 167 +;NOTE_E4 = 149 +;NOTE_FSHARP4 = 132 + + NOTE_A3 = 0 NOTE_B3 = 1 NOTE_CSHARP4 = 2 @@ -174,13 +185,13 @@ NOTE_FSHARP4 = 5 -; based on code from here -; http://eightbitsoundandfury.ld8.org/programming.html +; this is Paul Lutus's code from Apple II red book ; X,Y trashed ; duration also trashed - speaker_tone: + ldy #0 +speaker_tone_loop: bit $C030 ; click speaker speaker_loop: dey ; y never set? @@ -191,7 +202,7 @@ slabel1: dex bne speaker_loop ldx speaker_frequency ; (Frequency) - jmp speaker_tone + jmp speaker_tone_loop done_tone: beq play_music_loop @@ -289,7 +300,9 @@ box_data: .byte $FF -note_freqs: .byte $98,$87,$79,$72,$66,$5B +;note_freqs: .byte $98,$87,$79,$72,$66,$5B + +note_freqs: .byte 223,199,177,167,149,132 speaker_frequency: speaker_duration = speaker_frequency+1 diff --git a/music/redbook_sound/Makefile b/music/redbook_sound/Makefile new file mode 100644 index 00000000..957d115f --- /dev/null +++ b/music/redbook_sound/Makefile @@ -0,0 +1,30 @@ +include ../../Makefile.inc + +DOS33 = ../../utils/dos33fs-utils/dos33 +TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft + +all: generate_frequencies + +#still_alive.dsk: SA_COMPRESSED STILL_ALIVE TITLE.BAS ENDING +# $(DOS33) -y still_alive.dsk BSAVE -a 0x5900 SA_COMPRESSED +# $(DOS33) -y still_alive.dsk BSAVE -a 0x0800 STILL_ALIVE +# $(DOS33) -y still_alive.dsk BSAVE -a 0x1800 ENDING +# $(DOS33) -y still_alive.dsk SAVE A TITLE.BAS + +STILL_ALIVE: still_alive.o + ld65 -o STILL_ALIVE still_alive.o -C ../../linker_scripts/apple2_800.inc + + +### + +generate_frequencies: generate_frequencies.o + $(CC) -o generate_frequencies generate_frequencies.o -lm + +generate_frequencies.o: + $(CC) $(CFLAGS) -c generate_frequencies.c + +### + +clean: + rm -f *~ *.o generate_frequencies + diff --git a/music/redbook_sound/README b/music/redbook_sound/README new file mode 100644 index 00000000..acd601ac --- /dev/null +++ b/music/redbook_sound/README @@ -0,0 +1,38 @@ +this code was widely shared for playing tones on Apple II + by POKEing the machine language and CALLing from BASIC + +it's originally by Paul Lutus, from the Apple II Red Book, p45 + +this code is just toggling the speaker ($C030) on and off with cycle-counted +frequncies. + +There are fancier ways to get music out of the speaker, see Electric Duet +(also by Paul Lutus), dac522 (by Michael Mahon), and play-btc and +a2stream by Oliver Schmidt. + +using regular load/store/bit of $C030 is safe. Some of the more + advanced addressing modes can double-toggle due to how some 6502 + implementations run the address bus + +these was a table of notes floating around, but it seems the note values + were off a bit and also seems to have been calculated assuming + a 1MHz clock but the Apple II actually runs at roughly 1.023MHz + + ; the inner freq loop is roughly FREQ*10cycles + ; so the square wave generated has a period of + ; freq*20*1.023us + ; or a frequency of 1/(freq*20.46e-6) + + ; more exactly, it is (4+10F)+(13+10F) = 20F+17 + +Note this probably will be a bit off on PAL Apple IIs + +The code was originally in the form of a machine language program that could +be POKEd to address $00 of the zero page, and called from Integer Basic. + +Later this was adapted for Applesoft and loaded to $300 instead, although +when doing this Y was never initialized properly (Integer BASIC had it at $00 +but Applesoft it would be $02). + +see ../../utils/asoft_sound for some routines that are related but +have slightly different sounds to them diff --git a/music/redbook_sound/generate_frequencies.c b/music/redbook_sound/generate_frequencies.c new file mode 100644 index 00000000..47df310b --- /dev/null +++ b/music/redbook_sound/generate_frequencies.c @@ -0,0 +1,55 @@ +#include +#include + +static float note_frequencies[9][12]={ +/* C C# D D# E F F# G G# A A# B */ +{16.35, 17.32, 18.35, 19.45, 20.60, 21.83, 23.12, 24.50, 25.96, 27.50, 29.14, 30.87}, +{32.70, 34.65, 36.71, 38.89, 41.20, 43.65, 46.25, 49.00, 51.91, 55.00, 58.27, 61.74}, +{65.41, 69.30, 73.42, 77.78, 82.41, 87.31, 92.50, 98.00, 103.8, 110.0, 116.5, 123.5}, +{130.8, 138.6, 146.8, 155.6, 164.8, 174.6, 185.0, 196.0, 207.7, 220.0, 233.1, 246.9}, +{261.6, 277.2, 293.7, 311.1, 329.6, 349.2, 370.0, 392.0, 415.3, 440.0, 466.2, 493.9}, +{523.3, 554.4, 587.3, 622.3, 659.3, 698.5, 740.0, 784.0, 830.6, 880.0, 932.3, 987.8}, +{1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976}, +{2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951}, +{4186, 4435, 4699, 4978, 5274, 5588, 5920, 6272, 6645, 7040, 7459, 7902}, +}; + +static char note_names[12][12]={ + "C","CSHARP","D","DSHARP","E","F","FSHARP","G","GSHARP","A","ASHARP","B", +}; + +int main(int argc, char **argv) { + + int f,o; + float value,actual; + char temp_string[50]; + + for(o=3;o<7;o++) { + for(f=0;f<12;f++) { + // freq = 1/((20v+17)*1.023e-6) + // ((20v+17)*1.023e-6)= 1/freq + // 20v*1.023e-6 + 17*1.023e-6 = 1/freq + // 20v*1.023e-6 = (1/freq)-17*1.023e-6) + // v = ((1/freq)-17*1.023e-6)/(20*1.023e-6) + + value=(1.0/( + (20.0*(1.023e-6)*note_frequencies[o][f])- + 17*1.023e-6 + )); + + actual=1.0/((20.0*value+17)*1.023e-6); + +// value = ((1.0/note_frequencies[o][f])-17.0*1.023e-6)/ +// 20.0*1.023e-6; + + snprintf(temp_string,50,"NOTE_%s%1d", + note_names[f],o); + + printf("%-12s = %d\t; %.1f (%.1f)\n", + temp_string,(int)round(value), + actual,note_frequencies[o][f]); + } + } + + return 0; +} diff --git a/music/redbook_sound/note_frequencies.inc b/music/redbook_sound/note_frequencies.inc new file mode 100644 index 00000000..cd3cde3e --- /dev/null +++ b/music/redbook_sound/note_frequencies.inc @@ -0,0 +1,48 @@ +;NOTE_C3 = 376 ; 129.7 (130.8) +;NOTE_CSHARP3 = 355 ; 137.4 (138.6) +;NOTE_D3 = 335 ; 145.6 (146.8) +;NOTE_DSHARP3 = 316 ; 154.3 (155.6) +;NOTE_E3 = 298 ; 163.5 (164.8) +;NOTE_F3 = 281 ; 173.2 (174.6) +;NOTE_FSHARP3 = 265 ; 183.6 (185.0) +NOTE_G3 = 250 ; 194.5 (196.0) +NOTE_GSHARP3 = 236 ; 206.1 (207.7) +NOTE_A3 = 223 ; 218.3 (220.0) +NOTE_ASHARP3 = 210 ; 231.3 (233.1) +NOTE_B3 = 199 ; 245.0 (246.9) +NOTE_C4 = 187 ; 259.6 (261.6) +NOTE_CSHARP4 = 177 ; 275.0 (277.2) +NOTE_D4 = 167 ; 291.4 (293.7) +NOTE_DSHARP4 = 158 ; 308.6 (311.1) +NOTE_E4 = 149 ; 326.9 (329.6) +NOTE_F4 = 140 ; 346.3 (349.2) +NOTE_FSHARP4 = 132 ; 366.8 (370.0) +NOTE_G4 = 125 ; 388.5 (392.0) +NOTE_GSHARP4 = 118 ; 411.5 (415.3) +NOTE_A4 = 111 ; 435.8 (440.0) +NOTE_ASHARP4 = 105 ; 461.6 (466.2) +NOTE_B4 = 99 ; 488.9 (493.9) +NOTE_C5 = 94 ; 517.7 (523.3) +NOTE_CSHARP5 = 88 ; 548.3 (554.4) +NOTE_D5 = 83 ; 580.5 (587.3) +NOTE_DSHARP5 = 79 ; 614.8 (622.3) +NOTE_E5 = 74 ; 651.0 (659.3) +NOTE_F5 = 70 ; 689.3 (698.5) +NOTE_FSHARP5 = 66 ; 729.8 (740.0) +NOTE_G5 = 62 ; 772.6 (784.0) +NOTE_GSHARP5 = 59 ; 817.9 (830.6) +NOTE_A5 = 56 ; 865.9 (880.0) +NOTE_ASHARP5 = 52 ; 916.6 (932.3) +NOTE_B5 = 50 ; 970.3 (987.8) +NOTE_C6 = 47 ; 1027.5 (1047.0) +NOTE_CSHARP6 = 44 ; 1087.2 (1109.0) +NOTE_D6 = 42 ; 1150.7 (1175.0) +NOTE_DSHARP6 = 39 ; 1217.8 (1245.0) +NOTE_E6 = 37 ; 1288.6 (1319.0) +NOTE_F6 = 35 ; 1363.1 (1397.0) +NOTE_FSHARP6 = 33 ; 1442.1 (1480.0) +NOTE_G6 = 31 ; 1525.6 (1568.0) +NOTE_GSHARP6 = 29 ; 1613.6 (1661.0) +NOTE_A6 = 28 ; 1706.9 (1760.0) +NOTE_ASHARP6 = 26 ; 1805.6 (1865.0) +NOTE_B6 = 25 ; 1909.6 (1976.0) diff --git a/music/redbook_sound/redbook.bas b/music/redbook_sound/redbook.bas new file mode 100644 index 00000000..6f02ba22 --- /dev/null +++ b/music/redbook_sound/redbook.bas @@ -0,0 +1,7 @@ +10 GOSUB 100 +20 F=94:D=100:GOSUB 140 +90 END +100 FOR L = 770 TO 790: READ V: POKE L,V: NEXT L: RETURN +120 DATA 173,48,192,136,208,5,206,1,3,240,9 +130 DATA 202,208,245,174,0,3,76,2,3,96 +140 POKE 768,F: POKE 769,D: CALL 770: RETURN diff --git a/music/redbook_sound/redbook_sound.s b/music/redbook_sound/redbook_sound.s new file mode 100644 index 00000000..ab5a57ae --- /dev/null +++ b/music/redbook_sound/redbook_sound.s @@ -0,0 +1,111 @@ +; this code was widely shared for playing tones on Apple II +; by POKEing the machine language and CALLing from BASIC + +; it's originally by Paul Lutus, from the Apple II Red Book p45 + + +; it's hard to find good info on this, but loading from $C030 +; "toggles" the speaker. So toggling twice is esentially a square wave? + +; using regular load/store/bit of $C030 is safe. Some of the more +; advanced addressing modes can double-toggle due to how some 6502 +; implementations run the address bus + +; these seem to have been calculated assuming a 1MHz clock +; but the Apple II actually runs at roughly 1.023MHz + +; or a frequency of 1/(speaker_freq*20.46e-6) + +; to go other way, speaker_freq=1/(freq*20.46e-6) + +;NOTE_C3 = 376 ; 129.7 (130.8) +;NOTE_CSHARP3 = 355 ; 137.4 (138.6) +;NOTE_D3 = 335 ; 145.6 (146.8) +;NOTE_DSHARP3 = 316 ; 154.3 (155.6) +;NOTE_E3 = 298 ; 163.5 (164.8) +;NOTE_F3 = 281 ; 173.2 (174.6) +;NOTE_FSHARP3 = 265 ; 183.6 (185.0) +NOTE_G3 = 250 ; 194.5 (196.0) +NOTE_GSHARP3 = 236 ; 206.1 (207.7) +NOTE_A3 = 223 ; 218.3 (220.0) +NOTE_ASHARP3 = 210 ; 231.3 (233.1) +NOTE_B3 = 199 ; 245.0 (246.9) +NOTE_C4 = 187 ; 259.6 (261.6) +NOTE_CSHARP4 = 177 ; 275.0 (277.2) +NOTE_D4 = 167 ; 291.4 (293.7) +NOTE_DSHARP4 = 158 ; 308.6 (311.1) +NOTE_E4 = 149 ; 326.9 (329.6) +NOTE_F4 = 140 ; 346.3 (349.2) +NOTE_FSHARP4 = 132 ; 366.8 (370.0) +NOTE_G4 = 125 ; 388.5 (392.0) +NOTE_GSHARP4 = 118 ; 411.5 (415.3) +NOTE_A4 = 111 ; 435.8 (440.0) +NOTE_ASHARP4 = 105 ; 461.6 (466.2) +NOTE_B4 = 99 ; 488.9 (493.9) +NOTE_C5 = 94 ; 517.7 (523.3) +NOTE_CSHARP5 = 88 ; 548.3 (554.4) +NOTE_D5 = 83 ; 580.5 (587.3) +NOTE_DSHARP5 = 79 ; 614.8 (622.3) +NOTE_E5 = 74 ; 651.0 (659.3) +NOTE_F5 = 70 ; 689.3 (698.5) +NOTE_FSHARP5 = 66 ; 729.8 (740.0) +NOTE_G5 = 62 ; 772.6 (784.0) +NOTE_GSHARP5 = 59 ; 817.9 (830.6) +NOTE_A5 = 56 ; 865.9 (880.0) +NOTE_ASHARP5 = 52 ; 916.6 (932.3) +NOTE_B5 = 50 ; 970.3 (987.8) +NOTE_C6 = 47 ; 1027.5 (1047.0) +NOTE_CSHARP6 = 44 ; 1087.2 (1109.0) +NOTE_D6 = 42 ; 1150.7 (1175.0) +NOTE_DSHARP6 = 39 ; 1217.8 (1245.0) +NOTE_E6 = 37 ; 1288.6 (1319.0) +NOTE_F6 = 35 ; 1363.1 (1397.0) +NOTE_FSHARP6 = 33 ; 1442.1 (1480.0) +NOTE_G6 = 31 ; 1525.6 (1568.0) +NOTE_GSHARP6 = 29 ; 1613.6 (1661.0) +NOTE_A6 = 28 ; 1706.9 (1760.0) +NOTE_ASHARP6 = 26 ; 1805.6 (1865.0) +NOTE_B6 = 25 ; 1909.6 (1976.0) + + +;===================================================== +; speaker tone +;===================================================== +; A,X,Y trashed +; duration also trashed + +; this was designed by basic to be poked into 770 ($302) +; on an Applesoft CALL, X=$9d, Y=$02 (A,Y = Address to call) + +; it was originally designed for Integer BASIC where Y=0 on call +; and it was poked to $00 (zero page) + + ; the inner freq loop is roughly FREQ*10cycles + ; so the square wave generated has a period of + ; freq*20*1.023us + ; or a frequency of 1/(freq*20.46e-6) + + ; more exactly, it is (4+10F)+(13+10F) = 20F+17 + +speaker_tone: + ldy #0 ; 3 +speaker_tone_loop: + lda $C030 ; click speaker ; 4 +speaker_loop: + dey ; ; 2 + bne freq_loop ; ; 2/3 + dec speaker_duration ; (Duration) ; 6 + beq done_tone ; 2/3 +freq_loop: + dex ; 2 + bne speaker_loop ; 2/3 + ldx speaker_frequency ; (Frequency) ; 4 + jmp speaker_tone_loop ; 3 +done_tone: + rts + +speaker_duration: + .byte $00 +speaker_frequency: + .byte $00 + diff --git a/music/redbook_sound/sound_test.bas b/music/redbook_sound/sound_test.bas new file mode 100644 index 00000000..e9a395c2 --- /dev/null +++ b/music/redbook_sound/sound_test.bas @@ -0,0 +1,508 @@ +40 FOR L = 770 TO 790: READ V: POKE L,V: NEXT L +41 DATA 173,48,192,136,208,5,206,1,3,240,9 +42 DATA 202,208,245,174,0,3,76,2,3,96 +43 GOTO 100 +50 DATA 173,48,192,174,0,3,202,240,247,234,234,136,208,248,206,1,3,208,243,96 +51 FOR L=770 TO 789:READ V:POKE L,V:NEXT L +52 GOTO 100 +60 DATA 173,48,192,174,0,3,202,240,247,234,136,208,249,206,1,3,208,244,96 +61 FOR L=770 TO 788:READ V:POKE L,V:NEXT L +62 GOTO 100 +70 DATA 173,48,192,174,0,3,202,240,247,234,234,234,136,208,247,206,1,3,208,242,96 +71 FOR L=770 TO 790:READ V:POKE L,V:NEXT L +72 GOTO 100 +80 DATA 172,1,3,173,0,3,133,250,174,0,3,228,250,208,3,173,48,192,202,208,246,173,48,192,136,240,7,198,250,208,233,76,5,3,96 +81 FOR L=770 TO 804:READ V:POKE L,V:NEXT L +82 GOTO 100 +90 POKE 768,F:POKE 769,D:CALL 770:RETURN +' Still Alive +' from Portal +' Words and Music by Jonathan Coulton +' Transcribed from the sheet music made by Ryan Maziarz +' This was a triumph +100 D=54:F=85:GOSUB 90 +101 F=91:GOSUB 90 +102 F=102:GOSUB 90 +103 F=102:GOSUB 90 +104 F=91:GOSUB 90 +105 FOR I=1 TO 80: NEXT I +106 FOR I=1 TO 160: NEXT I +107 FOR I=1 TO 320: NEXT I +108 FOR I=1 TO 160: NEXT I +109 FOR I=1 TO 80: NEXT I +' I'm making a note here, HUGE SUCCESS +110 F=152:GOSUB 90 +111 F=85:GOSUB 90 +112 F=91:GOSUB 90 +113 F=102:GOSUB 90 +114 D=108:F=102:GOSUB 90 +115 D=54:F=91:GOSUB 90 +116 FOR I=1 TO 160: NEXT I +117 D=108:F=114:GOSUB 90 +118 D=54:F=102:GOSUB 90 +119 D=108:F=152:GOSUB 90 +120 FOR I=1 TO 80: NEXT I +121 FOR I=1 TO 160: NEXT I +122 FOR I=1 TO 160: NEXT I +123 FOR I=1 TO 80: NEXT I +' It's hard to overstate my satisfaction +'L8 < A > L4 E L8 F# G L4 G L8 F# C# C# L3 D L4 E L8 < A A A > L4 F# R8 R2 R2 +124 D=54:F=152:GOSUB 90 +125 D=108:F=102:GOSUB 90 +126 D=54:F=91:GOSUB 90 +127 D=162:F=85:GOSUB 90 +128 D=54:F=91:GOSUB 90 +129 D=108:F=121:GOSUB 90 +130 D=162:F=114:GOSUB 90 +131 D=108:F=102:GOSUB 90 +132 D=54:F=152:GOSUB 90 +133 D=108:F=152:GOSUB 90 +134 F=91:GOSUB 90 +135 FOR I=1 TO 80: NEXT I +136 FOR I=1 TO 320: NEXT I +137 FOR I=1 TO 320: NEXT I +' Aperture Science +138 D=54:F=85:GOSUB 90 +139 F=91:GOSUB 90 +140 F=102:GOSUB 90 +141 F=102:GOSUB 90 +142 F=91:GOSUB 90 +143 FOR I=1 TO 80: NEXT I +144 FOR I=1 TO 160: NEXT I +145 FOR I=1 TO 320: NEXT I +146 FOR I=1 TO 160: NEXT I +147 FOR I=1 TO 80: NEXT I +' we do what we must because we can. +148 F=152:GOSUB 90 +149 F=85:GOSUB 90 +150 F=91:GOSUB 90 +151 F=102:GOSUB 90 +152 F=102:GOSUB 90 +153 FOR I=1 TO 160: NEXT I +154 F=91:GOSUB 90 +155 F=114:GOSUB 90 +156 FOR I=1 TO 160: NEXT I +157 F=102:GOSUB 90 +158 D=162:F=152:GOSUB 90 +159 FOR I=1 TO 80: NEXT I +160 FOR I=1 TO 160: NEXT I +161 FOR I=1 TO 320: NEXT I +' for the good of all of us except the ones who are dead. +162 D=108:F=102:GOSUB 90 +163 D=54:F=91:GOSUB 90 +164 D=162:F=85:GOSUB 90 +165 D=54:F=102:GOSUB 90 +166 D=162:F=121:GOSUB 90 +167 D=54:F=114:GOSUB 90 +168 F=102:GOSUB 90 +169 FOR I=1 TO 80: NEXT I +170 F=152:GOSUB 90 +171 F=114:GOSUB 90 +172 F=102:GOSUB 90 +173 F=96:GOSUB 90 +174 F=102:GOSUB 90 +175 F=114:GOSUB 90 +176 F=128:GOSUB 90 +177 FOR I=1 TO 160: NEXT I +' But there's no sense crying over every mistake +178 F=152:GOSUB 90 +179 F=143:GOSUB 90 +180 D=108:F=128:GOSUB 90 +181 F=96:GOSUB 90 +182 D=54:F=102:GOSUB 90 +183 F=114:GOSUB 90 +184 F=114:GOSUB 90 +185 F=128:GOSUB 90 +186 F=114:GOSUB 90 +187 F=128:GOSUB 90 +188 D=108:F=128:GOSUB 90 +189 F=128:GOSUB 90 +' you just keep on trying till you run out of cake +190 D=54:F=152:GOSUB 90 +191 F=143:GOSUB 90 +192 D=108:F=128:GOSUB 90 +193 F=96:GOSUB 90 +194 D=54:F=85:GOSUB 90 +195 F=96:GOSUB 90 +196 F=102:GOSUB 90 +197 F=114:GOSUB 90 +198 F=114:GOSUB 90 +199 F=102:GOSUB 90 +200 D=108:F=96:GOSUB 90 +201 F=96:GOSUB 90 +' and the Science gets done and you make a neat gun +202 D=54:F=85:GOSUB 90 +203 F=76:GOSUB 90 +204 F=72:GOSUB 90 +205 F=72:GOSUB 90 +206 D=108:F=76:GOSUB 90 +207 F=85:GOSUB 90 +208 D=54:F=96:GOSUB 90 +209 F=85:GOSUB 90 +210 F=76:GOSUB 90 +211 F=76:GOSUB 90 +212 D=108:F=85:GOSUB 90 +213 F=96:GOSUB 90 +' for the people who are still alive. +214 D=54:F=114:GOSUB 90 +215 F=128:GOSUB 90 +216 F=114:GOSUB 90 +217 F=96:GOSUB 90 +218 F=96:GOSUB 90 +219 D=108:F=102:GOSUB 90 +220 D=54:F=102:GOSUB 90 +221 F=91:GOSUB 90 +222 D=162:F=91:GOSUB 90 +223 FOR I=1 TO 160: NEXT I +224 FOR I=1 TO 320: NEXT I +225 FOR I=1 TO 640: NEXT I +226 FOR I=1 TO 640: NEXT I +227 FOR I=1 TO 160: NEXT I +228 FOR I=1 TO 80: NEXT I +' I'm not even angry +' Note 8-16 and dotted 8 +229 D=54:F=152:GOSUB 90 +230 F=85:GOSUB 90 +231 F=91:GOSUB 90 +232 F=102:GOSUB 90 +233 F=102:GOSUB 90 +234 F=91:GOSUB 90 +235 FOR I=1 TO 160: NEXT I +236 FOR I=1 TO 320: NEXT I +237 FOR I=1 TO 320: NEXT I +' I'm being so sincere right now +238 F=85:GOSUB 90 +239 F=91:GOSUB 90 +240 F=102:GOSUB 90 +241 D=162:F=102:GOSUB 90 +242 D=54:F=91:GOSUB 90 +243 D=108:F=114:GOSUB 90 +244 F=102:GOSUB 90 +245 F=152:GOSUB 90 +246 FOR I=1 TO 80: NEXT I +247 FOR I=1 TO 160: NEXT I +248 FOR I=1 TO 320: NEXT I +' even though you broke my heart and killed me. +249 F=102:GOSUB 90 +250 D=54:F=91:GOSUB 90 +251 D=162:F=85:GOSUB 90 +252 D=108:F=102:GOSUB 90 +253 F=121:GOSUB 90 +254 D=54:F=114:GOSUB 90 +255 D=162:F=102:GOSUB 90 +256 D=54:F=152:GOSUB 90 +257 D=108:F=152:GOSUB 90 +258 D=54:F=91:GOSUB 90 +259 FOR I=1 TO 160: NEXT I +260 FOR I=1 TO 320: NEXT I +261 FOR I=1 TO 160: NEXT I +262 FOR I=1 TO 80: NEXT I +' and tore me to pieces +263 F=152:GOSUB 90 +264 F=85:GOSUB 90 +265 F=91:GOSUB 90 +266 F=102:GOSUB 90 +267 F=102:GOSUB 90 +268 F=91:GOSUB 90 +269 FOR I=1 TO 80: NEXT I +270 FOR I=1 TO 160: NEXT I +271 FOR I=1 TO 320: NEXT I +272 FOR I=1 TO 160: NEXT I +273 FOR I=1 TO 80: NEXT I +' L8 C# B A G G A R8 R4 R2 R4 R8 +' and threw every piece into a fire +274 F=152:GOSUB 90 +275 F=85:GOSUB 90 +276 F=91:GOSUB 90 +277 F=102:GOSUB 90 +278 F=102:GOSUB 90 +279 FOR I=1 TO 160: NEXT I +280 F=91:GOSUB 90 +281 F=114:GOSUB 90 +282 FOR I=1 TO 160: NEXT I +283 F=102:GOSUB 90 +284 D=108:F=152:GOSUB 90 +285 FOR I=1 TO 80: NEXT I +286 FOR I=1 TO 160: NEXT I +287 FOR I=1 TO 320: NEXT I +' As they burned it hurt because +288 F=102:GOSUB 90 +289 D=54:F=91:GOSUB 90 +290 D=162:F=85:GOSUB 90 +291 D=108:F=102:GOSUB 90 +292 F=121:GOSUB 90 +293 D=54:F=114:GOSUB 90 +294 F=102:GOSUB 90 +295 FOR I=1 TO 80: NEXT I +' I was so happy for you +296 F=152:GOSUB 90 +297 F=114:GOSUB 90 +298 F=102:GOSUB 90 +299 F=96:GOSUB 90 +300 F=102:GOSUB 90 +301 F=114:GOSUB 90 +302 F=128:GOSUB 90 +303 FOR I=1 TO 160: NEXT I +' Now these points of data make a beautiful line +304 F=152:GOSUB 90 +305 F=143:GOSUB 90 +306 D=108:F=128:GOSUB 90 +307 F=96:GOSUB 90 +308 D=54:F=102:GOSUB 90 +309 F=114:GOSUB 90 +310 F=114:GOSUB 90 +311 F=128:GOSUB 90 +312 F=114:GOSUB 90 +313 F=128:GOSUB 90 +314 D=108:F=128:GOSUB 90 +315 F=128:GOSUB 90 +' and we're out of beta, we're releasing on time. +316 D=54:F=152:GOSUB 90 +317 F=143:GOSUB 90 +318 D=108:F=128:GOSUB 90 +319 F=96:GOSUB 90 +320 D=54:F=85:GOSUB 90 +321 F=96:GOSUB 90 +322 F=102:GOSUB 90 +323 F=114:GOSUB 90 +324 F=114:GOSUB 90 +325 F=102:GOSUB 90 +326 D=108:F=96:GOSUB 90 +327 F=96:GOSUB 90 +' So I'm GLaD. I got burned. Think of all the things we learned +328 D=54:F=85:GOSUB 90 +329 F=76:GOSUB 90 +330 F=72:GOSUB 90 +331 F=72:GOSUB 90 +332 D=108:F=76:GOSUB 90 +333 F=85:GOSUB 90 +334 D=54:F=96:GOSUB 90 +335 F=85:GOSUB 90 +336 F=76:GOSUB 90 +337 F=76:GOSUB 90 +338 F=85:GOSUB 90 +339 F=96:GOSUB 90 +340 D=108:F=96:GOSUB 90 +' for the people who are still alive +341 D=54:F=114:GOSUB 90 +342 F=128:GOSUB 90 +343 F=114:GOSUB 90 +344 F=96:GOSUB 90 +345 F=96:GOSUB 90 +346 D=108:F=102:GOSUB 90 +347 D=54:F=102:GOSUB 90 +348 F=91:GOSUB 90 +349 D=162:F=91:GOSUB 90 +350 FOR I=1 TO 80: NEXT I +351 FOR I=1 TO 320: NEXT I +352 FOR I=1 TO 640: NEXT I +353 FOR I=1 TO 640: NEXT I +354 FOR I=1 TO 320: NEXT I +' Go ahead and leave me +355 D=54:F=85:GOSUB 90 +356 D=27:F=91:GOSUB 90 +357 F=91:GOSUB 90 +358 D=54:F=102:GOSUB 90 +359 D=108:F=102:GOSUB 90 +360 D=54:F=91:GOSUB 90 +361 FOR I=1 TO 160: NEXT I +362 FOR I=1 TO 320: NEXT I +363 FOR I=1 TO 160: NEXT I +364 FOR I=1 TO 80: NEXT I +' I think I'd prefer to stay inside +365 F=152:GOSUB 90 +366 F=85:GOSUB 90 +367 F=91:GOSUB 90 +368 F=102:GOSUB 90 +369 F=102:GOSUB 90 +370 FOR I=1 TO 160: NEXT I +371 F=91:GOSUB 90 +372 F=114:GOSUB 90 +373 FOR I=1 TO 160: NEXT I +374 F=102:GOSUB 90 +375 D=108:F=152:GOSUB 90 +376 FOR I=1 TO 80: NEXT I +377 FOR I=1 TO 160: NEXT I +378 FOR I=1 TO 320: NEXT I +' Maybe you'll find someone else to help you. +379 F=102:GOSUB 90 +380 D=54:F=91:GOSUB 90 +381 D=162:F=85:GOSUB 90 +382 D=108:F=102:GOSUB 90 +383 F=121:GOSUB 90 +384 D=54:F=114:GOSUB 90 +385 D=162:F=102:GOSUB 90 +386 D=54:F=152:GOSUB 90 +387 D=108:F=152:GOSUB 90 +388 D=54:F=91:GOSUB 90 +389 FOR I=1 TO 160: NEXT I +390 FOR I=1 TO 320: NEXT I +391 FOR I=1 TO 320: NEXT I +' Maybe Black Mesa +392 F=85:GOSUB 90 +393 F=91:GOSUB 90 +394 F=102:GOSUB 90 +395 D=108:F=102:GOSUB 90 +396 D=54:F=91:GOSUB 90 +397 FOR I=1 TO 160: NEXT I +398 FOR I=1 TO 320: NEXT I +399 FOR I=1 TO 320: NEXT I +' THAT WAS A JOKE, HA HA, FAT CHANCE +400 F=85:GOSUB 90 +401 F=91:GOSUB 90 +402 F=102:GOSUB 90 +403 F=102:GOSUB 90 +404 FOR I=1 TO 160: NEXT I +405 F=91:GOSUB 90 +406 F=114:GOSUB 90 +407 FOR I=1 TO 160: NEXT I +408 F=102:GOSUB 90 +409 D=108:F=152:GOSUB 90 +410 FOR I=1 TO 80: NEXT I +411 FOR I=1 TO 160: NEXT I +412 FOR I=1 TO 320: NEXT I +' Anyway this cake is great, it's so delicious and moist. +413 F=102:GOSUB 90 +414 D=54:F=91:GOSUB 90 +415 D=162:F=85:GOSUB 90 +416 D=108:F=102:GOSUB 90 +417 F=121:GOSUB 90 +418 D=54:F=114:GOSUB 90 +419 F=102:GOSUB 90 +420 FOR I=1 TO 80: NEXT I +421 F=152:GOSUB 90 +422 F=114:GOSUB 90 +423 F=102:GOSUB 90 +424 F=96:GOSUB 90 +425 F=102:GOSUB 90 +426 F=114:GOSUB 90 +427 F=128:GOSUB 90 +428 FOR I=1 TO 160: NEXT I +' Look at me still talking when there's Science to do +429 F=152:GOSUB 90 +430 F=143:GOSUB 90 +431 D=108:F=128:GOSUB 90 +432 F=96:GOSUB 90 +433 D=54:F=102:GOSUB 90 +434 F=114:GOSUB 90 +435 F=114:GOSUB 90 +436 F=128:GOSUB 90 +437 F=114:GOSUB 90 +438 F=128:GOSUB 90 +439 D=108:F=128:GOSUB 90 +440 F=128:GOSUB 90 +' When I look out there is makes me GLaD I'm not you. +441 D=54:F=152:GOSUB 90 +442 F=143:GOSUB 90 +443 D=108:F=128:GOSUB 90 +444 F=96:GOSUB 90 +445 D=54:F=85:GOSUB 90 +446 F=96:GOSUB 90 +447 F=102:GOSUB 90 +448 F=114:GOSUB 90 +449 F=114:GOSUB 90 +450 F=102:GOSUB 90 +451 D=108:F=96:GOSUB 90 +452 F=96:GOSUB 90 +' I've experiments to run. There is research to be done. +453 D=54:F=85:GOSUB 90 +454 F=76:GOSUB 90 +455 F=72:GOSUB 90 +456 F=72:GOSUB 90 +457 F=76:GOSUB 90 +458 F=85:GOSUB 90 +459 D=108:F=85:GOSUB 90 +460 D=54:F=96:GOSUB 90 +461 F=85:GOSUB 90 +462 F=76:GOSUB 90 +463 F=76:GOSUB 90 +464 F=85:GOSUB 90 +465 F=96:GOSUB 90 +466 D=108:F=96:GOSUB 90 +' On the people who are still alive. +467 D=54:F=114:GOSUB 90 +468 F=128:GOSUB 90 +469 F=114:GOSUB 90 +470 F=96:GOSUB 90 +471 F=96:GOSUB 90 +472 D=108:F=102:GOSUB 90 +473 D=54:F=102:GOSUB 90 +474 F=91:GOSUB 90 +475 D=162:F=91:GOSUB 90 +476 FOR I=1 TO 160: NEXT I +477 FOR I=1 TO 160: NEXT I +' And believe me I am still alive. +478 D=54:F=76:GOSUB 90 +479 F=76:GOSUB 90 +480 F=68:GOSUB 90 +481 F=76:GOSUB 90 +482 F=91:GOSUB 90 +483 D=108:F=114:GOSUB 90 +484 D=54:F=102:GOSUB 90 +485 F=91:GOSUB 90 +486 D=162:F=91:GOSUB 90 +487 FOR I=1 TO 160: NEXT I +488 FOR I=1 TO 80: NEXT I +' I'm doing science and I'm still alive. +489 D=54:F=76:GOSUB 90 +490 F=76:GOSUB 90 +491 F=76:GOSUB 90 +492 F=68:GOSUB 90 +493 F=76:GOSUB 90 +494 F=91:GOSUB 90 +495 D=108:F=114:GOSUB 90 +496 D=54:F=102:GOSUB 90 +497 F=91:GOSUB 90 +498 D=162:F=91:GOSUB 90 +499 FOR I=1 TO 160: NEXT I +500 FOR I=1 TO 80: NEXT I +' I feel FANTASTIC and I'm still alive. +501 D=54:F=76:GOSUB 90 +502 F=76:GOSUB 90 +503 F=76:GOSUB 90 +504 F=68:GOSUB 90 +505 F=76:GOSUB 90 +506 F=91:GOSUB 90 +507 D=108:F=114:GOSUB 90 +508 D=54:F=102:GOSUB 90 +509 F=91:GOSUB 90 +510 D=162:F=91:GOSUB 90 +511 FOR I=1 TO 160: NEXT I +512 FOR I=1 TO 160: NEXT I +' While you're dying I'll be still aliave +513 D=54:F=76:GOSUB 90 +514 F=76:GOSUB 90 +515 F=68:GOSUB 90 +516 F=76:GOSUB 90 +517 F=91:GOSUB 90 +518 D=108:F=114:GOSUB 90 +519 D=54:F=102:GOSUB 90 +520 F=91:GOSUB 90 +521 D=162:F=91:GOSUB 90 +522 FOR I=1 TO 160: NEXT I +523 FOR I=1 TO 80: NEXT I +' And when you're dead I will be still alive +524 D=54:F=76:GOSUB 90 +525 F=76:GOSUB 90 +526 F=76:GOSUB 90 +527 F=68:GOSUB 90 +528 F=76:GOSUB 90 +529 F=91:GOSUB 90 +530 D=108:F=114:GOSUB 90 +531 D=54:F=102:GOSUB 90 +532 F=91:GOSUB 90 +533 D=162:F=91:GOSUB 90 +534 FOR I=1 TO 160: NEXT I +535 FOR I=1 TO 80: NEXT I +' STILL ALIVE +536 D=54:F=85:GOSUB 90 +537 F=76:GOSUB 90 +538 D=162:F=76:GOSUB 90 +539 FOR I=1 TO 160: NEXT I +540 FOR I=1 TO 80: NEXT I +' STILL ALIVE +541 D=54:F=85:GOSUB 90 +542 F=91:GOSUB 90 +543 D=162:F=91:GOSUB 90 +544 FOR I=1 TO 160: NEXT I +545 FOR I=1 TO 320: NEXT I diff --git a/music/redbook_sound/wrong_frequencies.inc b/music/redbook_sound/wrong_frequencies.inc new file mode 100644 index 00000000..f9a03465 --- /dev/null +++ b/music/redbook_sound/wrong_frequencies.inc @@ -0,0 +1,45 @@ +; this table of notes was from +; http://eightbitsoundandfury.ld8.org/programming.html + +; it assumes 1MHz clock +; and has shifted the notes to better match octave boundaries +; NOTE_C3 is actually closer to G3 + +NOTE_C3 = 255 +NOTE_CSHARP3 = 241 +NOTE_D3 = 227 +NOTE_DSHARP3 = 214 +NOTE_E3 = 202 +NOTE_F3 = 191 +NOTE_FSHARP3 = 180 +NOTE_G3 = 170 +NOTE_GSHARP3 = 161 +NOTE_A3 = 152 +NOTE_ASHARP3 = 143 +NOTE_B3 = 135 + +NOTE_C4 = 128 +NOTE_CSHARP4 = 121 +NOTE_D4 = 114 +NOTE_DSHARP4 = 108 +NOTE_E4 = 102 +NOTE_F4 = 96 +NOTE_FSHARP4 = 91 +NOTE_G4 = 85 +NOTE_GSHARP4 = 81 +NOTE_A4 = 76 +NOTE_ASHARP4 = 72 +NOTE_B4 = 68 + +NOTE_C5 = 64 +NOTE_CSHARP5 = 60 +NOTE_D5 = 57 +NOTE_DSHARP5 = 54 +NOTE_E5 = 51 +NOTE_F5 = 48 +NOTE_FSHARP5 = 45 +NOTE_G5 = 43 +NOTE_GSHARP5 = 40 +NOTE_A5 = 38 +NOTE_ASHARP5 = 36 +NOTE_B5 = 34 diff --git a/music/sound_effects/sound.s b/music/sound_effects/sound.s index 8c8e78a9..b6abdc22 100644 --- a/music/sound_effects/sound.s +++ b/music/sound_effects/sound.s @@ -479,53 +479,12 @@ dly3: rts ; 6 6 6 6 6 6 6 00 00 00 00 01 01 01 0 1 1 1 0 0 1 -; based on code from here -; http://eightbitsoundandfury.ld8.org/programming.html +; redbook sound by Paul Lutus +; see music/redbook_sound ; A,X,Y trashed ; duration also trashed -NOTE_C3 = 255 -NOTE_CSHARP3 = 241 -NOTE_D3 = 227 -NOTE_DSHARP3 = 214 -NOTE_E3 = 202 -NOTE_F3 = 191 -NOTE_FSHARP3 = 180 -NOTE_G3 = 170 -NOTE_GSHARP3 = 161 -NOTE_A3 = 152 -NOTE_ASHARP3 = 143 -NOTE_B3 = 135 - -NOTE_C4 = 128 -NOTE_CSHARP4 = 121 -NOTE_D4 = 114 -NOTE_DSHARP4 = 108 -NOTE_E4 = 102 -NOTE_F4 = 96 -NOTE_FSHARP4 = 91 -NOTE_G4 = 85 -NOTE_GSHARP4 = 81 -NOTE_A4 = 76 -NOTE_ASHARP4 = 72 -NOTE_B4 = 68 - -NOTE_C5 = 64 -NOTE_CSHARP5 = 60 -NOTE_D5 = 57 -NOTE_DSHARP5 = 54 -NOTE_E5 = 51 -NOTE_F5 = 48 -NOTE_FSHARP5 = 45 -NOTE_G5 = 43 -NOTE_GSHARP5 = 40 -NOTE_A5 = 38 -NOTE_ASHARP5 = 36 -NOTE_B5 = 34 - - - speaker_tone: lda $C030 ; click speaker speaker_loop: diff --git a/utils/asoft_sound/asoft_sound.c b/utils/asoft_sound/asoft_sound.c index c99b1727..5a84dcfa 100644 --- a/utils/asoft_sound/asoft_sound.c +++ b/utils/asoft_sound/asoft_sound.c @@ -3,19 +3,12 @@ static int line=0; - -static int get_freq(int note, int octave, int flat, int sharp) { +/* frequencies from the eightbitsoundandfury webpage */ +static int get_freq_old(int note, int octave, int flat, int sharp) { if (octave==0) { switch(note) { - case 'A': - if (sharp) return 143; - if (flat) return 161; - return 152; - case 'B': - if (flat) return 143; - return 135; case 'C': if (sharp) return 241; return 255; @@ -33,6 +26,13 @@ static int get_freq(int note, int octave, int flat, int sharp) { if (sharp) return 161; if (flat) return 180; return 170; + case 'A': + if (sharp) return 143; + if (flat) return 161; + return 152; + case 'B': + if (flat) return 143; + return 135; default: fprintf(stderr,"Unknown note %c Line %d\n", note,line); } @@ -42,13 +42,6 @@ static int get_freq(int note, int octave, int flat, int sharp) { if (octave==1) { switch(note) { - case 'A': - if (sharp) return 72; - if (flat) return 81; - return 76; - case 'B': - if (flat) return 72; - return 68; case 'C': if (sharp) return 121; return 128; @@ -66,6 +59,14 @@ static int get_freq(int note, int octave, int flat, int sharp) { if (sharp) return 81; if (flat) return 91; return 85; + case 'A': + if (sharp) return 72; + if (flat) return 81; + return 76; + case 'B': + if (flat) return 72; + return 68; + default: fprintf(stderr,"Unknown note %c\n",note); } } else @@ -73,13 +74,6 @@ static int get_freq(int note, int octave, int flat, int sharp) { if (octave==2) { switch(note) { - case 'A': - if (sharp) return 36; - if (flat) return 40; - return 38; - case 'B': - if (flat) return 36; - return 34; case 'C': if (sharp) return 60; return 64; @@ -97,6 +91,14 @@ static int get_freq(int note, int octave, int flat, int sharp) { if (sharp) return 40; if (flat) return 45; return 43; + case 'A': + if (sharp) return 36; + if (flat) return 40; + return 38; + case 'B': + if (flat) return 36; + return 34; + default: fprintf(stderr,"Unknown note %c\n",note); } @@ -107,6 +109,117 @@ static int get_freq(int note, int octave, int flat, int sharp) { return 0; } +/* proper frequencies */ +static int get_freq_new(int note, int octave, int flat, int sharp) { + + if (octave==0) { + + switch(note) { // C3 +// case 'C': +// if (sharp) return 241; +// return 255; +// case 'D': +// if (sharp) return 214; +// if (flat) return 241; +// return 227; +// case 'E': +// if (flat) return 214; +// return 202; +// case 'F': +// if (sharp) return 180; +// return 191; + case 'G': + if (sharp) return 236; + return 250; + case 'A': + if (sharp) return 210; + if (flat) return 236; + return 223; + case 'B': + if (flat) return 210; + return 199; + + default: fprintf(stderr,"Unknown note %c Line %d\n", + note,line); + } + + } else + + if (octave==1) { + + switch(note) { + case 'C': + if (sharp) return 177; + return 187; + case 'D': + if (sharp) return 158; + if (flat) return 177; + return 167; + case 'E': + if (flat) return 158; + return 149; + case 'F': + if (sharp) return 132; + return 140; + case 'G': + if (sharp) return 118; + if (flat) return 132; + return 125; + case 'A': + if (sharp) return 105; + if (flat) return 118; + return 111; + case 'B': + if (flat) return 105; + return 99; + default: fprintf(stderr,"Unknown note %c\n",note); + } + } else + + if (octave==2) { + + switch(note) { + case 'C': + if (sharp) return 88; + return 94; + case 'D': + if (sharp) return 79; + if (flat) return 88; + return 83; + case 'E': + if (flat) return 79; + return 74; + case 'F': + if (sharp) return 66; + return 70; + case 'G': + if (sharp) return 59; + if (flat) return 66; + return 62; + case 'A': + if (sharp) return 52; + if (flat) return 59; + return 56; + case 'B': + if (flat) return 52; + return 50; + + default: fprintf(stderr,"Unknown note %c\n",note); + } + + } else { + fprintf(stderr,"Unknown octave %d!\n",octave); + } + + return 0; +} + +static int get_freq(int note, int octave, int flat, int sharp) { + + return get_freq_new(note,octave,flat,sharp); +} + + static int get_duration(int length) { int d=0;