diff --git a/scripts/clang_format.sh b/scripts/clang_format.sh index 6e799b6f..7c8e946d 100755 --- a/scripts/clang_format.sh +++ b/scripts/clang_format.sh @@ -85,6 +85,7 @@ platform/targets/GDx/hwconfig.h platform/targets/linux/emulator/sdl_engine.h platform/targets/ttwrplus/pmu.h tests/platform/mic_test.c +tests/platform/codec2_encode_test.c EOF ) diff --git a/tests/platform/codec2_encode_test.c b/tests/platform/codec2_encode_test.c index e2fff1b9..ef0cfa5e 100644 --- a/tests/platform/codec2_encode_test.c +++ b/tests/platform/codec2_encode_test.c @@ -32,12 +32,11 @@ #include static const size_t audioBufSize = 320; -static const size_t dataBufSize = 2*1024; +static const size_t dataBufSize = 2 * 1024; void error() { - while(1) - { + while (1) { platform_ledOn(RED); sleepFor(0u, 500u); platform_ledOff(RED); @@ -47,12 +46,13 @@ void error() void *mic_task(void *arg) { - (void) arg; + (void)arg; struct CODEC2 *codec2 = codec2_create(CODEC2_MODE_3200); - int16_t *audioBuf = ((int16_t *) malloc(audioBufSize * sizeof(int16_t))); - if(audioBuf == NULL) error(); - uint8_t *dataBuf = ((uint8_t *) malloc(dataBufSize * sizeof(uint8_t))); + int16_t *audioBuf = ((int16_t *)malloc(audioBufSize * sizeof(int16_t))); + if (audioBuf == NULL) + error(); + uint8_t *dataBuf = ((uint8_t *)malloc(dataBufSize * sizeof(uint8_t))); memset(dataBuf, 0x00, dataBufSize); sleepFor(0u, 500u); @@ -68,19 +68,21 @@ void *mic_task(void *arg) dsp_resetFilterState(&dcr); - while(pos < dataBufSize) - { + while (pos < dataBufSize) { dataBlock_t data = inputStream_getData(id); - if(data.data == NULL) error(); + if (data.data == NULL) + error(); // Pre-amplification stage - for(size_t i = 0; i < data.len; i++) data.data[i] <<= 3; + for (size_t i = 0; i < data.len; i++) + data.data[i] <<= 3; // DC removal dsp_dcRemoval(&dcr, data.data, data.len); // Post-amplification stage - for(size_t i = 0; i < data.len; i++) data.data[i] *= 20; + for (size_t i = 0; i < data.len; i++) + data.data[i] *= 20; codec2_encode(codec2, &dataBuf[pos], data.data); pos += 8; @@ -89,13 +91,13 @@ void *mic_task(void *arg) platform_ledOff(GREEN); sleepFor(10u, 0u); platform_ledOn(RED); - for(size_t i = 0; i < dataBufSize; i++) - { + for (size_t i = 0; i < dataBufSize; i++) { iprintf("%02x ", dataBuf[i]); } platform_ledOff(RED); - while(1) ; + while (1) + ; return 0; } @@ -105,15 +107,15 @@ int main() platform_init(); // Create mic input thread - pthread_t mic_thread; + pthread_t mic_thread; pthread_attr_t mic_attr; pthread_attr_init(&mic_attr); pthread_attr_setstacksize(&mic_attr, 20 * 1024); pthread_create(&mic_thread, &mic_attr, mic_task, NULL); - while(1) ; + while (1) + ; return 0; } -