LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

THD+N from Harmonic Analyzer giving strange answers

Warning now, I am going to give a pretty detailed view of my program just in case the issue is somewhere else than the function itself.  but I put the chunk of code in a zip file attached Smiley Very Happy

 

My mini program records sound from my Line-In port.  I have been using an external executable called Audio_recorder that I found elsewhere on this forum.  Mainly because I don't fully understand how to implement the recording myself into CVI and using windows APIs.  i went ahead and attached that c++ file in case someone is interested.

 

Everything is super duper and it it produces a .wav file that I then read in.  I then perform all the analysis on the signal as shown in the Record file.  I use ReadWavFileInfo, ReadWavFile from WavFileIO (also from this forum). Then I do ScaledWindow, AutoPowerSpectrum,PowerFrequencyEstimate and HarmonicAnalyzer to get my thd and thd+n.  My thd values out seem about right, but my thd+n are way off.

 

What I have noticed is that when I plot the waveform, i see the first 5-10% of the samples are zero.  I'm not sure if this is affecting my thd and thd+n results, but it seems its possibly something in the audio_recorder or possibly my agc or something in my audio card does this.  Then the signal shows up as its supposed to.  If I need to trim the .wav file, I may need help on how to do that correctly as well.

 

I've attached as much as I can to see if someone else could help, since it may need someone else to try it out.  I've also attached a few .wav files in case someone can't produce a few sine waves in their line-in port.

 

Thanks VERY much in advance

 

0 Kudos
Message 1 of 7
(3,877 Views)

ngay528,

 

You didn't attach enough files to run your application, I was not able to reproduce this. Need a UIR file and any .h files necessary.

 

Also, if this is specific to the audio_recorder application, have you tried contacting the persion who made it? His contact info is embedded in the .exe if you run it in the command prompt.

 

 

National Instruments
0 Kudos
Message 2 of 7
(3,851 Views)

Sorry I didn't add the entire project.  I made a quick demo attached.  Should compile.

 

I also attached other "perfect" test signals as examples bypassing the recording process, and I get a THD near 0, but THD+N is 15% or higher.

 

there still seems to be an issue with recording, which I am not completely sure why this happens but at the least, I can remove that part of the signal from my analysis array.  And i have not contacted the creator of the audio_recorder program at this time.  i have a feeling it is not the software but rather my line-in jack.  Regardless, my ideal solution would be to include that code into my program.  But there are plenty of other hurdles to pass first Smiley Happy

 

 

0 Kudos
Message 3 of 7
(3,842 Views)

Have any updates?

 

Also I wasn't sure if anyone else had some ideas in order to offset my AGC of my line-in.  I believe this is why my recorded sound is muted at the start for a short while.  And then there is no way to convert my amplitude of my .wav file to Vpp since the AGC changes all the time.

0 Kudos
Message 4 of 7
(3,773 Views)

Is your audio in muted for the same length of time each run? Or is it different each time. Is there a way you could add some dead sound to the beginning of the file?

National Instruments
0 Kudos
Message 5 of 7
(3,747 Views)

The "strangeness" seems to happen about the same length of "samples" which is why we beleive its the AGC on our sound cards.  One of my colleagues tested it and saw that it doesn't always start quite and increase but has seen it change.  But after about the same amount of "samples" though, the signal becomes constant.

 

Would this be causing the strange THD+N numbers?  I am just wondering why THD and THD+N are so different on the same signal.

0 Kudos
Message 6 of 7
(3,736 Views)

It seems like the problem you are experiencing is a little too specific to audio analysis for this forum. Most users here are CVI programmers, and not necessarily audiophiles. I would recommend posting on a third party forum, or maybe the support forums for your sound card.

 

National Instruments
0 Kudos
Message 7 of 7
(3,719 Views)