Page 1 of 1
How do you loop NOTES?
Posted: Fri Jan 16, 2015 1:14 pm
by Dav
I have a .MID file loaded by NOTES playing as background music for a game I'm making.
I'd like the .MID to loop after it is done playing. Is there a command to do that?
I have tried,
IF NOTES_PLAYING() = 0 THEN NOTES PLAY
but that doesn't seem to work.
Really impressed with how easy the sprite commands are to do graphics!
- Dav
Re: How do you loop NOTES?
Posted: Fri Jan 16, 2015 1:19 pm
by Mr. Kibernetik
Currently there is no rewind command for playing NOTES.
So it is supposed to repeat NOTES LOAD and then NOTES PLAY if you want to play them again.
Re: How do you loop NOTES?
Posted: Fri Jan 16, 2015 2:48 pm
by Dutchman
Background music can best be played from file in .WAV, or .MP# or .AIFF format.
There is the command MUSIC M$ LOOP which enables repetition of the content.
Re: How do you loop NOTES?
Posted: Fri Jan 16, 2015 3:01 pm
by Dav
Thanks for the quick replies here. I'm using MUSIC for the sound effects currently, but maybe I will switch it around and uses notes for effects and music command for looping.
- Dav
Re: How do you loop NOTES?
Posted: Fri Jan 16, 2015 3:20 pm
by Dutchman
That is what I did in 'Sea Combat'
Re: How do you loop NOTES?
Posted: Sun Jan 18, 2015 5:56 pm
by Dav
I've decided to use this method to loop notes, for a .MID playback during the game. It works, but NOTES_PLAYING() didn't work for me (or I'm just not using it correctly) so I used other notes commands. Here is what works for me. This way, I can still use MUSIC for sound effects, which are important to the game play.
- Dav
Code: Select all
'Looping a .MID file in a game
'By Dav - JAN/2015
'sample .mid to test with
a$= "winstone-data/sfx/sfx_music.mid"
'start .mid playback
notes load a$
notes play
'show info
print "Notes looping test"
print "Playing "; a$
print
print "Time left:"
'make a button to show time left
t$ = str$(notes_length() - notes_time())
button "time" text t$ at 140,75
'main game loop
do
t$ = str$(notes_length() - notes_time())
button "time" set text t$
gosub checkmusic
until 0
end
checkmusic:
'if music over, reload, start over
'if notes_playing()=0 then '<<< did not work
if notes_time() => notes_length() then
notes load a$
notes play
end if
return
Re: How do you loop NOTES?
Posted: Sun Jan 18, 2015 6:06 pm
by Mr. Kibernetik
NOTES_PLAYING() returns 1 always if MIDI sequence was started to play and did not stop yet. Currently MIDI playback does not stop automatically when musical sequence is over. So it is supposed to use NOTES_TIME() and NOTES_LENGTH() to detect end of musical sequence to stop it manually.
Re: How do you loop NOTES?
Posted: Sun Jan 18, 2015 6:17 pm
by Dav
Oh. Thanks. By the way, the notes command is very cool. Much better than the PLAY command I used in QB64 basic. I'm going to be experimenting with it!
- Dav