Author Topic: A question about the PLAY function  (Read 3797 times)

0 Members and 1 Guest are viewing this topic.

Offline Kris01

  • Newbie
  • Posts: 5
    • View Profile
A question about the PLAY function
« 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?

FellippeHeitor

  • Guest
Re: A question about the PLAY function
« Reply #1 on: September 01, 2019, 04:13:55 pm »
PLAY “CEG”

Plays do, mi, sol, in sequence.

PLAY “C,E,G”

Plays a chord.
« Last Edit: September 01, 2019, 04:19:25 pm by FellippeHeitor »

Offline Kris01

  • Newbie
  • Posts: 5
    • View Profile
Re: A question about the PLAY function
« Reply #2 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?

FellippeHeitor

  • Guest
Re: A question about the PLAY function
« Reply #3 on: September 01, 2019, 04:45:11 pm »
Make it longer. Specify its duration right after it.
« Last Edit: September 01, 2019, 05:15:48 pm by FellippeHeitor »

FellippeHeitor

  • Guest
Re: A question about the PLAY function
« Reply #4 on: September 01, 2019, 05:16:38 pm »
Or use L to change duration: Play “L1C,L16EGECEGEC”
« Last Edit: September 01, 2019, 05:18:52 pm by FellippeHeitor »

Offline Kris01

  • Newbie
  • Posts: 5
    • View Profile
Re: A question about the PLAY function
« Reply #5 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.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: A question about the PLAY function
« Reply #6 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...
Programming isn't difficult, only it's  consuming time and coffee

FellippeHeitor

  • Guest
Re: A question about the PLAY function
« Reply #7 on: September 01, 2019, 07:19:02 pm »
Commas allow simultaneous notes. Please run the example.

Offline Kris01

  • Newbie
  • Posts: 5
    • View Profile
Re: A question about the PLAY function
« Reply #8 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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A question about the PLAY function
« Reply #9 on: September 02, 2019, 10:19:43 am »
Hi Kris01,

Sounds like interesting app, I hope you share a sample. Welcome to forum!

Offline Kris01

  • Newbie
  • Posts: 5
    • View Profile
Re: A question about the PLAY function
« Reply #10 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!