-Fixing issue with single channel recordings while uninterleaving samples
parent
9cc9a7330b
commit
d79ffdd352
|
@ -55,8 +55,7 @@ vorbisRecorder.start(...);
|
|||
* Decode from file
|
||||
<pre>
|
||||
VorbisPlayer vorbisPlayer = new VorbisPlayer(fileToPlay);
|
||||
//extract wave header information here, for example 44KHz stereo wav file
|
||||
vorbisPlayer.start(44100, 2);
|
||||
vorbisPlayer.start();
|
||||
</pre>
|
||||
|
||||
* To write to custom output, create a custom ```DecodeFeed```
|
||||
|
|
|
@ -227,11 +227,12 @@ JNIEXPORT int JNICALL Java_org_xiph_vorbis_encoder_VorbisEncoder_startEncoding
|
|||
float **buffer=vorbis_analysis_buffer(&vd,READ);
|
||||
|
||||
/* uninterleave samples */
|
||||
for(i=0;i<bytes/4;i++){
|
||||
buffer[0][i]=((readbuffer[i*4+1]<<8)|
|
||||
(0x00ff&(int)readbuffer[i*4]))/32768.f;
|
||||
buffer[1][i]=((readbuffer[i*4+3]<<8)|
|
||||
(0x00ff&(int)readbuffer[i*4+2]))/32768.f;
|
||||
int channel;
|
||||
for(i=0;i<bytes/(2*channels);i++) {
|
||||
for(channel = 0; channel < channels; channel++) {
|
||||
buffer[channel][i]=((readbuffer[i*(2*channels)+(channel*2+1)]<<8)|
|
||||
(0x00ff&(int)readbuffer[i*(2*channels)+(channel*2)]))/32768.f;
|
||||
}
|
||||
}
|
||||
|
||||
/* tell the library how much we actually submitted */
|
||||
|
|
Binary file not shown.
|
@ -98,8 +98,8 @@ public class MainActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
//Start playing the 44KHz stereo vorbis audio
|
||||
vorbisPlayer.start(44100, 2);
|
||||
//Start playing the vorbis audio
|
||||
vorbisPlayer.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -196,12 +196,9 @@ public class VorbisPlayer implements Runnable {
|
|||
|
||||
/**
|
||||
* 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")
|
||||
public synchronized void start(int sampleRate, int channels) {
|
||||
public synchronized void start() {
|
||||
if (isStopped()) {
|
||||
new Thread(this).start();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue