I testet the CreateSoundFromMemory-Function. Maybe this code inspires you.
It does some Tunes, but it is not a complete music-player. But you get the core idea.
With some work this could do "music" on the fly. Maybe someone or me will port Hively-Tracker code (
http://www.hivelytracker.co.uk/) or MOD/S3M decoder code.
// Project: makesound_FL
// Created: 2016-09-19
// show all errors
SetErrorMode(2)
function fen_makesound(freq)
channels =1 //mono
bits=16
rate = 44100
duration = 1 // in seconds
framesize = bits/8*channels
frames = rate * duration
moffset = 2+2+4+4 // header
memsize=frames*framesize+moffset
memid = Creatememblock(memsize)
SetMemblockByte ( memID, 0, channels)
SetMemblockByte ( memID, 2, bits)
SetMemblockInt ( memID, 4, rate)
SetMemblockInt ( memID, 8, frames)
num_to_write = rate / freq
val_to_write = 1
for i = 0 to (frames / num_to_write)-1
for j = 0 to num_to_write-1
SetMemblockShort( memID, moffset, val_to_write * 256*256-32535)
inc moffset,framesize
Next
val_to_write = (1 - val_to_write) // SquareWave
Next
soundid = 1
CreateSoundFromMemblock(1, memID) // 1..299
// could not do: soundid = CreateSoundFromMemblock(memID)
DeleteMemblock(memid)
endfunction soundid
// set window properties
SetWindowTitle( "makesound_FL" )
SetWindowSize( 1280, 720, 0 )
// set display properties
SetVirtualResolution( 1280, 720 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
sID = fen_makesound(440) // creates a wave or instrument-sample-sound
//InstID = PlaySound(sID)
Sleep(100)
SetSoundInstanceRate( PlaySound(sID),0.5) // 440 * 0.5 = 220, highter pitch causes the sound to be shorter
Sleep(100)
SetSoundInstanceRate( PlaySound(sID), 1) // 440 * 2.0 = 880, lower pitch causes the sound to be longer while playing
Sleep(100)
SetSoundInstanceRate( PlaySound(sID), 2) // 440 * 2.0 = 880, lower pitch causes the sound to be longer while playing
SetSoundInstanceRate( PlaySound(sID), 1)
Sleep(50)
SetSoundInstanceRate( PlaySound(sID), 2)
Sleep(50)
SetSoundInstanceRate( PlaySound(sID), 1.5)
// a "note" has to be stopped after the needed time StopSoundInstance( InstID )
//notes as char[ 10 ] = [ 1.2, 1.3, 1.4 ]
//Timer?
//Timer()
//ResetTimer()
do
Print( ScreenFPS() )
Sync()
loop