diff --git a/tests/periph_pdm/main.c b/tests/periph_pdm/main.c index b6e54d34a0c2e..140513247c416 100644 --- a/tests/periph_pdm/main.c +++ b/tests/periph_pdm/main.c @@ -69,14 +69,8 @@ int start_recording_cmd(int argc, char **argv) (void)argv; _main_thread_pid = thread_getpid(); #if !PDM_DATA_PRINT_BINARY - //puts("PDM peripheral driver test\n"); #endif -/* msg_t temp; - for (unsigned i = 0; i<1; i++) - { - msg_receive(&temp); - } */ for (unsigned repeat = 0; repeat < NEW_BUF_SIZE / PDM_BUF_SIZE; repeat++) { msg_t msg; msg_receive(&msg); @@ -84,14 +78,6 @@ int start_recording_cmd(int argc, char **argv) #if PDM_DATA_PRINT_BINARY stdio_write((uint8_t *)buf, PDM_BUF_SIZE >> 2); #else - /* printf("Start of the buffer\n"); - for (unsigned idx = 0; idx < PDM_BUF_SIZE; ++idx) { - printf("%i\n", buf[idx]); - buf_size = idx; - } - printf("End of the buffer\n"); - printf("%d\n", buf_size); */ - // Copy PDM_BUF_SIZE to NEW_BUF_SIZE repeatedly for (unsigned idx = 0; idx < PDM_BUF_SIZE; idx++) { new_buf[repeat*PDM_BUF_SIZE+idx] = buf[idx]; @@ -99,7 +85,6 @@ int start_recording_cmd(int argc, char **argv) #endif } // Parse the new_buf - //pdm_stop(); _main_thread_pid = KERNEL_PID_UNDEF; printf("Start of the new buffer\n"); for (unsigned idx = 0; idx < NEW_BUF_SIZE ; idx++) { diff --git a/tests/periph_pdm/larger_buff_size.py b/tests/periph_pdm/testing_pdm_conversion.py similarity index 77% rename from tests/periph_pdm/larger_buff_size.py rename to tests/periph_pdm/testing_pdm_conversion.py index c8c1f562a4387..bf60805477b36 100644 --- a/tests/periph_pdm/larger_buff_size.py +++ b/tests/periph_pdm/testing_pdm_conversion.py @@ -14,7 +14,7 @@ str1 = "Start of the new buffer".encode('ascii') str2= "End of the new buffer".encode('ascii') -start_index_buf = 0 +start_index_buf = 0 stop_index_buf = 0 start_found = False buffer_number = 0 @@ -31,20 +31,17 @@ value = line.strip() data[key] = value if line.find(str1) != -1: - #print("Start Recording") start_found = True start_index_buf = key if line.find(str2) != -1: - if start_found: stop_index_buf = key buffer_number = stop_index_buf - start_index_buf - 2 start = False - #print("Stop recording") break key +=1 -print(start_index_buf) +print(start_index_buf) print(stop_index_buf) print(buffer_number) ser.close() @@ -52,8 +49,6 @@ # Extract the data within the specified range data_to_plot = [int(data[i]) for i in range(start_index_buf+1, stop_index_buf)] data_to_bytes = [int(data[i]).to_bytes(2,byteorder="little",signed=True) for i in range(start_index_buf+1, stop_index_buf)] -data_to_export = [(data[i]) for i in range(start_index_buf+1, stop_index_buf)] -#print(data_to_bytes) # Save the data to 16-b file # Open a file in binary write mode @@ -62,22 +57,6 @@ # Write the binary data to the file f.write(binary_data) -# Sample rate (Hz) -sample_rate = 16000 - -# Open a new wave file -with wave.open("output_wave.wav", "w") as output_wave: - # Set parameters for the wave file - output_wave.setnchannels(1) # Mono - output_wave.setsampwidth(2) # 2 bytes per sample for 16-bit audio - output_wave.setframerate(sample_rate) - - # Convert data_to_plot to numpy array - data_np = np.array(data_to_bytes) - - # Convert data to bytes and write to the wave file - output_wave.writeframes(data_np) - # Sample rate (Hz) samplerate = 16000 length = 1 @@ -94,6 +73,7 @@ # Convert to (little-endian) 16 bit integers. audio = (audio * (2 ** 15 - 1)).astype("