Before anyone uses this code, it has became clear to me that some people prefer clarification on licencing when source is open.
I will make the same statement here as I do when anyone asks, that is this.
If my source code is available, then I genuinely do not care what you do with it. If I intended to restrict its use in any way, then I simply would not release the code. That being said, the closest license that I know about is MIT. If anyone is not happy with “I have said it’s free so it is”, then go with MIT. Change it, sell it, forget about it, I really don’t care.
In this case specifically I have asked for help and actually want people to change any use my code, I don’t think I can be clearer.
UPDATE!
I have had a little play with this and I think I have it at a usable place. That being said, it isn’t finished, but it does show off what I am trying to do.
Source link - https://os.mbed.com/users/spinal/code/music_player/
Bin link - music_player.zip (75.2 KB)
The main thing left to do, is to modify the pokitto sound library to include part of this as it is currently running in the main project code and I feel that is slowing it down a little.
I have mad a reasonable start at a tracker based music player, specifically for one game, but I’m going to need a little help refining what I have to be more reusable.
https://os.mbed.com/users/spinal/code/music_player/
the tune in the example is based on Mod_Sensitive.xm (37.5 KB)
file, if anyone wants to hear what it should sound like :-P.
It works about as well as I expected, but isn’t much use to other people in its current state.
I assume there are far more elegant ways to do things like the following for example…
switch(instrument){
case 1:
playSound(t, s_01, sizeof(s_01), volume, speed, sampleRepeat[0]);
break;
case 2:
playSound(t, s_02, sizeof(s_02), volume, speed, sampleRepeat[1]);
break;
case 3:
playSound(t, s_03, sizeof(s_03), volume, speed, sampleRepeat[2]);
break;
case 4:
playSound(t, s_04, sizeof(s_04), volume, speed, sampleRepeat[3]);
break;
}
The music format (if you can call it that yet) is as follows -
const char tune[22][64][4][4]={
{
{{0 ,0 ,128,0 },{0 ,0 ,128,0 },{0 ,0 ,128,0 },{1 ,5 ,160,3 }},
4 columns with 64 rows, this example has 22 patterns.
1st number is the note to be played, starting at 1 with C, 0 being no note
2nd is the octave, rage from 0 to 8
3rd is volume, currently 0 doesn’t change volume, 128 or above changes the volume to number-128, with a recommended max of 63 to keep the mixing OK.
4th is the instrument number.
each instrument can have it’s own sample rate and can be loopable. I intended to at a start and end loop point, I haven’t done that yet.
one timer is used to fill the audio buffer and a second used to time the music playback.
Also needed would be some soft of tracker software, probably cross-platform I guess, I haven’t even thought much about that part.