Playing a tune on the "bigger" PICAXE's

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:


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
 

manuka

Senior Member
Bravo on your zeal! Getting exact output tones can be a hassle, but maybe consider a cheap DMM with freq. settings? You may have some mileage with PWM & even PULSOUT as well- although these will be hardly orchestral.

Similar sound/tune postings pop up on this forum every few months,so try a search. Here's a past offering from Jeremy Leach => http://www.picaxeforum.co.uk/showthread.php?t=5881&highlight=sound+frequencies

Although you say "bigger PICAXEs" (ah-which one?), I guess you've played with 08M Tune Wizards ? Hippy also rolled a magnificent one (2004 ?) that even Beethoven would have applauded.

EXTRA: Although it will slightly slow things down, you may be able to usefully tweak output tones on the fly with an OSCTUNE. Andrew" BrightSpark" & I spent some time on a single 08M DTMF quest (+ PWM too), with only modest success, but it's doable with dual 08Ms => http://www.picaxeforum.co.uk/showthread.php?t=8140&highlight=osctune
 
Last edited:

westaust55

Moderator
Thanks technical,

gotta get that grey matter to remember all I have read. :(

Recall reading the comment by others that with the 08M for example the M stood for "Music" and was only PICAXEs with the tune command.

I had already tried searches on "Tune", "Sound", and "Music" with little success.
Its a bit like entering "i2C" which gives zero results. But "i2c*" finds a lot of posts.
 
Last edited:

Technical

Technical Support
Staff member
gotta get that grey matter to remember all I have read. .
No need to remember - part 2 of the manual clearly shows which commands work with which chips - just look up the command (e.g. tune) and use the diagrams on the left to see which chips that command works on.
 
Top