<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91713/creating-wave-file-from-pcm-data</link><description>Hi 
 I&amp;#39;m using the PDM module to capture audio through MP34DB02 PDM microphone ( here &amp;#39;s the datasheet). I set the clock frequency to default 1.032 MHz and a gain of +4 dB with mono configuration and left channel connection. 
 I get the PCM output to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 Jun 2024 11:10:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91713/creating-wave-file-from-pcm-data" /><item><title>RE: Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/thread/490849?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2024 11:10:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27ef0195-7f18-4550-bf8a-01dd8d065037</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please open a new ticket on this. It would also be helpful if you can include a sample wave file to show what the noise looks like, ideally using something simple like a sine wave as the input.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/thread/490753?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2024 06:31:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75a1aba6-00d2-4bfc-ad17-d25b3230373b</guid><dc:creator>Rakshita</dc:creator><description>&lt;p&gt;My issue is similar&lt;br /&gt;I am using sd card to store the pcm data in a .pcm file and than playing that file on Audacity but either its noise or silence&amp;nbsp;&lt;br /&gt;It would be great if u can help me regarding this&amp;nbsp;&lt;br /&gt;I am attaching my code for reference.&lt;br /&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8345.inmp621_5F00_mic.zip"&gt;devzone.nordicsemi.com/.../8345.inmp621_5F00_mic.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/thread/385658?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2022 08:58:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc07eb33-cde6-40dc-b65b-90a20c71f8a3</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Raj&lt;/p&gt;
&lt;p&gt;I am happy to help. If you have more questions later on just let me know.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/thread/385575?ContentTypeID=1</link><pubDate>Fri, 09 Sep 2022 22:56:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9689f043-91d5-469c-8d91-c314d9d8fe41</guid><dc:creator>RajB</dc:creator><description>&lt;p&gt;Thanks for your response&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn. I&amp;#39;ll incorporate your suggestions and get back to you. Thank you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Raj&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/thread/385519?ContentTypeID=1</link><pubDate>Fri, 09 Sep 2022 12:33:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80faff37-c62d-496f-88de-8fbe470b7b68</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Raj&lt;/p&gt;
&lt;p&gt;I will help Håkon out with this case.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The PDM module is giving you the PCM data directly, no conversion is necessary. I believe the problem in your case is that you are converting the PCM samples to a text (ASCII) string, which will alter the data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It should be possible to output the PCM data on the UART directly, so that you can simply open it as a PCM file in Audacity, but be aware that not all terminal applications are designed to be used with non ASCII data. You should try to find if there is a function in your terminal to store the incoming data as a binary file directly, without applying any string conversions, number formatting etc.&amp;nbsp;&lt;/p&gt;
[quote user=""]Question 2: Why am I not getting enough samples? Is there something wrong with the way I store and display the PCM data?[/quote]
&lt;p&gt;To me it looks like you are just overwriting the values in the&amp;nbsp;disp_pdm_buf buffer over and over each time the pdm event handler is called, and then after you are done sampling you will just print the final state of this buffer (which will be the last bytes of the 2 second sampling sequence).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Instead what you should do is create a larger buffer in the application, and&amp;nbsp;copy data into a different part of the buffer each time the event handler is called.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would also recommend using &lt;a href="https://www.tutorialspoint.com/c_standard_library/c_function_memcpy.htm"&gt;memcpy(..)&lt;/a&gt; to copy data from one buffer to the next, rather than running a for loop.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/thread/385093?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 15:54:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2c0c466-4a33-48a8-b468-2dcff6ee683a</guid><dc:creator>RajB</dc:creator><description>&lt;p&gt;OK thanks for your reply.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Raj&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating WAVE file from PCM data</title><link>https://devzone.nordicsemi.com/thread/384986?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 10:34:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e84f6328-d327-4eb5-8e14-af6a6ad74f8d</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello Raj,&lt;/p&gt;
&lt;p&gt;I will have to get back to you on this.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>