My mod loader is successful so far, having correctly loaded the data for the mod file I've chosen to use as my primary test subject: Space Debris, by Captain. If you want to know what this song sounds like, behold, and be amazed:
Space Debris is arguably the greatest song ever done in the Amiga Protracker format, and is definitely one of the iconic classics of tracked music.
Right now, my loader correctly stores everything into an object, even though the structure of the object could probably use some improvement. Now, the question remains: how to play it?
That's where things get a little more complicated, as I'm not really sure what to do with these byte arrays that represent audio. And there's going to be a lot of complicated things going on, such as the constant resampling and mixing and making sure effect commands are applied in the proper sequence.
But first things first: I need to actually make the sample play.
In the JVM, this is done through a SourceDataLine object. Here's how I'm doing this so far:
I start by creating an audio format. The parameters are for a 48khz sampling rate, 16 bit sample size, 1 channel (mono, for now), signed = true and bigEndian = true.
Then, using this audioFormat, I get a SourceDataLine which I name audioLine in my code.
Then, using this audioFormat, I get a SourceDataLine which I name audioLine in my code.
The sample parameter in this case represents a ProTracker sample, which contains a byteArray of PCM audio data. This I can simply write to the SourceDataLine - the parameters are for a ByteArray (the audio data), 0 = offset, and the length of the data in the array.
The result is that it plays whatever sample I pass into the method at its default frequency.
The next thing I will need to figure out is how to resample and play the audio at different rates, so I will need to find a resampling algorithm that I can apply to a byte array.
Comments
Post a Comment