Jason Smalridge wrote:
>I am having trouble with this code. I am trying to create a Player class
>(GUI) for Oscillator classes, but the first one that I did will not work
>properly. It gives me a very distorted noise and I cannot control the
>frequency properly.
Your posted code came through in the digest, so I can read all of it. Very
weird that it's so mangled in the archives, though.
Anyway, it looks like you're asking for a little-endian AudioFormat in
getAudioFormat():
boolean bigEndian = false;
yet in SimpleOsc.makeWave(), your ByteBuffer and ShortBuffer are both
big-endian (the default for Buffers). The result is that bytes in each
sample are swapped high-for-low, which is going to approximate random noise.
Another possible problem is that SimpleOsc is generating mono data (one
sample per frame), but other parts of your code are playing it as stereo
audio (two samples per frame). The result is going to be twice the desired
signal frequency.
I don't know what your JavaSound experience is, but you may find a tutorial
useful. Dick Baldwin has a specific article on audio synthesis:
<http://www.developer.com/java/other/article.php/2226701>
He also has other articles on JavaSound, and on 1.4's Buffers. Find
"sound" or "buffer" on this page, near the bottom:
<http://www.dickbaldwin.com/tocadv.htm>
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden