Skip to content

Commit

Permalink
Re-scale the audio values.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Feb 20, 2019
1 parent f5a4db7 commit fc65d0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions AMBE2WAV/AMBE2WAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ int CAMBE2WAV::run()
if (m_mode == MODE_P25) {
unsigned int blockSize = m_fec ? 18U : 11U;

imbe_vocoder vocoder;

uint8_t imbe[18U];
while (reader.read(imbe, blockSize) == blockSize) {
if (m_fec) {
Expand Down Expand Up @@ -225,13 +227,11 @@ int CAMBE2WAV::run()

int16_t audioInt[AUDIO_BLOCK_SIZE];

imbe_vocoder vocoder;
vocoder.imbe_decode(frame, audioInt);

float audioFloat[AUDIO_BLOCK_SIZE];

for (unsigned int i = 0U; i < AUDIO_BLOCK_SIZE; i++)
audioFloat[i] = (float(audioInt[i]) - 128.0F) / 255.0F;
audioFloat[i] = float(audioInt[i]) / 32768.0F;

writer.write(audioFloat, AUDIO_BLOCK_SIZE);
}
Expand Down
6 changes: 3 additions & 3 deletions WAV2AMBE/WAV2AMBE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ int CWAV2AMBE::run()

#if !defined(HAVE_USB3000_P25)
if (m_mode == MODE_P25) {
imbe_vocoder vocoder;

float audioFloat[AUDIO_BLOCK_SIZE];
while (reader.read(audioFloat, AUDIO_BLOCK_SIZE) == AUDIO_BLOCK_SIZE) {
imbe_vocoder vocoder;

int16_t audioInt[AUDIO_BLOCK_SIZE];
for (unsigned int i = 0U; i < AUDIO_BLOCK_SIZE; i++)
audioInt[i] = int16_t((audioFloat[i] * 128) + 128);
audioInt[i] = int16_t(audioFloat[i] * 32768.0F + 0.5F);

int16_t frameInt[8U];
vocoder.imbe_encode(frameInt, audioInt);
Expand Down

0 comments on commit fc65d0b

Please sign in to comment.