About the ringtones and command Sound & Tune

jdev

New Member
Well guys I'm trying to use the command sound but including one of the music that comes with the editor of picaxe,but return error. but also use the command Tune again, the error. if you have a link that solves this or a complete sample, would greatly appreciate please!:confused::eek::confused:
 

hippy

Technical Support
Staff member
Can you give more details please of what the error actually is and where - In the Tune Wizard or in the Basic Program, and which PICAXE.
 

jdev

New Member
Picaxe28a
'A-Team
Code:
play tune 0, 6,($03,$6A,$C3,$6C,$68,$2A,$23,$6C,$67,$6A,$43,$6A,$45,$C3,$6C,$41,$40,$6A,$68,$EA)
Error: sinatxis error in this line
 

BeanieBots

Moderator
The 28A does not support "play" or "Tune".
Check the manual for which commands are supported by which PICAXEs.
 
Last edited:

jdev

New Member
But, Can I use the command sound using inside the A team, for example

sound0,6,($03,$6A,$C3,$6C,$68,$2A,$23,$6C,$67,$6A,$43,$6A,$45,$C3,$6C,$41,$40,$6A,$68,$EA)

Like this?
 

BeanieBots

Moderator
Yes, as long as you use the correct syntax:-

sound pin,(note,duration,note,duration......)

Whether or not your numbers will play "The A team" or not I don't know.
 

jdev

New Member
like this:
sound 0,($03,$6A,$C3,$6C,$68,$2A,$23,$6C,$67,$6A,$43,$6A,$45,$C3,$6C,$41,$40,$6A,$68,$EA)

It´s runing but do not play like a ringtone maybe on the 28a play fine!
 

Technical

Technical Support
Staff member
You cannot use the numbers from the tune command in a sound command, they will not work.

The best solution for you is to use a 28X1 rather than a 28A chip, as the 28X1 supports the play & tune command.
 

westaust55

Moderator
Play a tune on PICAXE without TUNE command

If you want to try and use some of the music sequences associated with the Tune command, I did some work on a program to use the data from TUNE sequences and play them with the SOUND command.

Was still a bit rough around the edges but it is a starting point if your PICAXE does not support the TUNE command.

Have a look at:
http://www.picaxeforum.co.uk/showthread.php?t=9578
 

jdev

New Member
Man is amazing your code, is little bit complicated but i´m catching the wave. you`re using the eeprom like tunes (i´m not musician), now greenleaves is the melody to play ah?. could you explain a little more is awesome
 

westaust55

Moderator
In summary, the program works as follows:
1. The first 3 EEPROM statements give an approximation of the Sound values for notes in 3 octaves. Bit rough but as close as I got in a couple of nights playing around.
2. The 4th EEPROM statement has all the data straight from a TUNE function.
Each byte of data is encoded to indicate the note, octave and duration for the TUNE function.
3. The For Next statement is set to step through each of the notes in the 4th EEPROM statement. And put the byte of data in variable b9
4. We take each note data and divide by 64. The resulting value indicates the length of the note (sound)
5. Then take the same data (b9) and divied by 16 and AND with 3 to get the bottom 2 bits of data so we have a value 0 to 3. This indicates the octave.
6. The maths for variable b5 uses AND 15 to get the bottom 4 bits of data (0-15) which indicates the note to simulate. Then add an offset to get a pointer (b5) to the note in the required octave.
7. Read from EEPROM using b5 as a pointer to the required note data and play the note for the duration determined in step 4 (held in variable b6)

I did not get around to doing any automatic calculation to determine the number of notes copied from a TUNE command but that is certainly possible rather than manually counting and changing the FOR statement values.

If you look at the TUNE command details in current revision of Manual 2 pages 176 on and in particular page 178 you can see how the note data is constructed for the TUNE command. My program attempts to reverse compute this data. I only made an approximation to the values for notes in the SOUND command as I do note have data on the frequency of each of the 128 available sounds.


Hope that is the level of additional description you are looking for.

While I have played in brass bands so know about music and knew about BASIC programming from the past, that program was what I created after using the PICAXE for about a month at the time I uploaded the program.
 
Last edited:
Top