LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Audio Input

Hi,

I am very new to LabView and am self-taught so please forgive any mistakes. I am trying to write a program that will 1.) record boolean data and 2.) record audio input with date and time into an Excel sheet. I have successfully created step 1, but am having issues with step 2. It is recording audio (I think, though I am not sure what the units of amplitude are in this case- decibels?) but it is greatly slowing down my program and causing lags of up to 15 seconds where I just lose that data, which is not acceptable for the application of this. I tried to create a "producer/consumer" loop in a separate VI just to see if that would get rid of the lag, but it doesn't look like it is. I will attach both VIs below (they are messy-sorry). Any help would be greatly appreciated, as no one I work with has ever worked with audio and I have hit a wall.

Download All
0 Kudos
Message 1 of 5
(2,727 Views)

Hi mnchem,

 


@mnchem wrote:

2.) record audio input with date and time into an Excel sheet. 

 

 It is recording audio (I think, though I am not sure what the units of amplitude are in this case- decibels?) but it is greatly slowing down my program and causing lags of up to 15 seconds where I just lose that data, which is not acceptable for the application of this


There are some bugs in "PatientTest":

  • Your SoundRead is set to read 10k samples at 22050 Hz, resulting in data blocks of ~0.45s. But there is an additional wait of 1.0s in your loop: this is causing delays!
  • Why do you read the audio data as an array of waveforms, but convert all those sample to one single scalar value using the FromDDT ExpressVI? This looks very suspicious…
  • Building up an array in a loop is highly inefficient and will also slow down the loop sooner or later!
  • Writing the same (growing) data to your Excel file using the RGT function is also highly inefficient…
  • Using RGT functions to create an Excel file is in itself inefficient (aka slow). Why don't you create a simple CSV file instead?

In the QueueTest VI there are basically the very same problems/bugs, but spread over two loops…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(2,673 Views)

Hi GerdW,

Like I said, I am very new (to LV and coding in general), so most of what I have done comes from tutorials I've found on Youtube. The program was working fine before I added the audio component, so I thought building the array in the loop then writing to an Excel file (as I saw in a tutorial) was okay. Can you describe how to create a CSV file (or point me in the direction of a tutorial/instructions?). 

The second bullet point is the only part that I really came up with myself, so I am not surprised that it is wrong. Basically, the end goal is to measure the average volume of what the mic is picking up every second, and logging that with the other boolean data. I need to know what the patient is doing (reading, coughing, etc.) along with their volume every second when I look back at this data. Do you have any suggestions on how to record the audio in a less "suspicious" way?

Again, beginner language so I really appreciate any help in layman's terms. Thank you!

0 Kudos
Message 3 of 5
(2,668 Views)

Hi mnchem,

 


@mnchem wrote:

The program was working fine before I added the audio component, so I thought building the array in the loop then writing to an Excel file (as I saw in a tutorial) was okay. Can you describe how to create a CSV file (or point me in the direction of a tutorial/instructions?). 


Why do you go to Yutube when there are "Training resources" at the top of the LabVIEW board?

 

To create a CSV file (which basically is a formatted text file) you can either use the WriteDelimitedFile function - or WriteTextFile with some formatted strings…

 


@mnchem wrote:

Basically, the end goal is to measure the average volume of what the mic is picking up every second, and logging that with the other boolean data. I need to know what the patient is doing (reading, coughing, etc.) along with their volume every second when I look back at this data. Do you have any suggestions on how to record the audio in a less "suspicious" way?


The you should read samples of one second, so at 22.050kHz you should read 22050 samples.

Then you use WaveformGetCompontents function to get the samples from each waveform, and finally use a Mean function on the samples array to get the average!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(2,664 Views)

Hi GerdW,

Thank you for your help so far. Would you mind taking a look at this revised version and tell me where I am going wrong? When I save as a .txt file (there were errors when I tried to save either as csv or xlsx), I get the headers (Date, Time, "aaah"ing, etc.) but it is not recording any of the data, boolean or audio. 

I tried to use the lightbulb (not sure what it is called) and it looks like the data is getting stuck getting out of the while loop. I tried putting the build array and write delimited spreadsheet inside the loop just to see, and the data was able to get through those but again something got stuck at the loop I think. I tried removing the loop just to see what would happen, and it did successfully record the data, but just once (as expected), so there must be a problem with the loop that I'm not understanding.

Also, could you describe what the amplitude measurements I will be getting physically mean? i.e are they volume in decibels..?

Thank you again!

0 Kudos
Message 5 of 5
(2,568 Views)