Skip to content

benallfree/wavesurfer-peakbuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wavesurfer-peakbuilder

This package prebuilds peaks for wavesurfer.js.

By default, wavesurfer must use XHR to download an audio fully before it can draw peaks. Wavesurfer accepts an optional array of precalculated peaks and will use these instead of downloading the complete audio file if the array is supposed. The audiowaveform tool can be used to build peaks, but its output is not compatible with wavesurfer. This package solves everything by using audiowaveform to build peaks and output them in a wavesurfer-compatible array.

For a more practical example that uses this package, see gulp-wavesurfer-peakbuilder.

yarn add wavesurfer-peakbuilder --dev

Usage

wavesurfer-peakbuilder requires local access to the audio file. This is necessary so it can prebuild peaks.

import peakbuilder from 'wavesurfer-peakbuilder'

peakbuilder('./path/to/audio.mp3').resolve( (peaks) => {
  console.log(peaks);
}).reject((err)=>{
  console.log(err);
});

Example peaks array:

[0.0104,0.0794,0.1061,0.1082,0.1768,0.2746,0.2694,0.1862,0.3599,0.1484,0.4223,0.4424,0.2493,0.4375,0.4178,0.3509,0.3391,0.2226,0.0423,0.087,0.2732,0.3682,0.4185,0.2566,0.2742,0.4708,0.4507,0.423,0.4112,0.3949,0.5585,0.4705,0.3724,0.3204,0.3925,0.1907,0.0659,0.0895,0.431,0.4171,0.4161,0.3443,0.2777,0.3668,0.3724,0.4483,0.3946,0.3412,0.2441,0.2174,0.3245,0.3419,0.2711,0.2378,0.2046,0.3828,0.3464,0.3398,0.3713,0.4396,0.4365,0.2583,0.371,0.3835,0.5045,0.3894,0.1695,0.1772,0.1061,0.1207,0.0704,0.0752,0.1456,0.0534,0.1643,0.4604,0.3727,0.3325,0.3415,0.4618,0.3973,0.3183,0.3377,0.3627,0.2912,0.3242,0.5901,0.6341,0.4684,0.4258,0.4615,0.4583,0.39,0.3044,0.3176,0.4639,0.3107,0.1896,0.1349,0.1044,0.0801,0.0749,0.1158,0.4427,0.2905,0.2656,0.4684,0.5655,0.2836,0.2905,0.5533,0.4698,0.3575,0.1695,0.1914,0.4427,0.39,0.1664,0.0784,0.1914,0.449,0.4067,0.4296,0.2545,0.1349,0.3828,0.3824,0.2094,0.2032,0.1494,0.1144,0.1016,0.1259,0.0877,0.07,0.1668,0.5585,0.5121,0.4018,0.2805,0.3956,0.4514,0.432,0.2756,0.0676,0.3443,0.3796,0.2132,0.1044,0.0239,0.1858,0.1404,0.5429,0.4226,0.3235,0.3817,0.4247,0.4896,0.4965,0.4414,0.5135,0.587,0.5235,0.2798,0.1865,0.1519,0.3526,0.3658,0.2122,0.2139,0.0426,0.0142,0.0437,0.0756,0.0302,0.0929,0.3169,0.5149,0.4102,0.3696,0.3505,0.3131,0.2462,0.2257,0.5384,0.3991,0.44,0.4764,0.3928,0.2853,0.1997,0.1297,0.0908,0.1987,0.146,0.0953,0.1432,0.3238,0.5294,0.4483,0.4927,0.4792,0.4847,0.4792,0.3093,0.2392,0.1942,0.4164,0.4157,0.3297,0.2819,0.2073,0.1796,0.1841,0.2039,0.1383,0.1061,0.2344,0.4178,0.4629,0.4875,0.4213,0.4479,0.4421,0.3554,0.2396,0.1751,0.2531,0.4601,0.3186,0.2427,0.0981,0.0392,0.1369,0.0898,0.0371,0.0139,0.2347,0.4733,0.5478,0.5228,0.4854,0.4792,0.3887,0.3207,0.3346,0.2846,0.2198,0.389,0.2954,0.1976,0.1148,0.0579,0.0316,0.0628,0.0815,0.0343,0.2129,0.3848,0.3699,0.3193,0.2971,0.2521,0.2475,0.3103,0.3887,0.3037,0.2222,0.2389,0.2229,0.1834,0.1536,0.1082,0.0673,0.0371,0.0156,0.0128,0.1578,0.2829,0.3276,0.2916,0.241,0.1869,0.1383,0.2313,0.1373,0.0967,0.1553,0.1311,0.122,0.1026,0.0947,0.0763,0.0603,0.0482,0.0302,0.0191,0.0142,0.0073,0,0,0,0,0,0,0,0,0]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published