peasy-audio
Ruby client for the PeasyAudio API — analyze BPM, calculate bitrate, and convert audio formats. Zero dependencies beyond Ruby stdlib (Net::HTTP, JSON, URI).
Built from PeasyAudio, a comprehensive audio toolkit offering free online tools for analyzing tempo, calculating file sizes, comparing audio formats, and converting between MP3, WAV, FLAC, OGG, and AAC. The site includes in-depth guides on lossless vs. lossy audio encoding, format comparison charts, and a glossary covering concepts from bitrate and sample rate to audio codecs and clipping.
Try the interactive tools at peasyaudio.com — Audio BPM Analyzer, Audio Frequency Calculator, Audio File Size Calculator, and more.
Table of Contents
- Install
- Quick Start
- What You Can Do
- Audio Analysis Tools
- Browse Reference Content
- Search and Discovery
- API Client
- Available Methods
- Learn More About Audio Tools
- Also Available
- Peasy Developer Tools
- License
Install
gem install peasy-audioOr add to your Gemfile:
gem "peasy-audio"Quick Start
require "peasy_audio"
client = PeasyAudio::Client.new
# List available audio tools
tools = client.list_tools
tools["results"].each do |tool|
puts "#{tool["name"]}: #{tool["description"]}"
endWhat You Can Do
Audio Analysis Tools
Digital audio is represented as a series of samples captured at a fixed rate — CD-quality audio uses 44,100 samples per second (44.1 kHz) with 16-bit depth, producing 1,411 kbps of uncompressed data. Lossy codecs like MP3 and AAC reduce this dramatically (128-320 kbps) by discarding inaudible frequencies using psychoacoustic models, while lossless codecs like FLAC compress without any data loss. PeasyAudio provides calculators and analysis tools for understanding these encoding parameters.
| Tool | Slug | Description |
|---|---|---|
| BPM Analyzer | audio-bpm |
Calculate beats per minute for tempo analysis |
| Frequency Calculator | audio-freq |
Compute audio frequency values and wavelengths |
| File Size Calculator | audio-filesize |
Estimate file sizes for different bitrate and duration combinations |
The relationship between sample rate, bit depth, and channels determines the raw data rate of uncompressed audio. CD-quality stereo (44.1 kHz, 16-bit, 2 channels) produces 1,411.2 kbps, while studio-quality recordings at 96 kHz/24-bit stereo generate 4,608 kbps — over 34 MB per minute. Lossy codecs like AAC at 256 kbps achieve roughly 18:1 compression while maintaining transparency (indistinguishable from the original in controlled listening tests).
require "peasy_audio"
client = PeasyAudio::Client.new
# Get the BPM analyzer tool for tempo detection
tool = client.get_tool("audio-bpm")
puts "Tool: #{tool["name"]}" # Audio BPM analyzer name
puts "Description: #{tool["description"]}" # How BPM detection works
# List all available audio tools with pagination
tools = client.list_tools(page: 1, limit: 20)
puts "Total audio tools available: #{tools["count"]}"Learn more: Audio BPM Analyzer · Audio Format Comparison · Convert Between Audio Formats
Browse Reference Content
PeasyAudio includes a comprehensive glossary of audio engineering terminology and practical guides for common workflows. The glossary covers foundational concepts like bitrate (the number of bits processed per second, determining audio quality and file size), sample rate (how many times per second the audio signal is measured), WAV (Microsoft's uncompressed audio container), and FLAC (Free Lossless Audio Codec, the open-source standard for archival-quality audio).
| Term | Description |
|---|---|
| Bitrate | Bits per second — determines audio quality and file size |
| Sample Rate | Samples per second — 44.1 kHz (CD), 48 kHz (video), 96 kHz (hi-res) |
| WAV | Waveform Audio File Format — uncompressed PCM container |
| FLAC | Free Lossless Audio Codec — open-source lossless compression |
The choice between lossy and lossless encoding involves a fundamental trade-off between file size and audio fidelity. Lossy codecs like MP3 and AAC use psychoacoustic models to discard sounds that fall below the human hearing threshold — frequencies masked by louder nearby tones, or ultra-high frequencies above 16 kHz that most adults cannot perceive. Lossless codecs like FLAC and ALAC preserve every sample exactly, achieving typical compression ratios of 50-60% while guaranteeing bit-perfect reconstruction of the original recording.
require "peasy_audio"
client = PeasyAudio::Client.new
# Browse the audio glossary for encoding and format terminology
glossary = client.list_glossary(search: "bitrate")
glossary["results"].each do |term|
puts "#{term["term"]}: #{term["definition"]}"
end
# Read a guide comparing lossless vs lossy audio formats
guide = client.get_guide("audio-format-comparison")
puts "Guide: #{guide["title"]} (Level: #{guide["audience_level"]})"Learn more: Audio Glossary · Audio Format Comparison · Convert Between Audio Formats
Search and Discovery
The API supports full-text search across all content types — tools, glossary terms, guides, use cases, and format documentation. Search results are grouped by content type, making it easy to find the right tool or reference for any audio workflow. Format conversion data covers the full matrix of source-to-target transformations, including quality trade-offs — converting from a lossy format (MP3) to another lossy format (AAC) involves a generation loss as the second encoder cannot recover information discarded by the first.
require "peasy_audio"
client = PeasyAudio::Client.new
# Search across all audio content — tools, glossary, guides, and formats
results = client.search("convert flac")
puts "Found #{results["results"]["tools"].length} tools"
puts "Found #{results["results"]["glossary"].length} glossary terms"
puts "Found #{results["results"]["guides"].length} guides"
# Discover format conversion paths — what can WAV convert to?
conversions = client.list_conversions(source: "wav")
conversions["results"].each do |c|
puts "#{c["source_format"]} -> #{c["target_format"]}"
end
# Get detailed information about a specific audio format
format = client.get_format("wav")
puts "#{format["name"]} (#{format["extension"]}): #{format["mime_type"]}"| Format | Type | Typical Bitrate | Primary Use |
|---|---|---|---|
| MP3 | Lossy | 128-320 kbps | Universal playback, streaming |
| AAC | Lossy | 128-256 kbps | Apple ecosystem, streaming |
| FLAC | Lossless | 800-1400 kbps | Archival, audiophile playback |
| WAV | Uncompressed | 1411 kbps (CD) | Recording, editing, mastering |
Learn more: REST API Docs · All Audio Tools · All Formats
API Client
The client wraps the PeasyAudio REST API using only Ruby standard library — no external dependencies.
require "peasy_audio"
client = PeasyAudio::Client.new
# Or with a custom base URL:
# client = PeasyAudio::Client.new(base_url: "https://custom.example.com")
# List tools with pagination and filters
tools = client.list_tools(page: 1, limit: 10, search: "convert")
# Get a specific tool by slug
tool = client.get_tool("audio-convert")
puts "#{tool["name"]}: #{tool["description"]}"
# Search across all content
results = client.search("convert")
puts "Found #{results["results"]["tools"].length} tools"
# Browse the glossary
glossary = client.list_glossary(search: "mp3")
glossary["results"].each do |term|
puts "#{term["term"]}: #{term["definition"]}"
end
# Discover guides
guides = client.list_guides(category: "audio")
guides["results"].each do |guide|
puts "#{guide["title"]} (#{guide["audience_level"]})"
end
# List file format conversions
conversions = client.list_conversions(source: "wav")
# Get format details
format = client.get_format("wav")
puts "#{format["name"]} (#{format["extension"]}): #{format["mime_type"]}"Available Methods
| Method | Description |
|---|---|
list_tools |
List tools (paginated, filterable) |
get_tool(slug) |
Get tool by slug |
list_categories |
List tool categories |
list_formats |
List file formats |
get_format(slug) |
Get format by slug |
list_conversions |
List format conversions |
list_glossary |
List glossary terms |
get_glossary_term(slug) |
Get glossary term |
list_guides |
List guides |
get_guide(slug) |
Get guide by slug |
list_use_cases |
List use cases |
search(query) |
Search across all content |
list_sites |
List Peasy sites |
openapi_spec |
Get OpenAPI specification |
All list methods accept keyword arguments: page:, limit:, category:, search:.
Full API documentation at peasyaudio.com/developers/. OpenAPI 3.1.0 spec: peasyaudio.com/api/openapi.json.
Learn More About Audio Tools
- Tools: Audio BPM Analyzer · Audio Frequency Calculator · Audio File Size Calculator · All Tools
- Guides: Audio Format Comparison · Convert Between Audio Formats · All Guides
- Glossary: Bitrate · Sample Rate · WAV · FLAC · All Terms
- Formats: All Formats
- API: REST API Docs · OpenAPI Spec
Also Available
| Language | Package | Install |
|---|---|---|
| Python | peasy-audio | pip install "peasy-audio[all]" |
| TypeScript | peasy-audio | npm install peasy-audio |
| Go | peasy-audio-go | go get github.com/peasytools/peasy-audio-go |
| Rust | peasy-audio | cargo add peasy-audio |
Peasy Developer Tools
Part of the Peasy Tools open-source developer ecosystem.
| Package | PyPI | npm | RubyGems | Description |
|---|---|---|---|---|
| peasy-pdf | PyPI | npm | Gem | PDF merge, split, rotate, compress — peasypdf.com |
| peasy-image | PyPI | npm | Gem | Image resize, crop, convert, compress — peasyimage.com |
| peasy-audio | PyPI | npm | Gem | Audio trim, merge, convert, normalize — peasyaudio.com |
| peasy-video | PyPI | npm | Gem | Video trim, resize, thumbnails, GIF — peasyvideo.com |
| peasy-css | PyPI | npm | Gem | CSS minify, format, analyze — peasycss.com |
| peasy-compress | PyPI | npm | Gem | ZIP, TAR, gzip compression — peasytools.com |
| peasy-document | PyPI | npm | Gem | Markdown, HTML, CSV, JSON conversion — peasyformats.com |
| peasytext | PyPI | npm | Gem | Text case conversion, slugify, word count — peasytext.com |
Embed Widget
Embed PeasyAudio widgets on any website with peasy-audio-embed:
<script src="https://cdn.jsdelivr.net/npm/peasy-audio-embed@1/dist/embed.min.js"></script>
<div data-peasyaudio="entity" data-slug="example"></div>Zero dependencies · Shadow DOM · 4 themes (light/dark/sepia/auto) · Widget docs
License
MIT