LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

spectrum analysis results output as audio to Windows

I have an application that stores raw data from vibrations. When I playback the raw data, I can apply a FFT on a small sample extract and look at the spectrum as a quicklook analysis. I like to output the spectrum to the Windows sound/music environment so that I can "hear" the quicklook as well.

The frequencies are sometimes 10 - 100 Hz, sometimes 10 - 10 kHz. In all cases, it is easy to fit this frequency range to the human audio range.

Maybe I have to define an equalizer. The measured virbrations (most often) fits on a linear scale with 2 decades range. To optimize this for the human ear, I probably have to define a frequency-power-dependent scaling and an non-linear amplitude scaling. Each will be easy to prog
ram when I have found some clues.

The FFT speed varies from 1x each second to 10x each second and is not very constant. So I think I have to calculate a "sound" for 1 second, send it to the output, and interrupt sound playing when a new FFT is available. Or I have to calculate a "sound" for 0.05 second, send it the output and repeatedly play it until a new FFT is available.

My big question: how can I send a spectrum (or a re-calculated amplitude sequency) to the Windows environment, start playing, and interrupt for a new spectrum? I prefer to send the output to some Windows (SDK) functions to that this will work on all computers with Windows 2000/XP and sound capabilities.

I am using LabWindows/CVI version 6.
I am using Windows 2000.
0 Kudos
Message 1 of 6
(4,373 Views)
Hello,

Take a look at the folowing example:

Play .wav Files Using Windows SDK Functions

This example shows how to output a .wav file to the soundcard using the Windows SDK functions. It is not totaly what you are trying to do but maybe it gives you a good idea on how to do this.

Best regards,

RikP
Application Engineering
National Instruments
Rik Prins, CLA, CLED
Software Development Engineer
0 Kudos
Message 2 of 6
(4,373 Views)
Thanks Rik for the effort, however ...
When I try the link, I get a message from my browser that the page is not available. (Also after login at the discussion forum.)

Is this the same sample as within Help -> Windows SDK that uses DirectSound to playback a wave-file? That's where I started myself to develop a source. But its still a long way to go.

If you think that your sample is different and better, do you know another link where I can access it?
0 Kudos
Message 3 of 6
(4,373 Views)
Try this link.
0 Kudos
Message 4 of 6
(4,373 Views)
Thanks again. This new link gave a minor problem with the firewall at home. However it also refers to the samples in the Labwindows/CVI distribution. From a quicklook in the Help -> Windows DSK, the sndPlaySound is a functions for waveforms from file or registry.

I am working now (also to be found in Windows SDK) with DirectSound from the DirectX distribution and additional functions IDirectSoundBuffer...
From a spectrum or frequency, I fill a PCM data buffer (instead of streaming it from file). I am at liberty to use any valid format and so I have choosen 44100 sample rate and signed 16-bit amplitude information. I already get a sound. I am now trying to find a method to create an automatic callback-event so that the CVI software can prepare
the next spectrum while a tune is finished in the background by Windows.

If that works, I have to adapt all buffers so that the subsequent spectra seems to be un-interrupted when playing back.

And after that, I will look into the human aspects eg non-linear amplitude filtering and frequency-dependent amplitude scaling.

Any additional information on one of these topics and especially when involving the use of IDirectSoundBuffer is welcome. I myself am not experienced in the use of Windows SDK.
0 Kudos
Message 5 of 6
(4,373 Views)
After some time searching through examples, I have solved my "big question" with information in CVI Help --> Windows SDK --> DirectSound --> C/C++ tutorial. For those I like to do something simular, I have attached my test programme.

In the attached project, there is a GUI where parameters for N frequencies can be entered. These entries are used to calculate a waveform. Of course you can compose such a waveform in many ways: sum sine-waves, inverse FFT, direct from A/D interface, ...

The source code shows how DirectSound can be used to play a (continuous) waveform. The code also shows how a new waveform can be transferred to DirectSound without interrupting the playback.

Please note that this a just a test programme. It does not contain yet sufficient check
s and code to handle errors. Especially for most use of DirectSound, additional code is needed when errors occur.

Jos
0 Kudos
Message 6 of 6
(4,373 Views)