Page 1 of 1
How to loop midi notes
Posted: Mon Dec 05, 2016 10:18 pm
by Ramzan
Say I want to play the same note over and over again using NOTES MIDI 1,9,60,127.
How would I do this?
I've tried:
But it doesn't work
Re: How to loop midi notes
Posted: Mon Dec 05, 2016 10:50 pm
by Ramzan
Ok I figured it out. I use a loop command and PAUSE
Re: How to loop midi notes
Posted: Tue Dec 06, 2016 1:31 am
by sarossell
Well, don't share or nuthin'!
Show us your successful code. {Please}
Re: How to loop midi notes
Posted: Tue Dec 06, 2016 11:39 pm
by Ramzan
It's nothing special, just
Code: Select all
loop
note=50+RND(20)
NOTES MIDI 1,9,note,127
Pause 1
Goto loop
This is just a generic version. Add however many tracks you want, any instruments, change the formula for note etc. Also you can pause for however long you need.
Re: How to loop midi notes
Posted: Wed Dec 07, 2016 12:45 am
by sarossell
Ah, I see what ya did there. I didn't expect the GOTO with so many people badmouthing it these days. I love the fact that sB includes it. I had a little fun with it and accidentally came up with a ten note ramble often heard in action films.
Code: Select all
for n = 1 to 10
note=30+rnd(10)
notes midi 1,9,note,127
pause .1
next n
Re: How to loop midi notes
Posted: Thu Dec 08, 2016 12:36 am
by rbytes
Here's another variation. Sound a bit like Stravinsky.
Code: Select all
loop:
note=50+RND(20)
NOTES MIDI 1,9,note,127
Pause RND(.5)
Goto loop
Re: How to loop midi notes
Posted: Thu Dec 08, 2016 1:20 am
by sarossell
Ha ha! That was fun. I tried it out and you're right. I swear I heard "The Rite of Spring".
Re: How to loop midi notes
Posted: Thu Dec 08, 2016 1:48 am
by rbytes
Smart Basic has another construct that avoids the use of goto statements
do
note=50+RND(20)
NOTES MIDI 1,9,note,127
Pause RND(.5)
until 0
This loop will run forever! Normally you would use logic with the until statement - e.g. until x > 20
But the 0 is just interpreted as "condition not met"
Re: How to loop midi notes
Posted: Thu Dec 08, 2016 1:54 am
by sarossell
Ah, I knew about the DO..UNTIL, but it never occurred to me to use a zero for a continuous loop. I've always been a big fan of the FOR..NEXT with BREAK. I think it's the OCD in me that prefers a known limit with exception instead of an continuous loop with an exit clause. My own special kind of crazy. Thanks for a peek into a saner world.