From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Multiply an Array with a Constant for Audio Purposes

Solved!
Go to solution

Hi,

 

I'm a Student in Electronics, and i have to make an Audio Equalizer for .wav files for a Project.

Im in 2nd year, and this is'nt my Main project at all, so i don't need a "good" program. Just something who works more or less.

I don't have much time for doing this, so i apologize if this is a basic problem, the searchs i've done so far give me old topics or were too specific.

 

I have LabView 15 and i don't have MyDAQ

 

I've thought about a defined number of Bandpass Filter in parrallel,  of which i could control the volume (because so far i di'nt find any Resonator filters) for controlling Frequency areas. Also thought about adding one lowpass and one Highpass filter behind that, but i'm not there yet.

 

But i can't manage to change the volume..

 

I've got a setup pretty much like this : https://www.youtube.com/watch?v=ChSVf9lZ44k jump to 5:10.

 

The guy here is trying to reverse the sound. I would like to lower the volume by manipulating the Y data.

 

Would it works? I think so, positive or negative, i will always be dividing by a positive value. But now i fear this is more complex than that.

 

Of course i've tried to divide by a constant, but i get  "number of samples must be >0". which is wierd.

 

I've tried various other thing but so far none worked, either i've get error some not repertoried , either it did'nt changed the volume. either i get error ,some not repertoried.

 

The way i thought would be to build an array of the size of the Y array with every element being the constant. But it does'nt change the volume.

 

Thanks for any help

 

 

 

 

 

0 Kudos
Message 1 of 7
(3,977 Views)

@Kenny_mk wrote:

 

The way i thought would be to build an array of the size of the Y array with every element being the constant. But it does'nt change the volume.

 


Many math functions are polymorphic, meaning they accept multiple data types and try to do what you want based on the input.  If you multiply an array of doubles, by a scalar of a double, it multiply each element in the array by the scalar value.

 

Example_VI.png

Message 2 of 7
(3,961 Views)

Ok so i've understood that "create => Constant" was creating an array of which i had to set every value, giving me the "number of samples" error.

 

I've created a constant separetly , and this seems "to work" in the meaning i get no error. But i've got the same result as when i was creating an array of the size of my Y's Waweform: The volume is'nt changed = (

 

 

Any idea how i can mod the Volume directly in the Y Data?

 

Would FFT be a solution? Changing every ahem "Dirac" (sorry i'm french) by a constant and revert back?

This seems pretty hard to me, i 'll try to do it but i'm not sure if it could work. Would be glad if i could get answers in the meantime.

 

I try to rename the topic, else can i create a new Thread?

0 Kudos
Message 3 of 7
(3,950 Views)

Greetings, I think we would all benefit from some clarification, and most likely that you attached the code to your next post so we can see what you're trying to do. From what I understand you have some Y data that you want to modify to change the volume. This would most likely be accomplished by a local variable of said Y data, that you write with the new values. It is hard to pinpoint it without the code, so here's the basics:

 

-You take the raw Y data, I'm assuming a 1D array of doubles

-You multiply said Y data by a single scalar, that gives you a new 1D array of doubles

-You wire said results to a local variable that references the original Y data, so it overwrites the old info with the modified one

-Alternatively, just create an indicator with the new data and use that as an output.

Message 4 of 7
(3,937 Views)

 

I've erased most of the code i was talking about, so pretty pointless to upload it (i think, not much work there in the end  ; / )

 

Yes i was doing like you said.

 

I had a 2D Array representing my sound in dt and Y. So i was multiplying Y by a Scalar,  and wire it in a new waveform. I was also wiring the dt unchanged.

 

Then the Waweform was wired to the express VI "Read WaveForm"

 

The program was working, but the volume was unchanged.

I think this might be due to the express VI "Read WaveForm"

 

Anyways i now use Classic VIs

(File Format => Configure sound => Volume configure => Write /!\ Data come in here => Wait => Erase

which allow me to control Volume in a much easier way

 

BUT

 

As i write this i realise i might not be able to control volume separatly of different filtered Signals Which is what i planned to do for "EQ ing", since i will not be able to tell my SoundCard to write multiple Sound at once.

 

I need to revert back to the old way and see if this can get fixed.(9pm though so lunch-time)   😕 Got others problems also (can't fusion 2 signal correctly result is highly pitched and/or by ear i can tell the frequency are wrong).

 

Thanks for Help

0 Kudos
Message 5 of 7
(3,921 Views)
Solution
Accepted by topic author Kenny_mk

Hi Kenny,

 

I had a 2D Array representing my sound in dt and Y.

Why do you need a 2D array for this?

Waveforms are clusters containing dt and T0 scalars and an Y 1D array…

 

- volume is changed by multiplying your Y data.

- adding waveforms is only simple as long as both have the same dt - everything else can result in your "pitch" problems

 

Again:

Provide a VI and provide some example data to illustrate your problem!

Anything else is just looking into glass balls!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(3,913 Views)

Sooo it does work, i don't know where i was wrong.. The fact that you tell me this is the way to go, i've make  it again and now it work. For me it's the exact same thing except i use Classic VI, not the express Read WaveForm.

 

I haven't think about Clusters being involved. Thanks for pointing out the difference.

 

Still i have to merge signal now. And in the precedent VI, my 2 signals were the same .Wav filtered on different frequency range. So i have'nt look about mathematics but DT should be the same.

 

I've attached the file still.

 

Thanks for your help = )

0 Kudos
Message 7 of 7
(3,901 Views)