First time posting here, hopefully i'm in the right section of the forum. Anyway, i'm a part time student and currently studying a module on Labview in university. As a mini project i decided to build a synth using Labview. I've it mostly built but i'm having a bit of trouble outputting sound to the soundcard. I'm also having a bit of trouble getting the waveforms to play for a longer time period.
I was sort of copying the setup of one of the example VIs (generating sound vi i think) and another vi i found online but i can't seem to get mine to work using my synth design. I've two problems, one is that the waveform only plays for a very short time but the main problem is that i'm getting an error (error 4803) saying the soundcard cannot accomodate the specified configuration but as far as i can see my setup is more or less the same as the generating sound vi (which works on my fine macbook). Obviously i'm missing something so i decided to come on here and ask for help.
I'm guessing the datatype connected to my sound output configure vi could be causing a problem since it has a red dot on the input terminal. Any suggestions on how i should fix this?
I've my vi attached. Any help would be appreciated!
Edit: I've already fixed the error 4803 problem. Had to change the input to the sound output configure sub vi. Now i just have to figure out how to get the sound to play for longer. Any ideas anyone?
Solved! Go to Solution.
I kind of cheated with that one. For some reason the "Format" cluster i have connected to the sound output configure sub vi seemed to be the wrong data type. I had the numeric controls set as follows:
Rate - DBL
Channels - I32
Bits - I32
Just as the example vi had that i was more or less copying. I couldn't figure out why this was causing a problem so i opened up the example project on my macbook (which seemed to be slightly different from the example vi on the windows machine in uni earlier) and copied over the cluster constant and it fixed the problem. I was going to look into why this fixed it at a later stage, as my priority has now changed to sustaining a note for a bit longer.
OK. You have several problems.
The cluster order in your Format cluster is Rate, Bits, Channels while the order in the "sound format" cluster on Sound Output Configure.vi is sample rate (S/s), number of channels, bits per sample. LabVIEW connects clusters according to the cluster order. How to avoid this: Pop up on the sound format conpane terminal on the Sound Output Configure.vi icon on the block diagram and choose Create Control. That will put a control with the same names and cluster order on the front panel. You can edit the names if you wish as long as you do not change the cluster order. The alternate is to Unbundle the data from your cluster control and then bundle it to the input cluster. I show this in the modification of your VI attached.
The VI does not respond to the Stop button until the event structure executes, which only happens when a key is pressed. Fix: Add an event case for the Stop Value Changed event. I show this in the modification of your VI attached.
The VI does not recognize changes in Octave, Amplitude, Osc Select, or Filter Frequency until the second keypress after changing any of these controls. Why? Dataflow. Those controls are probably read within microseconds after an iteration of the for loop starts. They are not read again until the next iteration regardless of when or how many times they are changed. The loop will not iterate until the Event structure completes, which only happens when a key is pressed. The Fix: Event cases for Value Changes on those controls. Note that this does not work because now there is no defined frequency. So, you also need some shift registers. Because of the problems mentioned, I did not put this into the modified VI.
Next, the event structure freezes the front panel until the code inside has completed. This becomes quite apparent when you set the duration to 2 seconds and press several keys quickly. The fix to this and the problem in the paragraph above is a parallel loop archtitecture, such as the Producer/Consumer Design Pattern.
Not a problem but a different way of doing something: Use Scale by Power of 2 from the Numeric palette in place of the case structure connected to Octave. I show this in the modification of your VI attached.
Now to your question about tone duration: The duration of a signal generated by the Sine Waveform.vi and the others is determined by the sampling frequency and the number of samples. You are a student so you can do the math. You need to adjust the number of samples because the sampling frequency is fixed.
The modified VI works fine on my iMac.
Thanks a lot Lynn! That's loads of help and I'll definitely learn a few things from it. Much appreciated!
That'll be my project finished nearly three weeks early. Just a few things to tidy up now then the fun part....the write up!
Remember that your instructor may be monitoring this Forum, so be sure to give appropriate credit for the help you have received.