LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sound card oscilloscope

Greetings,

 

I'm a bit of a newbie to LabVIEW and I'm trying to write a sound card based oscilloscope. I've been stuck a few hours on probably the most basic, first step. I want to read from a microphone directly onto a graph. While I can get a setup like this going, it's not quite ideal and I can't figure out how to fix it. For example, when using the Express VI "Acquire Sound" I can't get the image to update more frequently than what appears to be once a second. I'd like this to look more fluid. ~10-15ms. Is it possible to do this with the Express VI? I've also tried using my own VI, but I keep confusing myself and not getting the same result from the Express VI (However, a quicker refresh rate).

 

I know this probably sounds like a dumb question, and I myself feel like there's something big I'm missing that I shouldn't be. I've been trying it for hours now and I can't seem to come up with anything.

 

I also know there are already programs out there that can do this for me, and that a sound card based oscilloscope really has its limitations. I want to make one anyway. =]

 

If possible, can someone tell me how to get the graph to update more frequently using the Express VI, or some guidance on writing my own sound aquisition VI?

 

Thanks,

Pheria

0 Kudos
Message 1 of 5
(5,359 Views)

 


@Pheria wrote:

Greetings,

 

I'm a bit of a newbie to LabVIEW and I'm trying to write a sound card based oscilloscope. I've been stuck a few hours on probably the most basic, first step. I want to read from a microphone directly onto a graph. While I can get a setup like this going, it's not quite ideal and I can't figure out how to fix it. For example, when using the Express VI "Acquire Sound" I can't get the image to update more frequently than what appears to be once a second. I'd like this to look more fluid. ~10-15ms. Is it possible to do this with the Express VI?

 

Avoid using Express VI's.  They are very limited and will mess up your code rapidly.

 

I've also tried using my own VI, but I keep confusing myself and not getting the same result from the Express VI (However, a quicker refresh rate).

 

Can you post your code?

 

I know this probably sounds like a dumb question, and I myself feel like there's something big I'm missing that I shouldn't be. I've been trying it for hours now and I can't seem to come up with anything.

 

It may be something simple, but we can't tell until we see the code.

 

I also know there are already programs out there that can do this for me, and that a sound card based oscilloscope really has its limitations. I want to make one anyway. =]

 

If possible, can someone tell me how to get the graph to update more frequently using the Express VI, or some guidance on writing my own sound aquisition VI?

 

The solution is not the Express VI, but rather the architecture of your code.  It sounds like you need to use the producer/consumer design pattern, where the consumer loop takes care of your graph.

Once again, seeing your code will help to determine where the problem lies.

 

Thanks,

Pheria


 

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

Here is a link to a project which uses the sound card to display to the screen (and does a lot of analysis, as well).  It uses a producer/consumer architecture.  The final code has a bug in the setup - the buffer size needs to be doubled or it will get buffer overruns constantly.  Read through the posts, looking at the code as you do so.  What you are doing could be harder or simpler, depending upon what your final end goal is.  Let us know if you need more help.

0 Kudos
Message 3 of 5
(5,335 Views)

Greetings again,

 

Thank you for your insights. The project you linked was quite difficult to follow, but I think it helped a little. The solution was simple. I only needed to ready a device, read it, and send it to an indicator.

 

I've moved a bit further with my project and I've been stuck getting an error code 1 when I try to do a TCP Write. (I want to sample on a server sound card, send the waveform over TCP to a client, and then the client will perform manipulations some basic oscilloscope operations.

 

Right now it's not in a very organized state. Comments haven't been added and the state diagram implementation probably isn't ideal. A GUI is probably the last thing I'll come back to, so there is one, but it's a pretty big mess at the moment as well.

 

I'll be sure to attach the code this time. Sorry about not doing so last time.

 

In the code I'm trying to flatten the 1d array to a string to send over TCP, then unflatten it at the client. That doesn't seem to be the problem, however. As I stated, I keep getting an error code 1 on TCP Write on the server. I've eventried changing it to simply write a "hi" string and telling the client to read 2 bytes. No dice, same error.

 

I'm running both on the same machine for now and trying to connect to 127.0.0.1 on port 40000

 

Does anyone happen to have an idea why this error keeps occurring?

 

After I can tranfer the data over TCP, my next step will be to cut down on the number of samples I take from the sound card on the server (<1000). It often crashes when I reduce the sampling that low. I haven't tried to solve THIS aspect of the project much myself, so I feel it'd be rude to ask others to invest time in a solution for me. If you happen to know a good suggestion readily for this, I'm all ears. The main problem here is the mysterious error 1 I'm getting.

 

Thanks,

Pheria

 

 

Download All
0 Kudos
Message 4 of 5
(5,290 Views)

TCP/IP is something I have never used in LabVIEW, so take my comments with a grain of salt.  However, error code 1 means an invalid input.  Since you are using the local machine, try localhost as the address instead of 127.0.0.1.  Also make sure your firewall (if any) is not blocking the port you are using.  If that does not work, you may want to start a new thread for the issue, since it is not really related to a sound card oscilloscope.  You should get a better response.

0 Kudos
Message 5 of 5
(5,255 Views)