|
|
@ -2,7 +2,6 @@ |
|
|
|
#ifndef _AudioConvert_I16toF32_h |
|
|
|
#ifndef _AudioConvert_I16toF32_h |
|
|
|
#define _AudioConvert_I16toF32_h |
|
|
|
#define _AudioConvert_I16toF32_h |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <AudioStream_F32.h> |
|
|
|
#include <AudioStream_F32.h> |
|
|
|
|
|
|
|
|
|
|
|
class AudioConvert_I16toF32 : public AudioStream_F32 //receive Int and transmits Float
|
|
|
|
class AudioConvert_I16toF32 : public AudioStream_F32 //receive Int and transmits Float
|
|
|
@ -14,12 +13,15 @@ class AudioConvert_I16toF32 : public AudioStream_F32 //receive Int and transmits |
|
|
|
//get the Int16 block
|
|
|
|
//get the Int16 block
|
|
|
|
audio_block_t *int_block; |
|
|
|
audio_block_t *int_block; |
|
|
|
int_block = AudioStream::receiveReadOnly(); //int16 data block
|
|
|
|
int_block = AudioStream::receiveReadOnly(); //int16 data block
|
|
|
|
if (!int_block) return; |
|
|
|
if (int_block==NULL) return; |
|
|
|
|
|
|
|
|
|
|
|
//allocate a float block
|
|
|
|
//allocate a float block
|
|
|
|
audio_block_f32_t *float_block; |
|
|
|
audio_block_f32_t *float_block; |
|
|
|
float_block = AudioStream_F32::allocate_f32();
|
|
|
|
float_block = AudioStream_F32::allocate_f32();
|
|
|
|
if (float_block == NULL) return; |
|
|
|
if (float_block == NULL) { |
|
|
|
|
|
|
|
AudioStream::release(int_block); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//convert to float
|
|
|
|
//convert to float
|
|
|
|
convertAudio_I16toF32(int_block, float_block, AUDIO_BLOCK_SAMPLES); |
|
|
|
convertAudio_I16toF32(int_block, float_block, AUDIO_BLOCK_SAMPLES); |
|
|
@ -57,7 +59,10 @@ class AudioConvert_F32toI16 : public AudioStream_F32 //receive Float and transmi |
|
|
|
//allocate a Int16 block
|
|
|
|
//allocate a Int16 block
|
|
|
|
audio_block_t *int_block; |
|
|
|
audio_block_t *int_block; |
|
|
|
int_block = AudioStream::allocate();
|
|
|
|
int_block = AudioStream::allocate();
|
|
|
|
if (int_block == NULL) return; |
|
|
|
if (int_block == NULL) { |
|
|
|
|
|
|
|
AudioStream_F32::release(float_block); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//convert back to int16
|
|
|
|
//convert back to int16
|
|
|
|
convertAudio_F32toI16(float_block, int_block, AUDIO_BLOCK_SAMPLES); |
|
|
|
convertAudio_F32toI16(float_block, int_block, AUDIO_BLOCK_SAMPLES); |
|
|
|