Q695 Posted May 11, 2014 Share Posted May 11, 2014 I have this function call I want tied directly into a var: startTone( tone ); How would I tie it into a var similar to how I have this var created: audio = new Audio(); audio.src = "sound.mp3"; audio.loop = false; audio.play(); Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/ Share on other sites More sharing options...
trq Posted May 11, 2014 Share Posted May 11, 2014 You want to store the result of calling startTone() in a variable? var foo = startTone(tone); The question however is, what does this function actually return? Obviously, there is no way for us to know the answer to that. Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479045 Share on other sites More sharing options...
Q695 Posted May 11, 2014 Author Share Posted May 11, 2014 I'm working with: http://www.softsynth.com/webaudio/tone.php As you can tell it returns an audio tone based upon the var "tone". Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479056 Share on other sites More sharing options...
Q695 Posted May 12, 2014 Author Share Posted May 12, 2014 That doesn't work, so how do I target the volume of everything on the page? Think how windows can target everything on your computer. Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479147 Share on other sites More sharing options...
trq Posted May 12, 2014 Share Posted May 12, 2014 Please.. you need to be more vague, I'm finding it far too easy to read your posts. Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479159 Share on other sites More sharing options...
Q695 Posted May 12, 2014 Author Share Posted May 12, 2014 I'm looking to load startTone( frequency ) into a variable so that I can manipulate the volume level of it instead of the generic 100%. Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479242 Share on other sites More sharing options...
trq Posted May 12, 2014 Share Posted May 12, 2014 We have absolutely no idea what that code does! We are not there in front of the code with you! You are going to need to provide relative information. Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479289 Share on other sites More sharing options...
Q695 Posted May 13, 2014 Author Share Posted May 13, 2014 This is the tone generator script from that page, and I want to load it into a page variable: http://jsfiddle.net/WH7Kf/61/ Would it be easier to grab the sounds from the whole page to manipulate them as I want to? Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479297 Share on other sites More sharing options...
trq Posted May 13, 2014 Share Posted May 13, 2014 Would it be easier to grab the sounds from the whole page to manipulate them as I want to? Your ability to describe your issue is non existent. This post makes zero sense, and your cryptic posts are nothing but frustrating. I'm out. Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479302 Share on other sites More sharing options...
Q695 Posted May 13, 2014 Author Share Posted May 13, 2014 In JavaScript I'm trying to: take a tone generated by a tone generator manipulate the tone (the only thing that will be on the whole page for sound) in several ways at the same time produce the tone in its manipulated form What I understand: the tone is generated by startTone( tone ) computer speaker manipulation What I need to do: make the product of startTone() manipulatable Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479304 Share on other sites More sharing options...
trq Posted May 13, 2014 Share Posted May 13, 2014 Everything appears to be tied to the global amp object, have you look at that? Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479313 Share on other sites More sharing options...
kicken Posted May 13, 2014 Share Posted May 13, 2014 From what I can tell briefly looking at the script if you want to store the tone into a variable you need to create another generateTone function which will create a new oscillator object at the proper frequency. Eg: function generateTone(context, frequency){ var oscillator = context.createOscillator(); fixOscillator(oscillator); oscillator.frequency.value = frequency; var amp = context.createGainNode(); oscillator.connect(amp); amp.connect(context.destination); return { oscillator: oscillator, amp: amp }; } That would create the oscillator and an associated amp object and return them. You'd then use the oscillator to alter the tone's frequency or the amp object to alter it's volume level. You could wrap that all up into a Tone object so that you'd just have to do something like var tone = new Tone(context, 100); tone.setVolume(0.6); tone.start(); tone.changeFrequency(60); tone.stop(); //etc Quote Link to comment https://forums.phpfreaks.com/topic/288396-how-do-i-plug-a-tone-generated-by-a-function-into-a-var/#findComment-1479355 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.