sound_drv_001 question.
TonyA
Posts: 226
I'm using the gamepad to make sound. I was wondering how I could adjust the parameters of the PlaySound function.
Repeat
· if(game_pad.button(game_pad#NES0_A))· ·'if press the A button make sound.
··· snd.PlaySoundFM(0, snd#SHAPE_SQUARE, freqVar, snd#SAMPLE_RATE, 255, $2457_9DEF)
I replaced the "arg_freq" with the variable "freqVar". I'm able to plug different values for freqVar and get different tones. I'd like to use the up button to increase the frequency, and the down button to decrease.
So, I'm thinking about something like this:
freqVar := 16..1976· 'assign a range to the freqVar variable, (I have no idea)
if(game_pad.button(game_pad#NES0_UP)) 'if press up button frequency increases
··· freqVar + 1
Or
·
if(game_pad.button(game_pad#NES0_DOWN)) 'if press down button frequency decreases
··· 'snd.SetFreq(0, (freqVar -1))
Would something like this work?
Repeat
· if(game_pad.button(game_pad#NES0_A))· ·'if press the A button make sound.
··· snd.PlaySoundFM(0, snd#SHAPE_SQUARE, freqVar, snd#SAMPLE_RATE, 255, $2457_9DEF)
I replaced the "arg_freq" with the variable "freqVar". I'm able to plug different values for freqVar and get different tones. I'd like to use the up button to increase the frequency, and the down button to decrease.
So, I'm thinking about something like this:
freqVar := 16..1976· 'assign a range to the freqVar variable, (I have no idea)
if(game_pad.button(game_pad#NES0_UP)) 'if press up button frequency increases
··· freqVar + 1
Or
·
if(game_pad.button(game_pad#NES0_DOWN)) 'if press down button frequency decreases
··· 'snd.SetFreq(0, (freqVar -1))
Would something like this work?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Thank you.
Andre'
I'm just beginning to learn the basics of Spin·and thought I was·starting to understand how to call methods, etc.
(I'm not a programmer so please forgive the following).
I was able to produce sound with the gamepad buttons like this:
I am able to produce a note by pressing either the A, B, or START buttons,·and make·the note·go down a half step (or whole step?)by pressing the gamepad down button.
I was just trying to figure out how to make·the note·go down continually (sweep down)·as I hold the down button, and go up continually (sweep up)·as I hold the up button.
(And then apply that to change the other parameters like the SHAPE, volume, and envelope.)
Do I need an Index? or Array, etc?
*For instance; should I make some kind of "array" or list of all of the notes I would like to produce in my top object, and then "iterate" (my new programming word of the day!) through the array/list?
If so, how would I iterate through the array/list using one of the gamepad buttons (preferably the up and down buttons)?
Thanks.
Post Edited (TonyA) : 7/6/2007 12:48:18 AM GMT