From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multitone generator with more inputs and with output to computer speakers

Solved!
Go to solution

I want to add several (perhaps 10)  harmonically related sinewave tones and output to the computer speakers or line out. Ideally would like to use the full audio range so 44100 Hz sample rate. I've managed to combine a couple of VIs and get something that works at lower sample rates but doesn't dynamically update if I change frequency or phases. And at higher sample rates it isn't a continuous sound. It just beeps, then waits, beeps then waits. I'm sure oters have tried to tackle this in the past but don't find much info. Currently using a Mac but could switch to a pc if needed. Guidance will be most graciously accepted.

0 Kudos
Message 1 of 9
(3,239 Views)
Solution
Accepted by topic author Danl_B

I found several things which together keep your VI from working the way you want. The VI attached works fine on my Mac.

 

1. I configured the sound and the tone generator to use the same sampling info. Any other combination creates complications.

2. I found out the hard way that the tone generator wants the frequncy to be an integer multiple of (sampling rate)/(# samples). This does not appear in the documentation (help file) but other combinations throw errors.

3. Set the amplitude input (not Tone Amplitudes) on the Multitone Generator.vi to 1.00. This makes its output compatible with the Sound VIs. This is documented in the help but you have to read several places and put thepieces together.

4. The reset input to Multitone Generator.vi must be true for it to respond to changes in the tone frequencies, amplitudes, or phases inputs. I just wired a true constant for now. Later this might be better handled by an event structure.

5. Consider making the frequency, amplitude, and phase controls into arrays or one 2D array so that an arbitrary number of tones cna be used without modifying the program.

6. Some kind of Wait may be required. Without it I occasionally received a Timeout error. Several options are in different cases of the Diagram Disable Structure. The Sound Output Wait will guarantee that the timeout does not occur but it also produces small gaps in the sound. The Wait (ms) works fairly well but it is a guess as to the optimum value for the Wait.  After all the changes I have madevene the no wait case seems to work.

 

Lynn

Message 2 of 9
(3,211 Views)

Lynn,

 

Thank you for the sage comments and surpisingly quick response. Some I would have figured out quickly but other issues would have taken me a month of Sundays. The delay between the time I change amplitude or phase is interesting but quite tolerable. I suppose I would eventually have figured out the (sampling rate)/(# samples) = integer value; makes sense in hindsight. Your pointers and assistance are very much appreciated.

 

Dan

0 Kudos
Message 3 of 9
(3,196 Views)

Dan,

 

The delay is a function of how long all the code in the loop takes to complete an iteration. As it is set in my VI the time is about 1 second. However, if the Stop button is read at the beginning of the iteration (most likely), it will take the rest of that iteration and all of the next one to stop it.  Because of the way the tones are generated and the sound sampling frequency, there may not be too many combinations which will work to give you much shorter times.

 

Lynn

0 Kudos
Message 4 of 9
(3,187 Views)

Then you should mark Lynn's message as the solution to your question rather than your own thank you message.  First you will need to go to the options menu to the upper right of  your message to unmark it as the solution.

0 Kudos
Message 5 of 9
(3,186 Views)

Message received. Thank you for the "heads up".

 

Dan


@RavensFan wrote:

Then you should mark Lynn's message as the solution to your question rather than your own thank you message.  First you will need to go to the options menu to the upper right of  your message to unmark it as the solution.


 

0 Kudos
Message 6 of 9
(3,177 Views)

Lynn,

 

I am just pleased it works at all. I can certainly live with a second or two delay. Now that I have something working it will be a lot more enjoyable trying different things to see what happens.

 

Dan

0 Kudos
Message 7 of 9
(3,168 Views)

Hi Lynn,

Can you please post your VI in LabVIEW 2009?

 

Regards,

Srikrishna.J

Regards,
Srikrishna


0 Kudos
Message 8 of 9
(3,154 Views)

Here it is. When saving for previous versions it generated warnings about polymorphic VIs. So you may need to make some adjustments. I did not test it in an older version.

 

Lynn

0 Kudos
Message 9 of 9
(3,147 Views)