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
How do you loop NOTES?
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: How do you loop NOTES?
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.
So it is supposed to repeat NOTES LOAD and then NOTES PLAY if you want to play them again.
- Dutchman
- Posts: 851
- Joined: Mon May 06, 2013 9:21 am
- My devices: iMac, iPad Air, iPhone
- Location: Netherlands
- Flag:
Re: How do you loop NOTES?
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.
There is the command MUSIC M$ LOOP which enables repetition of the content.
- Dav
- Posts: 279
- Joined: Tue Dec 30, 2014 5:12 pm
- My devices: iPad Mini, iPod Touch.
- Location: North Carolina, USA
- Contact:
Re: How do you loop NOTES?
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
- Dav
- Dutchman
- Posts: 851
- Joined: Mon May 06, 2013 9:21 am
- My devices: iMac, iPad Air, iPhone
- Location: Netherlands
- Flag:
Re: How do you loop NOTES?
That is what I did in 'Sea Combat'
- Dav
- Posts: 279
- Joined: Tue Dec 30, 2014 5:12 pm
- My devices: iPad Mini, iPod Touch.
- Location: North Carolina, USA
- Contact:
Re: How do you loop NOTES?
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
- 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
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: How do you loop NOTES?
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.
- Dav
- Posts: 279
- Joined: Tue Dec 30, 2014 5:12 pm
- My devices: iPad Mini, iPod Touch.
- Location: North Carolina, USA
- Contact:
Re: How do you loop NOTES?
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
- Dav