QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Kris01 on September 01, 2019, 02:58:16 pm

Title: A question about the PLAY function
Post by: Kris01 on September 01, 2019, 02:58:16 pm
Is there a way to play multiple "voices" with this function? I know you can add a comma and it will play several notes simultaneously. What I'm asking is if it's possible to play notes from a bass clef and treble clef together (with different melodies). See attachment.

How would I code this?
Title: Re: A question about the PLAY function
Post by: FellippeHeitor on September 01, 2019, 04:13:55 pm
PLAY “CEG”

Plays do, mi, sol, in sequence.

PLAY “C,E,G”

Plays a chord.
Title: Re: A question about the PLAY function
Post by: Kris01 on September 01, 2019, 04:34:30 pm
Right, but how do you keep the half note in the bass playing while the rest and eighth notes play from the treble staff?
Title: Re: A question about the PLAY function
Post by: FellippeHeitor on September 01, 2019, 04:45:11 pm
Make it longer. Specify its duration right after it.
Title: Re: A question about the PLAY function
Post by: FellippeHeitor on September 01, 2019, 05:16:38 pm
Or use L to change duration: Play “L1C,L16EGECEGEC”
Title: Re: A question about the PLAY function
Post by: Kris01 on September 01, 2019, 05:23:05 pm
But wouldn't that just play the half note and then the eighths? I don't think it would play them together. Please correct me if I'm wrong.
Title: Re: A question about the PLAY function
Post by: TempodiBasic on September 01, 2019, 06:41:22 pm
Hi Kris01

try this
Code: QB64: [Select]
  1. PLAY "cp32ep32g p8 c,e,g p4 l2C,l4E,l4G"
I think to hear a difference among the 3 ways of playing these CEG...
Title: Re: A question about the PLAY function
Post by: FellippeHeitor on September 01, 2019, 07:19:02 pm
Commas allow simultaneous notes. Please run the example.
Title: Re: A question about the PLAY function
Post by: Kris01 on September 02, 2019, 12:14:26 am
I figured it out. If I make the bass run in the background then it sounds like it should. The treble clef runs in the foreground independent of what the bass line is doing.
Title: Re: A question about the PLAY function
Post by: bplus on September 02, 2019, 10:19:43 am
Hi Kris01,

Sounds like interesting app, I hope you share a sample. Welcome to forum!
Title: Re: A question about the PLAY function
Post by: Kris01 on September 03, 2019, 12:39:13 am
Thanks bplus! I've been programming since high school (32 years ago! Yikes!) but I've seen some amazing examples of sample code on this forum!