[Fwd: Re: JSyn> buncha newbie questions]
Phil Burk
philburk at s...
Sat Jul 8 18:37:52 EDT 2000
-------- Original Message --------
Subject: Re: JSyn> buncha newbie questions
Date: Fri, 27 Aug 1999 07:22:07 -0700
From: Phil Burk <philburk at s...>
Reply-To: jsyn at l...
To: jsyn at l...
References: <199908270607.XAA28962 at l...>
Hello Anne,
I'm very glad you're asking questions. I hope more folks will join in
these discussions.
Anne Ogborn wrote:
>
> >From the user's guide:
>
> Synth.startEngine( 0, Synth.DEFAULT_FRAME_RATE / 2.0 );
>
> OK - what rate am I controlling here?
>
> As I understand it, the system "wakes up" periodically and
> tells all the Synth's to generate more data. This is the frequency of wakeup, right?
For a stereo sound card, a frame is two samples, left and right. The
frame rate is the number of stereo frames calculated and output per
second. The calculations are done in bursts of hundreds of frames when
the processor wakes up. The samples are then placed in a buffer and
output by the sound card using DMA and other hardware. The CPU does not
have to wake up for each sample.
The sound cards can generally only support certain sample rates so if
you specify an odd rate the low level code will have to do an expensive
resampling. It can get very inefficient if you do anything other than
1.0 or 0.5 times the Synth.DEFAULT_FRAME_RATE.
> ===============
>
> I take it the only output Units are SampleReader_16F1 and SampleReader_16F2
There are also SampleReader_16V1 which has a variable (V) sample rate
instead of a fixed (F) sample rate.
> Does this mean I can only play 16 bit WAV files, or is there some magic in there somewhere
> to do the conversion?
The SampleReader_16* units play 16 bit PCM data, which is basically just
an array of signed shorts. The data could come from an AIFF format file,
or a WAV format file, or another format that you parse, or be generated
by a program. See "JSynExamples\TJ_Sample*.java".
> =============
> Using your analogy of units connected togather, do I have to worry about
> levels/sample rates/etc. etc.?
Yes. The DAC's hardware can only output numbers in the range -1.0 to
+1.0. If you add signals together and get values like +1.7 then they
will get clipped to the proper range. This will sound buzzy and
distorted. You can reduce the size of the signals by setting the unit
generators "amplitude". If you add two oscillators together, you could
set their amplitude to 0.5 BEFORE adding so then they won't clip.
osc1.amplitude.set(0.5);
osc2.amplitude.set(0.5);
osc1.output.connect( adder.inputA );
osc2.output.connect( adder.inputB );
Also if you pass control signals around, you may want to set the signal
type on the port that ultimately controls sample rate so that it can be
controlled using convenient units.
> ===================
>
> I'm just digging through all this, but it all looks wonderful. It's simple, organized,
> well thought out, has a minimum of nonsense involvedd in doing simple things.
> After a summer of fighting Javasound, it's just delightful.
Thanks! This API has evolved slowly over many years and I've tried to
make it simple.
> For years I've thought of making a submarine game where the players would only
> have sound (sonar) and a control panel - just like in a real sub. I always thought
> it'd be a cool little hack, but the sound part of it seemed too much like "real work"
> to be fun.
> I think I can finally write it.
Yeah! That would be a great game. Do it!
--
Phil Burk
SoftSynth.com
mailto:philburk at s...
http://www.softsynth.com
More information about the JSyn
mailing list