kandi background
Explore Kits

audiowaveform | C program to generate waveform data and render waveform images from audio files | Audio Utils library

 by   bbc C++ Version: 1.4.2 License: GPL-3.0

 by   bbc C++ Version: 1.4.2 License: GPL-3.0

Download this library from

kandi X-RAY | audiowaveform Summary

audiowaveform is a C++ library typically used in Audio, Audio Utils applications. audiowaveform has no bugs, it has no vulnerabilities, it has a Strong Copyleft License and it has medium support. You can download it from GitHub.
C++ program to generate waveform data and render waveform images from audio files
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • audiowaveform has a medium active ecosystem.
  • It has 1206 star(s) with 172 fork(s). There are 74 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 36 open issues and 70 have been closed. On average issues are closed in 210 days. There are 5 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of audiowaveform is 1.4.2
audiowaveform Support
Best in #Audio Utils
Average in #Audio Utils
audiowaveform Support
Best in #Audio Utils
Average in #Audio Utils

quality kandi Quality

  • audiowaveform has 0 bugs and 0 code smells.
audiowaveform Quality
Best in #Audio Utils
Average in #Audio Utils
audiowaveform Quality
Best in #Audio Utils
Average in #Audio Utils

securitySecurity

  • audiowaveform has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • audiowaveform code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
audiowaveform Security
Best in #Audio Utils
Average in #Audio Utils
audiowaveform Security
Best in #Audio Utils
Average in #Audio Utils

license License

  • audiowaveform is licensed under the GPL-3.0 License. This license is Strong Copyleft.
  • Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.
audiowaveform License
Best in #Audio Utils
Average in #Audio Utils
audiowaveform License
Best in #Audio Utils
Average in #Audio Utils

buildReuse

  • audiowaveform releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
audiowaveform Reuse
Best in #Audio Utils
Average in #Audio Utils
audiowaveform Reuse
Best in #Audio Utils
Average in #Audio Utils
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

audiowaveform Key Features

C++ program to generate waveform data and render waveform images from audio files

Ubuntu

copy iconCopydownload iconDownload
$ sudo add-apt-repository ppa:chris-needham/ppa
$ sudo apt-get update
$ sudo apt-get install audiowaveform

Mac OSX via Homebrew

copy iconCopydownload iconDownload
$ brew tap bbc/audiowaveform
$ brew install audiowaveform

Docker

copy iconCopydownload iconDownload
$ docker pull realies/audiowaveform
$ alias awf='docker run --rm -v `pwd`:/tmp -w /tmp realies/audiowaveform'
$ awf -i input.wav -o output.png

Install package dependencies

copy iconCopydownload iconDownload
$ sudo dnf install git make cmake gcc-c++ libmad-devel \
  libid3tag-devel libsndfile-devel gd-devel boost-devel

Obtain the source code

copy iconCopydownload iconDownload
$ git clone https://github.com/bbc/audiowaveform.git
$ cd audiowaveform

Install Google Test test framework

copy iconCopydownload iconDownload
$ wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz
$ tar xzf release-1.10.0.tar.gz
$ ln -s googletest-release-1.10.0/googletest googletest
$ ln -s googletest-release-1.10.0/googlemock googlemock

Build

copy iconCopydownload iconDownload
$ mkdir build
$ cd build
$ cmake ..
$ make

Test

copy iconCopydownload iconDownload
$ make test

Install

copy iconCopydownload iconDownload
$ sudo make install

Run

copy iconCopydownload iconDownload
$ audiowaveform --help

Examples

copy iconCopydownload iconDownload
$ audiowaveform -i test.mp3 -o test.dat -z 256 -b 8

How to get audio peaks with FFmpeg?

copy iconCopydownload iconDownload
sudo add-apt-repository ppa:chris-needham/ppa
sudo apt-get update
sudo apt-get install audiowaveform
brew tap bbc/audiowaveform
brew install audiowaveform
audiowaveform -i /root/audio.mp3 --pixels-per-second 100 --output-format json -
import {exec} from "child_process";

export default function getAudioWaveform(filename, blockSize = 100) {
    return new Promise((resolve, reject) => {
        const command = `audiowaveform -i ${filename} --pixels-per-second ${blockSize} --output-format json -`;

        exec(command, (error, stdout, stderr) => {
            if (error) reject(error, stderr);

            try {
                const data = JSON.parse(stdout).data.filter((_, i) => i % 2 === 1)

                const waveform = [];
                for (let i = 0; i < data.length; i++)
                    waveform[i] = Math.round(data.slice(i * 100, (i + 1) * 100).reduce((s, n) => s + n, 0) / 100);

                resolve(waveform);
            } catch (ex) {
                reject(ex);
            }
        });
    })
}
-----------------------
sudo add-apt-repository ppa:chris-needham/ppa
sudo apt-get update
sudo apt-get install audiowaveform
brew tap bbc/audiowaveform
brew install audiowaveform
audiowaveform -i /root/audio.mp3 --pixels-per-second 100 --output-format json -
import {exec} from "child_process";

export default function getAudioWaveform(filename, blockSize = 100) {
    return new Promise((resolve, reject) => {
        const command = `audiowaveform -i ${filename} --pixels-per-second ${blockSize} --output-format json -`;

        exec(command, (error, stdout, stderr) => {
            if (error) reject(error, stderr);

            try {
                const data = JSON.parse(stdout).data.filter((_, i) => i % 2 === 1)

                const waveform = [];
                for (let i = 0; i < data.length; i++)
                    waveform[i] = Math.round(data.slice(i * 100, (i + 1) * 100).reduce((s, n) => s + n, 0) / 100);

                resolve(waveform);
            } catch (ex) {
                reject(ex);
            }
        });
    })
}
-----------------------
sudo add-apt-repository ppa:chris-needham/ppa
sudo apt-get update
sudo apt-get install audiowaveform
brew tap bbc/audiowaveform
brew install audiowaveform
audiowaveform -i /root/audio.mp3 --pixels-per-second 100 --output-format json -
import {exec} from "child_process";

export default function getAudioWaveform(filename, blockSize = 100) {
    return new Promise((resolve, reject) => {
        const command = `audiowaveform -i ${filename} --pixels-per-second ${blockSize} --output-format json -`;

        exec(command, (error, stdout, stderr) => {
            if (error) reject(error, stderr);

            try {
                const data = JSON.parse(stdout).data.filter((_, i) => i % 2 === 1)

                const waveform = [];
                for (let i = 0; i < data.length; i++)
                    waveform[i] = Math.round(data.slice(i * 100, (i + 1) * 100).reduce((s, n) => s + n, 0) / 100);

                resolve(waveform);
            } catch (ex) {
                reject(ex);
            }
        });
    })
}
-----------------------
sudo add-apt-repository ppa:chris-needham/ppa
sudo apt-get update
sudo apt-get install audiowaveform
brew tap bbc/audiowaveform
brew install audiowaveform
audiowaveform -i /root/audio.mp3 --pixels-per-second 100 --output-format json -
import {exec} from "child_process";

export default function getAudioWaveform(filename, blockSize = 100) {
    return new Promise((resolve, reject) => {
        const command = `audiowaveform -i ${filename} --pixels-per-second ${blockSize} --output-format json -`;

        exec(command, (error, stdout, stderr) => {
            if (error) reject(error, stderr);

            try {
                const data = JSON.parse(stdout).data.filter((_, i) => i % 2 === 1)

                const waveform = [];
                for (let i = 0; i < data.length; i++)
                    waveform[i] = Math.round(data.slice(i * 100, (i + 1) * 100).reduce((s, n) => s + n, 0) / 100);

                resolve(waveform);
            } catch (ex) {
                reject(ex);
            }
        });
    })
}

Community Discussions

Trending Discussions on audiowaveform
  • How to get audio peaks with FFmpeg?
Trending Discussions on audiowaveform

QUESTION

How to get audio peaks with FFmpeg?

Asked 2020-Sep-02 at 20:04

I am working on a music app and need to generate audio spectrum for my files. Like this one:

enter image description here

So I tried using audiowaveform like this:

audiowaveform -i music.mp3 --pixels-per-second 1 -o out.dat

which gives me the following results[correct results]: [the first 10 words are meta data]

0000000 0001 0000 0000 0000 bb80 0000 bb80 0000
0000020 00f9 0000 df3e 1fa2 e22c 1ef3 e0bb 1e5a
0000040 e099 1e88 dfcf 1c33 e29f 1d4c e055 1f80
0000060 df63 1e3a e1b4 1f31 e271 1d81 e0e5 1b1c
0000100 e06d 1be4 dee2 1cb0 e118 1da1 e026 1dea
0000120 e055 1dac df9b 1dbf e0c3 2063 ded4 21b2
0000140 dec9 1f8d de5b 20c8 e02d 216a dd7e 21af
0000160 dea1 20ac de6c 2170 de80 1e12 de6f 1fb9
0000200 dde3 2106 e0d9 21be de88 218c de81 1f9f
0000220 decb 20ff deb2 1edc df32 20c4 dde7 ...

But when I do this kind of job with FFmpeg:

ffmpeg -y -i music.mp3 -acodec pcm_s16le -f s16le -ac 1 -ar 1 -v quiet out.pcm

that gives the following results, which is not same at all:

0000000 0001 fffe fffe fffe 0000 ffff fffd 0000
0000020 ffff ffff fffe 0001 0001 fffd 0001 fffe
0000040 0002 fffe fffc 0002 ffff fffc fffe 000b
0000060 0007 fffb 0004 0001 ffff fffd ffff 0002
0000100 0008 0006 fffe ffff 0001 0000 0003 000a
0000120 fffd ffff 0004 ffff 0001 ffff fffd ffff
0000140 fffe ffff 0001 fffd fffe 0000 fffb 0002
0000160 0002 0000 fffe 0000 fffb fffe fffe 0000
0000200 ffff 0000 ffff fffc 0002 0003 0005 0003
0000220 0002 fffb fffb fffa fffa 0004 0009 ...

You may wonder that why am i doing -ar 1 or --pixels-per-second 1? This is because I want to draw a line for each second, so I need to get peak for each second. . I don't know what am I missing there but I expect to get the same results from FFmpeg.

ANSWER

Answered 2020-Sep-02 at 20:04

This is not a solution with FFMPEG, but still results with a wave form array.

My solution was to use the audiowaveform linux package which has a simple cli to extract the waveform data with the desired sample rate.

You can install it on ubuntu like:

sudo add-apt-repository ppa:chris-needham/ppa
sudo apt-get update
sudo apt-get install audiowaveform

Or on macOS with homebrew like:

brew tap bbc/audiowaveform
brew install audiowaveform

First I used the provided command in the question to draw the waveform but it was inaccurate and dirty. Because it takes one sample from each second which is not what I was looking for. So I decided to take 100 samples from each second and get the average with some JS code. So the command to extract the wave form will be:

audiowaveform -i /root/audio.mp3 --pixels-per-second 100 --output-format json -

This will output the audio wave form data along with some metadata on the stdout (That hyphen at the end does the trick). So in my case I used NodeJs to get this output and reduce the waveform array to the average of waveform blocks. Note that I removed the negative numbers from the waveform to work on the upper half of the waveform.

import {exec} from "child_process";

export default function getAudioWaveform(filename, blockSize = 100) {
    return new Promise((resolve, reject) => {
        const command = `audiowaveform -i ${filename} --pixels-per-second ${blockSize} --output-format json -`;

        exec(command, (error, stdout, stderr) => {
            if (error) reject(error, stderr);

            try {
                const data = JSON.parse(stdout).data.filter((_, i) => i % 2 === 1)

                const waveform = [];
                for (let i = 0; i < data.length; i++)
                    waveform[i] = Math.round(data.slice(i * 100, (i + 1) * 100).reduce((s, n) => s + n, 0) / 100);

                resolve(waveform);
            } catch (ex) {
                reject(ex);
            }
        });
    })
}

Source https://stackoverflow.com/questions/62242044

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install audiowaveform

If you have not already done so, you should follow the instructions here to add the RPM Fusion free repository. For example, for CentOS 7:.
audiowaveform uses Google Test for unit testing. Following this advice in the Google Test FAQ, download the source and unzip:.
The default build type is Release. To build in Debug mode add -D CMAKE_BUILD_TYPE=Debug to the cmake command above:.
By default this installs the audiowaveform program in /usr/local/bin, and man pages in /usr/local/share/man. To change these locations, add a -D CMAKE_INSTALL_PREFIX=... option when invoking cmake above.

Support

If you'd like to contribute to audiowaveform, please take a look at our contributor guidelines.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with audiowaveform
Compare Audio Utils Libraries with Highest Support
Compare Audio Utils Libraries with Highest Quality
Compare Audio Utils Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.