Code Monkey home page Code Monkey logo

Comments (7)

bartolsthoorn avatar bartolsthoorn commented on July 26, 2024

You first Band Pass filter the data and then measure the volume of the new data? I don't see the problem?

from nvdsp.

k3zi avatar k3zi commented on July 26, 2024

Would that work to find the volume of each band? That is if I had 10 bands then I want 10 volumes returned back. By filtering the data you wouldn't have the original anymore and in order to get the volume of each you would have to copy that original data 10 times.

Is there away around that?

from nvdsp.

bartolsthoorn avatar bartolsthoorn commented on July 26, 2024

I guess you're then looking for a spectrum analyser, which can be done with a FFT algorithm. This has not been implemented in NVDSP.

Have you tried copying the data 10 times? They're small buffers anyway and if you measure one band at a time you can free the copied data immediately when you have the volume.

from nvdsp.

 avatar commented on July 26, 2024

Hi Bart,
Hope you would be doing well. Thanks a lot for your support and co-ordination, I really appreciate that. Currently I am working on reverb and echo effect on an audio file. I have read your comments on this issue and tried the Novocaine's sample code in order to achieve a simple delayed effect to mimic echo. I am facing a problem in that there is too much noise. I know I would be doing something wrong so I am sharing my code here with you so you may kindly review it and point out my mistake.

[self.fileReader setReaderBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
       wself.ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
    }];

    [self.fileReader play];
    self.fileReader.currentTime = 0.0;

    //int echoDelay = 11025;
    //float *holdingBuffer = (float *)calloc(16384, sizeof(float));
    [self.audioManager setOutputBlock:^(float *outData, UInt32 numFrames, UInt32 numChannels) {
        //[wself.fileReader retrieveFreshAudio:outData numFrames:numFrames numChannels:numChannels];

        //Grab the play-through audio
        wself.ringBuffer->FetchInterleavedData(outData, numFrames, numChannels);
        float volume = 0.8;
        vDSP_vsmul(outData, 1, &volume, outData, 1, numFrames*numChannels);

        //Seek back, and grab some delayed audio
        wself.ringBuffer->SeekReadHeadPosition(5);
        //wself.ringBuffer->FetchInterleavedData(holdingBuffer, numFrames, numChannels);
        //wself.ringBuffer->SeekReadHeadPosition(echoDelay);

        volume = 0.5;
        //vDSP_vsmul(holdingBuffer, 1, &volume, holdingBuffer, 1, numFrames*numChannels);
        //vDSP_vadd(holdingBuffer, 1, outData, 1, outData, 1, numFrames*numChannels);
    }];

from nvdsp.

bartolsthoorn avatar bartolsthoorn commented on July 26, 2024

Hi @faizankhan1909, thank you for the kind words. First of of all, your code currently has the delay parts commented out, so I think you mean that it makes noise when you actually turn it on?

The first thing I noticed is that you combine a 80% volume and 50% volume channel. This results into 130% which is higher than the allowed 100%. What this means is that if the fetched data contains samples that hit the 1.0f (or -1.0f) mark, you will send out something like 0.8 * 1.0f + 0.5 * 1.0f = 1.3f. Samples above 1.0f or below -1.0f will clip horribly, so that' d generate a lot of noise.

I recommend you try to set volume = 0.2; for the delay instead of the 0.5 right now. If this solves it, that means it was the clipping.

Something else I can think of is that you might need to set the ReadHeadPosition of the ringBuffer back after you grab some delayed audio, but it seems you were already thinking about that. Let me know if this works for you.

from nvdsp.

 avatar commented on July 26, 2024

Hi @bartolsthoorn,
Thank you for the quick response. Sorry I could not reply earlier, as I was too much indulged in some project. Just wanted to tell you that your solution worked perfectly fine. And now there is no noise, furthermore the delayed samples are giving the impact of a surround sound that I wanted to achieve. Thank you once again :)

from nvdsp.

bartolsthoorn avatar bartolsthoorn commented on July 26, 2024

@faizankhan1909 Thanks, that's nice to hear! 👍

from nvdsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.