I need to generate some software-created tones. Sound won’t work because i need to change pitch at run-time. NotePlayer won’t work because I can’t be constrained by conventional note steps or half steps. I need to specify one tone, at, lets say, 1000Hz and a second at, for example, 1001Hz, to demonstrate a particular physical phenomenon. The tones do not need (and should not have) any “color”; sine waves (with no particular attack or decay) are really what is needed. MacOS is top priority with Windows being “nice to have”.
How can I do this?
Oregon Research Electronics
is REALbasic Sinewave Generator (for OSX)
it’s old, maybe you can try it.
Thanks. Hope Xojo will open RB5.5 file.
Oops, it hangs when I start it (in current Xojo), it crashes at
// start playing sound through the device
err = AudioDeviceStart(device.ptr(0), (AddressOf wavePlayerCallback) )
DebugErr “AudioDeviceStart err=”+format(err,"#")
I do have multiple versions of RB to back before 5.5 so I will try some older versions to see whether success is possible. This is an area that I know absolutely nothing.
A while back I was doing a tone generator/player to compose some SELCAL tones for testing. I used the following references to create “on-the-fly” tones.
In the end I only needed a fixed number of tones and ran into issues with Xojo’s implementation of volume control in Windows (only in WIndows mind you) is broke (let’s say incomplete - it has been like that since like forever - see post). So I opted to create the specific files I needed, package them, and play with the right delays, and combinations (i.e. I did not go the route of “on-the-fly” tone generation).
But like I said above, using the links above I was able to create “on-the-fly” tones. I can’t share the final application for SELCAL, but I have a small test application for generating WAV tones if you’re interested.
Creating a PCM/Wave file and then playing it is fairly easy.
But because of the ‘change pitch at run-time’ -requirement, that’s not what you want right?
edit: See: https://forum.xojo.com/9660-noteplayer-problem/0
Thats my sense. HOWEVER, as I now think about it, maybe I could use several wav files - one higher pitched, one lower pitched, one as a combination. Then, just play the appropriate one. In the end, that may be easier.
Langue - how could I get a copy of your WAV generator?
In the link I posted above, Will Shank posted all source.
The test program I have is found here: https://dl.dropboxusercontent.com/u/42062295/RealSoftware/forum%20-%20audio%20wave%20file%20generator.rbp
EDIT: +1 for Will Shank’s post. I used that for one of the methods in the program.
I think with MBS Plugins comes an example for PortAudio which has a tone generator.
you make a sin curve for the frequency and play it to the speaker.
[quote=248351:@LangueR]The test program I have is found here: https://dl.dropboxusercontent.com/u/42062295/RealSoftware/forum%20-%20audio%20wave%20file%20generator.rbp
EDIT: +1 for Will Shank’s post. I used that for one of the methods in the program.[/quote]
Now we have tones, time for a hearing test.
Download Project File
Thanks, everyone. I think there is enough information to work from. I did not associate that link with “Will Shank” but finally found it.
And, Langue, I will try your test program. Yes, that works very nicely. That deals nicely with the wav file header. Like it.
Again, thanks for all the help.
Oregon Research Electronics