Skip to content

RSMP/sound

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sound

Gem Version Build Status Coverage Status Dependency Status Code Climate

This Gem is still in alpha! Breaking and changes are expected everywhere!

Cross Platform sound libraries for the Ruby developer

gem install sound

And then in irb or some script:

require 'sound'
device = Sound::Device.new
format = Sound::Format.new
data = Sound::Data.new(format)
data.generate_sine_wave(440, 500, 1)
device.write data
device.close

This will work on both windows and linux. However Linux platforms will need to install the libasound and libasound-dev packages. You may already have these installed.

With some sensible defaults, the previous example can be written in one line:

Sound::Device.new {|d| d.write Sound::Data.new.sine_wave(440, 500, 1)}

More can be seen in examples/example.rb

The three main parts of this gem are Sound::Device, Sound::Format, Sound::Data. That way more platforms can be added easily by interacting with DeviceLibrary. Obviously the only Data object that can be made is a sine wave (albeit two different ways), but that will grow into more data types like midi sequences and data pulled from audio files. As for Format, well that will just be PCM or MIDI for now, but that may evolve too.

Come back for more features in the future including more data types (loading from files, other wave types), more platforms (MacOS is next on the list) and new formats (midi).

About

Cross-platform sound libraries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages