-Fixing issue with single channel recordings while uninterleaving samples

master
Vincent Pizzo 2013-04-01 12:50:45 -05:00
parent 9cc9a7330b
commit d79ffdd352
5 changed files with 10 additions and 13 deletions

View File

@ -55,8 +55,7 @@ vorbisRecorder.start(...);
* Decode from file * Decode from file
<pre> <pre>
VorbisPlayer vorbisPlayer = new VorbisPlayer(fileToPlay); VorbisPlayer vorbisPlayer = new VorbisPlayer(fileToPlay);
//extract wave header information here, for example 44KHz stereo wav file vorbisPlayer.start();
vorbisPlayer.start(44100, 2);
</pre> </pre>
* To write to custom output, create a custom ```DecodeFeed``` * To write to custom output, create a custom ```DecodeFeed```

View File

@ -227,11 +227,12 @@ JNIEXPORT int JNICALL Java_org_xiph_vorbis_encoder_VorbisEncoder_startEncoding
float **buffer=vorbis_analysis_buffer(&vd,READ); float **buffer=vorbis_analysis_buffer(&vd,READ);
/* uninterleave samples */ /* uninterleave samples */
for(i=0;i<bytes/4;i++){ int channel;
buffer[0][i]=((readbuffer[i*4+1]<<8)| for(i=0;i<bytes/(2*channels);i++) {
(0x00ff&(int)readbuffer[i*4]))/32768.f; for(channel = 0; channel < channels; channel++) {
buffer[1][i]=((readbuffer[i*4+3]<<8)| buffer[channel][i]=((readbuffer[i*(2*channels)+(channel*2+1)]<<8)|
(0x00ff&(int)readbuffer[i*4+2]))/32768.f; (0x00ff&(int)readbuffer[i*(2*channels)+(channel*2)]))/32768.f;
}
} }
/* tell the library how much we actually submitted */ /* tell the library how much we actually submitted */

Binary file not shown.

View File

@ -98,8 +98,8 @@ public class MainActivity extends Activity {
} }
} }
//Start playing the 44KHz stereo vorbis audio //Start playing the vorbis audio
vorbisPlayer.start(44100, 2); vorbisPlayer.start();
} }
} }

View File

@ -196,12 +196,9 @@ public class VorbisPlayer implements Runnable {
/** /**
* Starts the audio recorder with a given sample rate and channels * Starts the audio recorder with a given sample rate and channels
*
* @param sampleRate the sample rate, must be greater than <code>0</code>
* @param channels the number of channels (can only be <code>1</code> or <code>2</code>)
*/ */
@SuppressWarnings("all") @SuppressWarnings("all")
public synchronized void start(int sampleRate, int channels) { public synchronized void start() {
if (isStopped()) { if (isStopped()) {
new Thread(this).start(); new Thread(this).start();
} }