How to loop midi notes

Post Reply
Ramzan
Posts: 26
Joined: Mon Jan 04, 2016 11:13 pm
My devices: iPad
Flag: Great Britain

How to loop midi notes

Post 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:

Code: Select all

10 NOTES MIDI 1,9,60,127
Goto 10
But it doesn't work

Ramzan
Posts: 26
Joined: Mon Jan 04, 2016 11:13 pm
My devices: iPad
Flag: Great Britain

Re: How to loop midi notes

Post by Ramzan »

Ok I figured it out. I use a loop command and PAUSE

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: How to loop midi notes

Post by sarossell »

Well, don't share or nuthin'! ;)

Show us your successful code. {Please}
smart BASIC Rocks!

- Scott : San Diego, California

Ramzan
Posts: 26
Joined: Mon Jan 04, 2016 11:13 pm
My devices: iPad
Flag: Great Britain

Re: How to loop midi notes

Post 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.

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: How to loop midi notes

Post 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
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How to loop midi notes

Post by rbytes »

Here's another variation. Sound a bit like Stravinsky. :lol:

Code: Select all

loop:
note=50+RND(20)
NOTES MIDI 1,9,note,127
Pause RND(.5)
Goto loop
The only thing that gets me down is gravity...

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: How to loop midi notes

Post by sarossell »

Ha ha! That was fun. I tried it out and you're right. I swear I heard "The Rite of Spring".
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How to loop midi notes

Post 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"
The only thing that gets me down is gravity...

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: How to loop midi notes

Post 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. ;)
smart BASIC Rocks!

- Scott : San Diego, California

Post Reply