# LabVIEW

cancel
Showing results for
Did you mean:

Highlighted

## record sound and convert it to a square wave

Hi,

I need to record a sound for say 3 seconds and convert it to a square wave so that i can later modulate it. Can you please help me on this?

Please find the attached block dig.

Message 1 of 4
(562 Views)
Highlighted

## Re: record sound and convert it to a square wave

Your while loop makes no sense, because all you get when it is terminated is the data from the last iteration (3 seconds). You might as well remove it. Building digital data into an array containing one such element does not really add any useful information.

I don't think you are using the correct tools ("digital" does not mean square wave), but it's not really clear want you want to do. We probably would need to understand the logic, math, and reasoning behind the experiment.

Is there a web site that explain your "sound>square wave>modulation" scheme? What are you trying to get out of it?

LabVIEW Champion. It all comes together in GCentral
What does "Engineering Redefined" mean??
Message 2 of 4
(524 Views)
Highlighted

## Re: record sound and convert it to a square wave

The exact experiment is to record a sound and modulate it using BPSK.

Solution: So what BPSK requires as source is a series of binary bits. Corresponding to whether the bit is a "1" or a "0", we transmit sin(wt) or -sin(wt) which is equivalent to saying that we can map "0" to -1 Volt and "1" as 1 volt (which is a equivalent to a square wave range -1V to 1V) and multiply this wave with a sin(wt) wave hence i can get a desired BPSK modulated waveform.

problem: I have quantized the recorded signal using 16 bit encoding per sample (via analog to digital block)ie: suppose 22k samples per second and i am taking samples for 3 seconds that is a total of 66k samples and each sample represented by 16 bits it becomes a matrix of binary data of size 66k x 16. now i want to do the above mentioned mapping of this matrix to a square wave of range -1V to 1V

Message 3 of 4
(495 Views)
Highlighted

## Re: record sound and convert it to a square wave

Hi Yatin,

what have you tried so far?

There is "Number to boolean array" to convert any (integer) number into a boolean array. This way you can convert your waveform sample data to "bits".

There is a Select function to select one of two values based on a boolean input. You could use it to select either +1 or -1 based on your "bit".

You need a loop to iterate over all samples of your waveform.

This way you will get an integer array of ±1 values.

Now all you need is to apply your BPSK algorithm…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 4 of 4
(486 Views)