Project

wavspa

0.0
No commit activity in last 3 years
No release in over 3 years
spectrum analyzer for wav file.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 10.0

Runtime

~> 0.5.4
 Project Readme

wavspa

"wavspa" is a WAV file spectrum analyzer. Includes FFT and wavelet analyzers.

Installation

Add this line to your application's Gemfile:

gem 'wavspa'

And then execute:

$ bundle

Or install it yourself as:

$ gem install wavspa

This application uses OpenMP, but by default tries to link the libgomp. When using another implementation (such as intel OpenMP) with macOS etc, specify the libary path and library name by command line options as follows:

$ gem insatll wavspa -- --with-openmp ~/env/opts/lib --omp-name omp

if you not require OpenMP, specify the folowing option:

$ gem insatll wavspa -- --no-openmp

Usage

FFT analyzer

wavfft [options] WAV-FILE

options:
    -o, --output=FILE
    -p, --preset=NAME
    -a, --amplitude-mode
    -f, --fft-size=SIZE
    -u, --unit-time=MSEC
    -W, --output-width=SIZE
    -w, --window-function=FUNCTION
    -r, --frequency-range=LO,HI
        --floor-gain=DB
        --ceil-gain=DB
        --luminance=NUMBER
    -g, --frequency-grid=BASIS,STEP
    -m, --scale-mode=MODE
    -c, --col-steps=SIZE
        --show-params
    -F, --no-draw-freq-line
    -T, --no-draw-time-line
    -v, --verbose

options

-o, --output
specify the output file name. by default, output to the file that extension of input file changed to ".png".
-p, --preset=NAME
specify preset settings. you can specify one of "default", "32k" or "cd".
-a, --amplitude-mode
When this option is specified, the amplitude spectrum is output (otherwise, the power spectrum is output).
-f, --fft-size=FFT
specify the FFT size (by number of samples, this value must spcify a power of 2).
-u, --unit-time=CS
specify the unit time of short time FFT in centiseconds (1/100 sec). This value is the time per pixel in horizontal direction of the output PNG.
-W, --output-width=SIZE
specify the hight of output PNG (by number of pixels).
-w, --window-function=FUNCTION
specify name of windows function for short time FFT. you can specify one of "RECTANGULAR", "HAMMING", "HANN", "BLACKMAN", "BLACKMAN\_NUTTALL", "FLAT\_TOP".
-r, --frequency-range=LO,HI
specify the frequency band show on the output PNG (upper limit to "HI", and lower limit to "LO").
--floor-gain=DB
specify the upper limit value of the gain to be displayed. values exceeding this number are displayed as saturated. effective only for amplitude mode.
--ceil-gain=DB
specify the lower limit value of the gain to be displayed. values less than this number will be masked. effective only for amplitude mode.
--luminance=NUMBER
specify correction value of luminance for pixel drawing (default is 3.5). effective only for power spectrum mode.
-g, --frequency-grid=BASIS,STEP
specify frequency grid settings. basis frequency to "BASIS" and step value to "STEP". "STEP" is evaluated as a ratio for neighbor grid when the scale mode is LOGSCALE, and as a difference for neighbor grid when LINEARSCALE.
-m, --scale=mode
specify the mode of grid scale in vertical direction of th output PNG. you can specify one of "LOGSCALE" or "LINEARSCALE" (default is "LOGSCALE").
-c, --col-steps=SIZE
specify the horizontal magnify ratio of th output file.
--show-params
show sumarry of settings.
-F, --no-draw-freq-line
disable frequency line (vertical grid).
-F, --no-draw-freq-line
disable time line (horizontal grid).
-v, --verbose
enable verbose mode
-h, --help
show help message

Wavelet analyzer

wavlet [options] WAV-FILE

options:
    -o, --output=FILE
    -p, --preset=NAME
    -s, --sigma=NUMBER
    -a, --amplitude-mode
    -u, --unit-time=CENTISECOND
    -W, --output-width=SIZE
    -r, --frequency-range=LO,HI
        --floor-gain=DB
        --ceil-gain=DB
        --luminance=NUMBER
    -g, --frequnecy-grid=BASIS,STEP
    -m, --scale-mode=STRING
    -c, --col-steps=SIZE
        --show-params
    -F, --no-draw-freq-line
    -T, --no-draw-time-line
    -v, --verbose
-o, --output
specify the output file name. by default, output to the file that extension of input file changed to ".png".
-p, --preset=NAME
specify preset settings. you can specify one of "default" or "cd".
-s, --sigma=FLOAT
specify the sigma value. Increasing this value improves the accuracy but increases the processing load.
-a, --amplitude-mode
When this option is specified, the amplitude spectrum is output (otherwise, the power spectrum is output).
-u, --unit-time=CS
specify the unit time of wavelet stransform in centiseconds (1/100 sec). This value is the time per pixel in horizontal direction of the output PNG.
-W, --output-width=SIZE
specify the hight of output PNG (by number of pixels).
-r, --frequency-range=LO,HI
specify the frequency band show on the output PNG (upper limit to "HI", and lower limit to "LO").
--floor-gain=DB
specify the upper limit value of the gain to be displayed. values exceeding this number are displayed as saturated. effective only for amplitude mode.
--ceil-gain=DB
specify the lower limit value of the gain to be displayed. values less than this number will be masked. effective only for amplitude mode.
--luminance=NUMBER
specify correction value of luminance for pixel drawing (default is 3.5). effective only for power spectrum mode.
-g, --frequency-grid=BASIS,STEP
specify frequency grid settings. basis frequency to "BASIS" and step value to "STEP". "STEP" is evaluated as a ratio for neighbor grid when the scale mode is LOGSCALE, and as a difference for neighbor grid when LINEARSCALE.
-m, --scale=mode
specify the mode of grid scale in vertical direction of th output PNG. you can specify one of "LOGSCALE" or "LINEARSCALE" (default is "LOGSCALE").
-c, --col-steps=SIZE
specify the horizontal magnify ratio of th output file.
--show-params
show sumarry of settings.
-F, --no-draw-freq-line
disable frequency line (vertical grid).
-F, --no-draw-freq-line
disable time line (horizontal grid).
-v, --verbose
enable verbose mode
-h, --help
show help message

Output example

As a sample data, transformed from "Call to Quarters" (https://archive.org/details/CallToQuarters).

FFT

 wavfft -p cd -c 2 -v -o Call_To_Quarters-fft.png Call_To_Quarters.wav

FFT result

Wavelet

 wavlet -p cd -c 2 -v -o Call_To_Quarters-wavelet.png Call_To_Quarters.wav

wavelet result

 wavlet -p cd -c 2 -a --floor-gain -110 -v -o Call_To_Quarters-wavelet2.png Call_To_Quarters.wav

wavelet result

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kwgt/wavspa.

その他

以下のソースコード及びデータを流用しています。各々の開発者の方に感謝いたします。

License

The gem is available as open source under the terms of the MIT License.