Ruby gem that provides access to audio waveform data files generated by audiowaveform
Find a file
Chris Needham e5f99ec098
All checks were successful
ci/woodpecker/push/build/2 Pipeline was successful
ci/woodpecker/push/build/6 Pipeline was successful
ci/woodpecker/push/build/3 Pipeline was successful
ci/woodpecker/push/build/5 Pipeline was successful
ci/woodpecker/push/build/4 Pipeline was successful
ci/woodpecker/push/build/1 Pipeline was successful
Added CI status badge to README.md
2025-08-23 13:31:34 +01:00
.woodpecker Added Woodpecker CI config 2025-08-23 13:29:38 +01:00
lib Version 1.0.7 2020-03-20 16:08:50 +00:00
spec Removed use of Dir::Tmpname.make_tmpname 2019-10-23 17:18:11 +01:00
.travis.yml Update Bundler for Travis CI 2020-03-20 16:05:41 +00:00
audio_waveform-ruby.gemspec Updated dependencies 2025-08-23 11:55:09 +01:00
CHANGELOG.md Added contributor guidelines 2025-08-23 10:52:43 +01:00
CONTRIBUTING.md Added contributor guidelines 2025-08-23 10:52:43 +01:00
COPYING Initial import 2013-10-14 19:57:31 +01:00
Gemfile Initial import 2013-10-14 19:57:31 +01:00
Gemfile.lock Added Woodpecker CI config 2025-08-23 13:29:38 +01:00
Rakefile Initial import 2013-10-14 19:57:31 +01:00
README.md Added CI status badge to README.md 2025-08-23 13:31:34 +01:00

audio_waveform-ruby

status-badge Gem Version

The audio_waveform-ruby gem provides a Ruby API for access to audio waveform data files generated by the audiowaveform program.

Refer to the audiowaveform documentation for more information and this page for file format details.

Installation

To install:

$ gem install audio_waveform-ruby

or, if using bundler, add this line to your application's Gemfile:

gem 'audio_waveform-ruby', :require => 'audio_waveform'

or, to use the latest code from the GitHub repository:

gem 'audio_waveform-ruby', :require => 'audio_waveform',
    :git => 'https://codeberg.org/chrisn/audio_waveform-ruby.git'

and run

$ bundle install

Usage

To use this Gem in your program, add:

require 'audio_waveform'

Then, to load and use data from an existing waveform data file:

waveform = AudioWaveform::WaveformDataFile.new(filename: "test.dat")

puts waveform.sample_rate       # Returns audio sample rate, in Hz
puts waveform.bits              # Returns resolution of waveform data points
puts waveform.samples_per_pixel # Returns waveform zoom level, in samples per pixel
puts waveform.size              # Returns number of waveform data points

(0...waveform.size).each do |i|
  puts waveform.min_sample(i)   # Returns waveform minimum at index i
  puts waveform.max_sample(i)   # Returns waveform maximum at index i
end

To generate a binary representation of a waveform data file:

waveform = AudioWaveform::WaveformDataFile.new(filename: "test.dat")
data = waveform.to_binary

To save waveform data as a file in binary format:

waveform = AudioWaveform::WaveformDataFile.new(filename: "test.dat")
waveform.save_as_binary("output.dat")

To generate a JSON representation of a waveform data file:

waveform = AudioWaveform::WaveformDataFile.new(filename: "test.dat")
waveform.to_json

To save waveform data as a file in JSON format:

waveform = AudioWaveform::WaveformDataFile.new(filename: "test.dat")
waveform.save_as_json("output.json")

To create a new waveform data file:

waveform = AudioWaveform::WaveformDataFile.new(
    sample_rate: 44100,
    samples_per_pixel: 512,
    bits: 8
)

waveform.append(-10, 10)
        .append(-11, 11)
        .append(-3, 3)
# etc

License

See COPYING for details.

Contributing

If you'd like to contribute to audio_waveform-ruby, please take a look at the contributor guidelines.

If you have a feature request or want to report a bug, we'd be happy to hear from you. Please either raise an issue, or fork the project and send us a pull request.

Authors

This software was written by Chris Needham.

Copyright 2025 Chris Needham