Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lsegal/easy_audio
EasyAudio is a simplified Ruby wrapper for the portaudio library.
https://github.com/lsegal/easy_audio
Last synced: 2 months ago
JSON representation
EasyAudio is a simplified Ruby wrapper for the portaudio library.
- Host: GitHub
- URL: https://github.com/lsegal/easy_audio
- Owner: lsegal
- License: bsd-3-clause
- Created: 2014-09-22T03:10:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-18T00:05:48.000Z (about 10 years ago)
- Last Synced: 2024-05-02T05:33:31.386Z (8 months ago)
- Language: Ruby
- Size: 148 KB
- Stars: 22
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EasyAudio
[![Gem Version](https://badge.fury.io/rb/easy_audio.svg)](http://badge.fury.io/rb/easy_audio)
EasyAudio is a simplified wrapper for the [portaudio][portaudio] library, which
allows to you play or record audio directly from your sound card.## Installing
```sh
$ gem install easy_audio
```Note: if you are on a Linux or Windows machine you will need to manually
install portaudio to a location in your library paths. The gem will attempt
to install this automatically on OS X through [Homebrew][brew].## Usage
Here's how you can easily play a sine wave at 440hz:
```ruby
require 'easy_audio'EasyAudio.easy_open(&EasyAudio::Waveforms::SINE)
sleep 2 # play for 2 seconds
```Play a custom waveform (a cosine wave):
```ruby
require 'easy_audio'EasyAudio.easy_open { Math.cos(Math::PI * 2 * step) }
sleep 1
```Here's a triangle wave that increases its frequency over 3 seconds:
```ruby
require 'easy_audio'stream = EasyAudio.easy_open(freq: 220, &EasyAudio::Waveforms::TRIANGLE)
Thread.new { loop { stream.frequency += 50; sleep 0.2 } }
sleep 3
```Record audio from your microphone and play it back a second later:
```ruby
require 'easy_audio'EasyAudio.easy_open(in: true, out: true, latency: 1.0) { current_sample }
sleep 10 # for 10 seconds
```## Documentation
See the API documentation on [rubydoc.info][docs].
## License
EasyAudio is copyright © 2014 by Loren Segal and licensed under the BSD
license. See the LICENSE file for more information.[portaudio]: http://portaudio.com
[brew]: http://brew.sh
[docs]: http://rubydoc.info/gems/easy_audio/frames