If I want to play one note say C2, with instrument 25 in the default instrument bank the following code does it.
notes set "25:c2"
notes play
do !until NOTES_TIME() > NOTES_LENGTH()
However if I want to set the note to a string variable I can't get it to work.
So the code below works and produces the note using the default instrument.
note$="c2"
notes set note$
notes play
do !until NOTES_TIME() > NOTES_LENGTH()
If I want to change to another instrument where do I put the quote marks?
Notes set "25:note$" etc almost works. It plays a note but it is a different high pitched one.
25:note$, "25":note$, produce an error.
I notice in the help documentation that midi should be used for real time note playing so I will start looking at that as well.
Playing a note as a string variable
- 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:
- Contact:
Re: Playing a note as a string variable
This code will work. Note that you can build a new string by combining the literal quote "25:" with the string variable note$. The ampersand is used to join them. It can join any series of literal quotes or string variables in any order you need.
Code: Select all
note$="c3"
notes set "25:"¬e$
notes play
do !until NOTES_TIME() > NOTES_LENGTH()
The only thing that gets me down is gravity...
Re: Playing a note as a string variable
Thanks that makes sense. I will try it later.