westaust55
Moderator
I had an experiment tonight with importing a tune designed for the 08M which has the TUNE command. tried playing around with a small code snippet to see what I could do . . .
Out of this comes the question:
Has anyone with a CRO or frequency meter determined the frequency of the 128 SOUND command frequencies for a PICAXE such as the 28X1 or 40X1?
Unfortunately I do not have a CRO or frequency meter.
Maybe Technical has some info on the actual frequencies.
By setting up 3 very rough octaves in the picaxe EEPROM memory and then storing the 08M tune data in EEPROM I can read the data, calculate the octave, note duration and note, extract the (as yet very roughly assigned) frequency and play the appropriate sound. Seems that the PICAXE can keep up with the maths overhead but the note frequencies need a lot of work.
Here is a sample of what I tried tonight:
Out of this comes the question:
Has anyone with a CRO or frequency meter determined the frequency of the 128 SOUND command frequencies for a PICAXE such as the 28X1 or 40X1?
Unfortunately I do not have a CRO or frequency meter.
Maybe Technical has some info on the actual frequencies.
By setting up 3 very rough octaves in the picaxe EEPROM memory and then storing the 08M tune data in EEPROM I can read the data, calculate the octave, note duration and note, extract the (as yet very roughly assigned) frequency and play the appropriate sound. Seems that the PICAXE can keep up with the maths overhead but the note frequencies need a lot of work.
Here is a sample of what I tried tonight:
Code:
; C C# D D# E F F# G G# A A# B pause
EEPROM 0, (26,28,30,32,34,36,38,40,42,44,46,48,0,0,0,0) ; low octave
EEPROM 16, (51,54,57,60,63,66,69,72,75,78,81,84,0,0,0,0) ; middle octave
EEPROM 32, (86,88,90,92,94,96,98,100,102,103,104,105,0,0,0,0) ; high octavae
; next line is cut from sample tunes for the PICAXE 8M with tune function
'Greensleaves
EEPROM 50, ($27,$EA,$00,$02,$43,$02,$C0,$29,$25,$67,$29,$EA,$27,$27,$65,$27,$E9,$25,$E2,$27,$EA,$00,$02,$44,$02,$C0,$29,$25,$67,$29,$2A,$69,$27,$26,$64,$26,$E7)
for b8 = 50 to 87 ; manually count number of notes for this (could change to a do until $FF later)
read b8, b9 ; fetch data for next note
b7 = b9 / 64
if b7 = 0 then ; calculate duration of note (rough at moment - could use speed from tune command to auto adjust later
b6 =36 ; quarter
elseif b7 = 1 then
b6 = 18 ; eigth
elseif b7 = 2 then
b6 = 150 ; full
else
b6 = 75 ; half
endif
b2 = b9 / 16
b2 = b2 AND 3 ; extract octave number
if B2 = 1 then ; then hi octave
B1 =32
elseif b2 = 0 then ; else lo octave
b1 =16
else ; else the mid octave
b1=0
endif
b5 = b9 AND 15 ; extract the note
b5=b5+b1 ; add offset to right octave
read b5,b4 ; read value for note
sound 5,(b4,b6) ; play the note
next
end