Coder Social home page Coder Social logo

Comments (7)

ryanheise avatar ryanheise commented on May 25, 2024 1

That's a fair approximation, RMS would be more accurate.

from just_waveform.

ryanheise avatar ryanheise commented on May 25, 2024

I would suggest computing the RMS. If you google that you should find some helpful tutorials and explanations.

from just_waveform.

zjjt avatar zjjt commented on May 25, 2024

The rms ok ...I was able to get the waveform now onto the rms. thanks

from just_waveform.

zjjt avatar zjjt commented on May 25, 2024

Hello @ryanheise , Please help/hear me out, thanks for the great package..i've been looking for solutions for this since 2 days..now with your help i know that i am close .i am not knowledgeable enough in sound engineering and i dont know if it is right to post this here but... i was able to calculate the RMS value of the waveform.data list of ints with this method:

double _rmsValueOfList(List<int> list, int n) {
    num square = 0;
    double mean = 0.0, root = 0.0;
    for (int i = 0; i < n; i++) {
      square += pow(list[i], 2);
    }
    mean = square / n;
    root = sqrt(mean);
    return root;
  }

the value i get in return is 4927.386586958856. Does that mean that if i loop through the waveform.data , values below the rms can be considered silences ? Also how can i know the timestamp of the current value in the waveform.data list so that i can issue commands based on the silence detection ? the audio files are voice reading generated mp3s. I have a character which mimics the voice speech...but since i cant yet detect the pauses ,it keeps on mumbling when there is no sound. the audio is read through the audioplayers plugin which allow me to get the current duration(the timestamp) of the current audio being played. i would like to match these timestamps to the silences(pauses) and issue commands to my character so it can shut or open its mouth ...Please assist me...

from just_waveform.

ryanheise avatar ryanheise commented on May 25, 2024

If you read tutorials about RMS, the more you read the more you will understand. In case you didn't realise, you also don't want to compute the RMS of the whole audio, so you'll want to choose a window size. As for timestamps, just_waveform gives you the sample rate and the samples per pixel, plus you have your own window size. Combining all of those you should be able to figure out timestamps. You can see an example of this sort of calculation in the Waveform.positionToPixel method.

But I generally don't give that sort of advice here, so please keep reading more about it and you will figure it out.

from just_waveform.

zjjt avatar zjjt commented on May 25, 2024

@ryanheise Thanks ... this is more than enogh already to get me going on the right track...thanks again

from just_waveform.

zjjt avatar zjjt commented on May 25, 2024

@ryanheise Just wanted to give you a huge shout out for the tips and the time. positionToPixel method did the trick for my use case. I was able to compare the values with a certain threshold to figure out how to detect silences and i didn't have to calculate RMS. Here is the code for future reference

player.onPositionChanged.listen((Duration p) {
            final currentMaxPixelAtPosition =
                waveform?.getPixelMax(waveform.positionToPixel(p).toInt());
            if (_isSilence(currentMaxPixelAtPosition!, -100)) {
              leoCurrentState = LeoState.talk;
            } else {
              leoCurrentState = LeoState.stopTalking;
            }
          });

bool _isSilence(int currentMaxPixelAtPosition, double silenceThreshold) {
    return currentMaxPixelAtPosition < silenceThreshold;
  }

from just_waveform.

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.