Small sounds around 0 became extreme high/low values, so loud/hifreq sound.
Still no mic->buf->spk path, but at 8 kHz noise is now also low.
/* Copy encoded samples to plain samples */
//TODO// Better to switch once and then loop in a separate routine which may even be .asm -- but that could require a codec-specific state storage structure
-int16_t codec_decode (codec_t codec, uint8_t *in, uint16_t inlen, uint16_t *out, uint16_t outlen) {
+int16_t codec_decode (codec_t codec, uint8_t *in, uint16_t inlen, int16_t *out, uint16_t outlen) {
while ((inlen > 0) && (outlen > 0)) {
register uint16_t outval;
register uint8_t inval = *in++;
/* Copy plain samples to encoded samples */
//TODO// Better to switch once and then loop in a separate routine which may even be .asm -- but that could require a codec-specific state storage structure
-int16_t codec_encode (codec_t codec, uint16_t *in, uint16_t inlen, uint8_t *out, uint16_t outlen) {
-bottom_printf ("Have %d, %d, %d at %04x\n", (intptr_t) in [0], (intptr_t) in [1], (intptr_t) in [2], (intptr_t) in);
+int16_t codec_encode (codec_t codec, int16_t *in, uint16_t inlen, uint8_t *out, uint16_t outlen) {
+bottom_printf ("Have %d, %d, %d at %04x\n", (intptr_t) in [0] & 0x0000ffff, (intptr_t) in [1] & 0x0000ffff, (intptr_t) in [2] & 0x0000ffff, (intptr_t) in);
while ((inlen > 0) && (outlen > 0)) {
register uint16_t inval = *in++;
bool signbit;
#define BUFSZ (64*25)
-volatile uint16_t samplebuf_play [BUFSZ];
-volatile uint16_t samplebuf_record [BUFSZ];
+volatile int16_t samplebuf_play [BUFSZ];
+volatile int16_t samplebuf_record [BUFSZ];
volatile uint16_t available_play = 0;
volatile uint16_t available_record = 0;
/******** Calls to play or record through a codec ********/
-int16_t codec_decode (codec_t codec, uint8_t *in, uint16_t inlen, uint16_t *out, uint16_t outlen);
-int16_t codec_encode (codec_t codec, uint16_t *in, uint16_t inlen, uint8_t *out, uint16_t outlen);
+int16_t codec_decode (codec_t codec, uint8_t *in, uint16_t inlen, int16_t *out, uint16_t outlen);
+int16_t codec_encode (codec_t codec, int16_t *in, uint16_t inlen, uint8_t *out, uint16_t outlen);
void tlv320aic2x_set_samplerate (uint8_t chan, uint32_t samplerate);
//TODO// Guard against buffer wraparound
retval = codec_decode (codec,
coded_samples, coded_bytes,
- (uint16_t *) (samplebuf_play + nextwrite_play), samples);
+ (int16_t *) (samplebuf_play + nextwrite_play), samples);
nextwrite_play += samples;
available_play += samples;
if (retval < 0) {
samples = ar;
}
retval = codec_encode (codec,
- (uint16_t *) (samplebuf_record + nextread_record), samples,
+ (int16_t *) (samplebuf_record + nextread_record), samples,
coded_samples, coded_bytes);
nextread_record += samples;
available_record -= samples;
uint16_t loop = 0;
bottom_critical_region_end ();
top_hook_update (bottom_phone_is_offhook ());
- memset (samples, 0 + 128, sizeof (samples));
- bottom_codec_play_samplerate (PHONE_CHANNEL_TELEPHONY, 1000);
- bottom_codec_record_samplerate (PHONE_CHANNEL_TELEPHONY, 1000);
+ bottom_codec_play_samplerate (PHONE_CHANNEL_TELEPHONY, 8000);
+ bottom_codec_record_samplerate (PHONE_CHANNEL_TELEPHONY, 8000);
bottom_soundchannel_setvolume (PHONE_CHANNEL_TELEPHONY, 127);
bottom_show_fixed_msg (APP_LEVEL_ZERO, FIXMSG_READY);
bottom_printf ("Running the development function \"echo\" (Test sound)\n");