Hi Peter,

this is from the [EMAIL PROTECTED] mailing list:
--------------
Hi Johan,

one possibility is to use one SourceDataLine for all samples of the same
track and to fill the gaps between the samples with an exactly
calculated number of zero-value frames. Attached is a class that may
help you. Using this class you can insert silence the following way:

AudioFormat     format = ...;
AudioChannel    channel = new AudioChannel(format);
channel.start();
// add AudioInputStreams representing you samples
AudioInputStream        ais = ...;
channel.addAudioInputStream(ais);
// now insert 10 frames of silence
byte[]  abSilence = new byte[10 * format.getFrameSize()];
for (int i = 0; i < abSilence.length; i++)
{
        abSilence[i] = 0;
}
ByteArrayInputStream    bais = new ByteArrayInputStream(abSilence);
AudioInputStream        ais = new AudioInputStream(bais, format, 10);
channel.addAudioInputStream(ais);

Matthias Pfisterer


Johan Kotlinski wrote:
>
> Hi!
>
> I was planning to write a drum machine using audio samples, but found out that the 
>sleep() function had way too bad timing for this purpose. Do anyone know of a way to 
>create a midi/audio sequencer with good timing?
>
>  /Johan
>
----------------
Note that since AudioChannel class is taken directely out of an
application, you have to comment out some things to make it work. There
seems to be general interest in such a class, therefore there soon will
be a cleaned-up version of this class on the JavaSound Examples page at
http://rupert.informatik.uni-stuttgart.de/~pfistere/jsexamples/.

If you have further questions, be free to contact me.

Matthias


Peter Pilgrim wrote:
> 
> The undocumented sun.audio.* package had ContinuosAudioStreamSequence class
> which accepted a Vector of AudioStreamSequences.
> It allowed you to play AudioData samples one after enough in sequence
> thru the AudioPlayer. You could put together a song with sampled riffs
> albeit only by (*.au) files.
> 
> How do would you reimplement this behavious using JavaSound / 1.3 Beta?
> 
> --
> 
> Adios
> Peter
> 
> -----------------------------------------------------------------
> import std.Disclaimer;          // More Java for your Lava, Mate.
> "Give the man, what he wants. £££" [on Roy Keane, Quality Player]
> 
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

AudioChannel.java

Reply via email to