Audioguy
2008-08-15 16:10:10 UTC
I'm using the USB 6009 to acquire audio in the form of a sine wave via analog inputs. My goal is to acquire the audio and determine the Fundamental frequency and THD+N of the signal much like the SignalExpress tool does when using the Analysis->Frequency-Domain measurements->Distortion block. I'm using the C API calls in a C++ program. My first question, are there C API calls to get the Distortion measurements? My other issue is that when I perform a DAQmxReadRaw, for data format I expect a 16 bit integer representation of a sine wave but the values are all over the place, representing more of jagged sawtooth than a sine wave. Maybe I'm handling the data wrong? I'm passing a char array into the ReadRaw call and getting what looks to be valid data although I'm not sure of the raw data format for the device. Maybe I'm setting up the timing / sampling params wrong. SignalExpress has no problems, so it must be something I'm doing. Here's my very simple setup of the task: DAQmxErrChk (DAQmxCreateTask("",&taskHandle)); DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_RSE,-2,2,DAQmx_Val_Volts,NULL));DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"OnboardClock",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000)); DAQmxDisableStartTrig( taskHandle );DAQmxErrChk (DAQmxStartTask(taskHandle));DAQmxErrChk (DAQmxReadRaw( taskHandle, -1, 10.0, Samples, 1000*2, &SamplesRead, &NumBytesPerSample, NULL)); Thanks for any suggestions, Patrick