Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is peak and how to Generate? #1172

Closed
smohammedyasin opened this issue Jul 19, 2017 · 6 comments
Closed

What is peak and how to Generate? #1172

smohammedyasin opened this issue Jul 19, 2017 · 6 comments
Labels

Comments

@smohammedyasin
Copy link

Hello,
this is not a bug, this is a question
I'm very new to audio part. i got many questions come in my mind.
1)what is peak?
2)how can i generate peak format data form mp3 using c#
3)Peak data is json array data?

  1. and how can i play large(2 hours) audio while loading.
    Please help me, i'm getting so much confused.
@agamemnus
Copy link
Contributor

  1. The visualization of the audio.
  2. Don't know.
  3. No, it's just numbers in an array. Does not have to be JSON.
  4. You will need to have your audio load in as a stream from your server...

@jurgenwerk
Copy link

Take a look at this issue: #1141

There you have links and resources explaining how to extract peaks and prepare them for wavesurfer. For playing large files before they download entirely, you can try with MediaElement and a server that supports partial byte range requests (I use cloudfront).

@agamemnus
Copy link
Contributor

agamemnus commented Jul 21, 2017

I have also found that large audio files need peak data added in chunks (of their constituent audio data), or there will be memory issues.

@smohammedyasin
Copy link
Author

@agamemnus , @matixmatix is possible to show waveform half section like this site audio mack
and still i'm looking for solution to convert peaks from wav or mp3 :-(

@smohammedyasin
Copy link
Author

smohammedyasin commented Aug 9, 2017

Hello Guy,
Finally i came to use NAudio library to generate peaks using .net(visual studio). this post may help others or get idea to save peaks with mp3 or wav file.


using(var reader = new AudioFileReader(file))
{
    var samples = reader.Length / (reader.WaveFormat.Channels * reader.WaveFormat.BitsPerSample / 8);

    var max = 0.0f;
    // waveform will be a maximum of 4000 pixels wide:
    var batch = (int)Math.Max(40, samples / 4000);
  
    float[] buffer = new float[batch];
    int read;
    
    while((read = reader.Read(buffer,0,batch)) == batch)
    {
        for(int n = 0; n < read; n++)
        {
            max = Math.Max(Math.Abs(buffer[n]), max);
        };
        console.write(max);//peak ex: 0.342424, this can be store in array or .peak file 
      console.write(',');
        max = 0;    
        
    }
}

source link : https://stackoverflow.com/questions/13629277/analyzing-wav-and-drawing-a-graph

@15838028035
Copy link

@smohammedyasin have you slove it ? cloud you share your demo ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants