Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using VarPtr in Play staement
#1
I'm trying to set the length of notes in a Play statement using a loop and Varptr, but can't hit on the correct syntax. This is what I'm currently trying:

Code: (Select All)
For D% = 1 To 3
    Play "L" + "X" + VarPtr$(D%) + "o3cdefgab"
Next

What am I doing wrong?
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#2
(12-05-2024, 11:39 PM)PhilOfPerth Wrote: I'm trying to set the length of notes in a Play statement using a loop and Varptr, but can't hit on the correct syntax. This is what I'm currently trying:

Code: (Select All)
For D% = 1 To 3
    Play "L" + "X" + VarPtr$(D%) + "o3cdefgab"
Next

What am I doing wrong?

I think you need to pass PLAY the whole string - the docs here show that:
Code: (Select All)
'Play scale in 7 different octaves
scale$ = "CDEFGAB"

play$ = "L16O=" + VARPTR$(i%) + "X" + VARPTR$(scale$)

FOR i% = 0 TO 6
    PLAY play$
NEXT

From: https://qb64phoenix.com/qb64wiki/index.php/PLAY
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#3
(12-06-2024, 04:25 AM)grymmjack Wrote:
(12-05-2024, 11:39 PM)PhilOfPerth Wrote: I'm trying to set the length of notes in a Play statement using a loop and Varptr, but can't hit on the correct syntax. This is what I'm currently trying:

Code: (Select All)
For D% = 1 To 3
    Play "L" + "X" + VarPtr$(D%) + "o3cdefgab"
Next

What am I doing wrong?

I think you need to pass PLAY the whole string - the docs here show that:
Code: (Select All)
'Play scale in 7 different octaves
scale$ = "CDEFGAB"

play$ = "L16O=" + VARPTR$(i%) + "X" + VARPTR$(scale$)

FOR i% = 0 TO 6
    PLAY play$
NEXT

From: https://qb64phoenix.com/qb64wiki/index.php/PLAY

Thanks @grymmjack. I'll play around with that and see what I can figure out.
(as you can see, I'm not the quickest at absorbing new info)!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#4
(12-06-2024, 09:05 AM)PhilOfPerth Wrote:
(12-06-2024, 04:25 AM)grymmjack Wrote:
(12-05-2024, 11:39 PM)PhilOfPerth Wrote: I'm trying to set the length of notes in a Play statement using a loop and Varptr, but can't hit on the correct syntax. This is what I'm currently trying:

Code: (Select All)
For D% = 1 To 3
    Play "L" + "X" + VarPtr$(D%) + "o3cdefgab"
Next

What am I doing wrong?

I think you need to pass PLAY the whole string - the docs here show that:
Code: (Select All)
'Play scale in 7 different octaves
scale$ = "CDEFGAB"

play$ = "L16O=" + VARPTR$(i%) + "X" + VARPTR$(scale$)

FOR i% = 0 TO 6
    PLAY play$
NEXT

From: https://qb64phoenix.com/qb64wiki/index.php/PLAY

Thanks @grymmjack. I'll play around with that and see what I can figure out.
(as you can see, I'm not the quickest at absorbing new info)!

OK good luck! Let us know how it goes Smile
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply




Users browsing this thread: 5 Guest(s)