source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/midi/voice_pool_spec.rb
Ruby
bsd-2-clause
19
master
1,137
RSpec.describe(MB::Sound::MIDI::VoicePool) do let(:midi_file) { MB::Sound::MIDI::MIDIFile.new('spec/test_data/all_notes.mid') } let(:manager) { MB::Sound::MIDI::Manager.new(jack: nil, input: midi_file) } describe '#sample_rate=' do it 'passes sample rate through to GraphNode' do voices = Array.new(3) {...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/mixer_spec.rb
Ruby
bsd-2-clause
19
master
11,150
RSpec.describe(MB::Sound::GraphNode::Mixer) do describe '#initialize' do it 'can create a mixer with no summands' do ss = MB::Sound::GraphNode::Mixer.new([], sample_rate: 48000) expect(ss.sample(800)).to eq(Numo::SFloat.zeros(800)) end it 'can create a mixer from an Array of summands' do ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/buffer_adapter_spec.rb
Ruby
bsd-2-clause
19
master
7,033
RSpec.describe(MB::Sound::GraphNode::BufferAdapter, :aggregate_failures) do describe '#sample' do let(:upstream) { 42.constant } it 'can read more samples than the upstream count' do expect(upstream).to receive(:sample).twice.with(13).and_call_original b = MB::Sound::GraphNode::BufferAdapter.new(...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/resample_spec.rb
Ruby
bsd-2-clause
19
master
13,885
RSpec.describe(MB::Sound::GraphNode::Resample, :aggregate_failures) do # Compensate for lag by skipping leading zeroes and then selecting as many # whole wave cycles as possible. If there are no zero crossings, then only # zero-skipping is applied. def select_whole_cycles(resampled, reference) resampled = ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/tee_spec.rb
Ruby
bsd-2-clause
19
master
5,509
RSpec.describe(MB::Sound::GraphNode::Tee, aggregate_failures: true) do it 'can be created' do a, b = 123.hz.tee expect(a).to be_a(MB::Sound::GraphNode::Tee::Branch) expect(b).to be_a(MB::Sound::GraphNode::Tee::Branch) end it 'can create more than two branches' do branches = 123.hz.tee(5) expe...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/complex_node_spec.rb
Ruby
bsd-2-clause
19
master
2,286
RSpec.describe(MB::Sound::GraphNode::ComplexNode, :aggregate_failures) do describe '#sample' do test_values = { Numo::SComplex[1, -1i, 0.5+0.5i, 0] => { real: Numo::SFloat[1, 0, 0.5, 0], imag: Numo::SFloat[0, -1, 0.5, 0], abs: Numo::SFloat[1, 1, Math.sqrt(2) / 2, 0], arg: Num...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/reverb_spec.rb
Ruby
bsd-2-clause
19
master
493
RSpec.describe(MB::Sound::GraphNode::Reverb) do it 'has feedback sources if show_internals is true' do # Using fewer channels and stages to reduce the exponential path explosion that causes warnings about infinite loops expect(100.hz.reverb(channels: 2, stages: 1, show_internals: true).graph_edges(feedback: t...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/graph_node_array_mixin_spec.rb
Ruby
bsd-2-clause
19
master
750
RSpec.describe(MB::Sound::GraphNode::GraphNodeArrayMixin) do # More tests in the GraphNodeInput spec it 'adds the as_input method to Arrays' do expect([]).to respond_to(:as_input) end describe '#as_input' do it 'raises an error if the array is empty' do expect { [].as_input }.to raise_error(/Grap...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/multiplier_spec.rb
Ruby
bsd-2-clause
19
master
10,095
RSpec.describe(MB::Sound::GraphNode::Multiplier, aggregate_failures: true) do describe '#initialize' do it 'can create a multiplier with no multiplicands' do ss = MB::Sound::GraphNode::Multiplier.new([], sample_rate: 48000) expect(ss.sample(800)).to eq(Numo::SFloat.ones(800)) end it 'can crea...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/constant_spec.rb
Ruby
bsd-2-clause
19
master
3,442
RSpec.describe(MB::Sound::GraphNode::Constant) do let(:c123) { MB::Sound::GraphNode::Constant.new(123, sample_rate: 48000) } let(:c123i45) { MB::Sound::GraphNode::Constant.new(123+45i, sample_rate: 44100) } it 'returns a constant value forever' do expect(c123.sample(480)).to eq(Numo::SFloat.zeros(480).fill(1...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/midi_dsl_spec.rb
Ruby
bsd-2-clause
19
master
2,472
RSpec.describe(MB::Sound::GraphNode::MidiDsl, aggregate_failures: true) do let(:midi) { MB::Sound.midi_file('spec/test_data/all_notes.mid') } let(:cc) { midi.cc(1) } let(:number) { midi.number } let(:note) { midi.tone } let(:freq) { midi.frequency } let(:bend) { midi.bend } let(:velocity) { midi.velocity ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/proc_node_spec.rb
Ruby
bsd-2-clause
19
master
1,056
RSpec.describe(MB::Sound::GraphNode::ProcNode) do describe '#initialize' do it 'can include extra source nodes' do a = 1.constant.named('A') b = 2.constant.named('B') pn = MB::Sound::GraphNode::ProcNode.new(a, extra_sources: {extra: b}) do |v| v end expect(pn.find_by_name('A...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/quantize_spec.rb
Ruby
bsd-2-clause
19
master
2,001
RSpec.describe(MB::Sound::GraphNode::Quantize, :aggregate_failures) do let (:data1) { MB::Sound::ArrayInput.new(data: Numo::SFloat[0.49, 0.5, 0.51, -0.49, -0.5, -0.51]) } let (:complex_data) { MB::Sound::ArrayInput.new(data: Numo::DComplex[0.49, 0.5i, 0.51, -0.49i, -0.5, -0.51i, -0.25+0.8i]) } it 'can quantize t...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/matrix_mixer_spec.rb
Ruby
bsd-2-clause
19
master
2,180
RSpec.describe(MB::Sound::GraphNode::MatrixMixer) do let(:identity3) { # 3x3 identity matrix Matrix[ [1, 0, 0], [0, 1, 0], [0, 0, 1], ] } let(:matrix3) { # 3x3 mixing matrix Matrix[ [1, 0.5, -0.5], [-0.5, 1, 0.5], [0.5, -0.5, 1], ] } let(:matrix21) {...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/node_sequence_spec.rb
Ruby
bsd-2-clause
19
master
3,157
RSpec.describe(MB::Sound::GraphNode::NodeSequence) do it 'can be constructed by DSL' do seq = 0.hz.square.at(5).for(7.0 / 48000).and_then(0.hz.square.at(4).for(4.0 / 48000), Numo::SFloat[-6, -5, -4]) expect(seq.sample(5)).to eq(Numo::SFloat[5, 5, 5, 5, 5]) expect(seq.sample(5)).to eq(Numo::SFloat[5, 5, 4,...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/wavetable_spec.rb
Ruby
bsd-2-clause
19
master
5,168
RSpec.describe(MB::Sound::GraphNode::Wavetable) do # More tests in spec for MB::Sound::Wavetable let(:data) { Numo::SFloat[[1, -1, 1, 1, -1, -1], [0, 1, -1, 1, 0, -1]] } describe '#initialize' do it 'can create a wavetable node from an NArray' do expect(120.hz.ramp.wavetable(wavetable: data, number: 0....
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/input_channel_split_spec.rb
Ruby
bsd-2-clause
19
master
2,059
RSpec.describe(MB::Sound::GraphNode::InputChannelSplit) do it 'can be created' do l, r = MB::Sound.file_input('sounds/synth0.flac').split expect(l).to be_a(MB::Sound::GraphNode::InputChannelSplit::InputChannelNode) expect(r).to be_a(MB::Sound::GraphNode::InputChannelSplit::InputChannelNode) end it 'c...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/data_shuffler_spec.rb
Ruby
bsd-2-clause
19
master
707
RSpec.describe(MB::Sound::GraphNode::DataShuffler) do describe '#sample' do # 1 in length! (factorial) chance of random failure. Length of 10 is ~1 in 3.6M let(:length) { 15 } let(:input) { (1..length).to_a } let(:ds) { MB::Sound::GraphNode::DataShuffler.new(input.to_a.map { |v| Numo::SFloat[v] }) } ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/nameable_spec.rb
Ruby
bsd-2-clause
19
master
294
RSpec.describe(MB::Sound::GraphNode::Nameable) do let(:obj) { 'Test'.tap { |o| o.extend(MB::Sound::GraphNode::Nameable) } } it 'allows an object to be named' do expect(obj.named?).to eq(false) expect(obj.named(5).named?).to eq(true) expect(obj.name_or_id).to eq('5') end end
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/multitap_delay_spec.rb
Ruby
bsd-2-clause
19
master
2,368
RSpec.describe(MB::Sound::GraphNode::MultitapDelay) do it 'can delay a single tap by a graph constant' do dly = MB::Sound::GraphNode::MultitapDelay.new(5.constant(smoothing: false).named('Const'), 4.constant, sample_rate: 1) tap = dly.taps[0] expect(tap.sample(10)).to eq(Numo::SFloat[0, 0, 0, 0, 5, 5, 5,...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/graph_node/midi_dsl/midi_envelope_spec.rb
Ruby
bsd-2-clause
19
master
584
RSpec.describe(MB::Sound::GraphNode::MidiDsl::MidiEnvelope) do context 'when a MIDI file has ended' do it 'does not cause duplicated envelopes to return nil when sampled' do clock = MB::Sound::MIDI::MIDIFile::ConstantClock.new env = MB::Sound.midi_file('spec/test_data/empty.mid', clock: clock).env ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/biquad_spec.rb
Ruby
bsd-2-clause
19
master
7,471
RSpec.describe(MB::Sound::Filter::Biquad, :aggregate_failures) do let(:f) { MB::Sound::Filter::Biquad.new(0.2, 0.5, -0.3, 0.6, 0.1, sample_rate: 48000) } let(:g) { MB::Sound::Filter::Biquad.from_pole_zero(**f.polezero, sample_rate: 44100) } let(:f_unity) { MB::Sound::Filter::Biquad.new(1, 0, 0, ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/smoothstep_spec.rb
Ruby
bsd-2-clause
19
master
1,315
RSpec.describe(MB::Sound::Filter::Smoothstep) do it 'can be created' do f = 120.hz.square.smooth(samples: 60) expect(f).to be_a(MB::Sound::Filter::SampleWrapper) expect(f.base_filter).to be_a(MB::Sound::Filter::Smoothstep) end it 'smooths samples' do f = MB::Sound::Filter::Smoothstep.new(sample_r...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/simple_envelope_follower_spec.rb
Ruby
bsd-2-clause
19
master
224
RSpec.describe(MB::Sound::Filter::SimpleEnvelopeFollower) do it 'can be constructed' do expect { MB::Sound::Filter::SimpleEnvelopeFollower.new(sample_rate: 48000) }.not_to raise_error end pending 'more tests' end
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/sample_wrapper_spec.rb
Ruby
bsd-2-clause
19
master
2,054
RSpec.describe(MB::Sound::Filter::SampleWrapper, :aggregate_failures) do describe '#sample' do it 'does not pad short inputs' do i = 1000.hz.lowpass.wrap(0.hz.square.at(0).at_rate(50).for(1)) expect(i).to be_a(MB::Sound::Filter::SampleWrapper) expect(i.sample(10)).to eq(Numo::SFloat.zeros(10)) ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/filter_sum_spec.rb
Ruby
bsd-2-clause
19
master
1,075
RSpec.describe(MB::Sound::Filter::FilterSum) do describe '#initialize' do it 'raises an error if filters have different sample rates' do a = 15.hz.at_rate(32170).lowpass b = 25.hz.at_rate(45678).lowpass b.singleton_class.undef_method(:sample_rate=) expect { MB::Sound::Filter::FilterSum.new...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/gain_spec.rb
Ruby
bsd-2-clause
19
master
518
RSpec.describe(MB::Sound::Filter::Gain) do let(:f) { MB::Sound::Filter::Gain.new(2, sample_rate: 12345) } let(:f_complex) { MB::Sound::Filter::Gain.new(2i, sample_rate: 12345) } it 'can be constructed' do expect { f }.not_to raise_error end it 'multiplies by the gain factor' do expect(f.process(Numo...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/hilbert_iir_spec.rb
Ruby
bsd-2-clause
19
master
2,925
RSpec.describe(MB::Sound::Filter::HilbertIIR, :aggregate_failures) do let(:sample_rate) { 48000.0 } let(:nyquist) { sample_rate * 0.5 } # FIXME: sometimes the logspace arrays here are all infinity??? Is this a CPU/RAM issue or a code bug? let(:log100_15k) { Numo::SFloat.logspace(Math.log10(100 * Math::PI / nyq...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/filter_chain_spec.rb
Ruby
bsd-2-clause
19
master
5,498
RSpec.describe(MB::Sound::Filter::FilterChain) do let (:chain) { MB::Sound::Filter::FilterChain.new( MB::Sound::Filter::Cookbook.new(:lowshelf, 48000, 1000, shelf_slope: 1.0, db_gain: -6.0), MB::Sound::Filter::Cookbook.new(:lowshelf, 48000, 2000, shelf_slope: 1.0, db_gain: -3.0), MB::Sound::Filt...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/filter_bank_spec.rb
Ruby
bsd-2-clause
19
master
1,654
RSpec.describe(MB::Sound::Filter::FilterBank) do describe '.butterworth' do let(:freq_range) { 1000..2000 } let(:freq_ends) { [freq_range.first, freq_range.last] } let(:bank) { MB::Sound::Filter::FilterBank.butterworth(11, :lowpass, 5, 48000, freq_range) } it 'creates all Butterworth filters' do ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/linear_follower_spec.rb
Ruby
bsd-2-clause
19
master
3,684
RSpec.describe(MB::Sound::Filter::LinearFollower) do describe '#initialize' do it 'calculates a per-sample rate from the per-second rates' do lf = MB::Sound::Filter::LinearFollower.new(sample_rate: 100, max_rise: 1, max_fall: 1, absolute: false) expect(lf.max_rise).to eq(0.01) expect(lf.max_fall...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/cookbook_spec.rb
Ruby
bsd-2-clause
19
master
18,795
require 'numo/pocketfft' RSpec.describe(MB::Sound::Filter::Cookbook, :aggregate_failures) do context 'when wrapped in MB::Sound::Filter::SampleWrapper' do it 'uses changing values and stops when inputs stop' do f = 500.hz.lowpass wrapper = MB::Sound::Filter::SampleWrapper.new( f, 500...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/butterworth_spec.rb
Ruby
bsd-2-clause
19
master
1,761
RSpec.describe MB::Sound::Filter::Butterworth do context 'lowpass' do for order in 1..10 do it "can construct a filter of order #{order} without crashing" do f = nil expect { f = MB::Sound::Filter::Butterworth.new(:lowpass, order, 48000, 12000) }.not_to raise_error expect { f.process...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/fir_spec.rb
Ruby
bsd-2-clause
19
master
7,963
RSpec.describe MB::Sound::Filter::FIR do let (:real_filter) { MB::Sound::Filter::FIR.new({ 100 => -10.db, 500 => -10.db, 1000 => 0.db, 3000 => -10.db, 5000 => 0.db, 10000 => -10.db, 15000 => 0.db, 16000 => -2.db }) } let (:complex_filter) { MB::Sound::F...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/first_order_spec.rb
Ruby
bsd-2-clause
19
master
2,122
RSpec.describe MB::Sound::Filter::FirstOrder do context 'lowpass1p' do it 'produces the expected coefficients for x=0.9' do fc = -Math.log(0.9) / (2.0 * Math::PI) * 48000 filter = MB::Sound::Filter::FirstOrder.new(:lowpass1p, 48000, fc) expect(filter.coefficients.map { |c| c.round(5) }).to eq([0...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/lib/mb/sound/filter/delay_spec.rb
Ruby
bsd-2-clause
19
master
6,298
RSpec.describe(MB::Sound::Filter::Delay, :aggregate_failures) do let(:shortbuf) { MB::Sound::Filter::Delay.new(delay: 5, sample_rate: 1, buffer_size: 10) } let(:midbuf) { MB::Sound::Filter::Delay.new(delay: 10, sample_rate: 1, buffer_size: 171) } describe '#initialize' do it 'can calculate delay...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/ext/mb/fast_sound_spec.rb
Ruby
bsd-2-clause
19
master
3,599
RSpec.describe(MB::FastSound) do describe '#narray_log' do it 'calculates the natural logarithm of SFloat' do data = Numo::SFloat[[1,2],[3,4]] expected = Numo::SFloat[[Math.log(1), Math.log(2)], [Math.log(3), Math.log(4)]] expect(MB::FastSound.narray_log(data)).to eq(expected) end it 'c...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/ext/mb/sound/fast_wavetable_spec.rb
Ruby
bsd-2-clause
19
master
8,755
RSpec.describe(MB::Sound::FastWavetable, aggregate_failures: true) do # Additional tests are in specs for MB::Sound::Wavetable and MB::Sound::GraphNode::Wavetable. describe '.outer_linear' do it 'can retrieve a value from a wavetable' do expect(MB::Sound::FastWavetable.outer_linear(Numo::SFloat[[0, 1], [...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
spec/ext/mb/sound/fast_resample_spec.rb
Ruby
bsd-2-clause
19
master
6,291
# This is the C extension from ext/mb/sound/fast_resample/ RSpec.describe(MB::Sound::FastResample, :aggregate_failures) do let(:converter_mode) { nil } let(:r_half) { MB::Sound::FastResample.new(0.5, converter_mode) { |s| Numo::SFloat.zeros(s) } } let(:r_double) { MB::Sound::FastResample.new(2, converter_mode) { ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fm_bass.rb
Ruby
bsd-2-clause
19
master
3,260
#!/usr/bin/env ruby # A very rough approximation of Solid Bass or Lately Bass from the classic # Yamaha FM synthesizers. require 'bundler/setup' require 'mb-sound' MB::U.sigquit_backtrace OSC_COUNT = ENV['OSC_COUNT']&.to_i || 1 voices = OSC_COUNT.times.map { |i| base = 440.constant freq_constants = [] bfreq = ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/synth.rb
Ruby
bsd-2-clause
19
master
3,821
#!/usr/bin/env ruby # A single-oscillator monophonic MIDI-controlled synthesizer. Requires the # mb-sound-jackffi gem. This is a simple example that quantizes all MIDI # events to audio buffer boundaries. # # Usage: ./bin/synth.rb [midi_port_to_connect] require 'bundler/setup' require 'forwardable' Bundler.require...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/benchmark_ruby_versions.rb
Ruby
bsd-2-clause
19
master
4,157
#!/usr/bin/env ruby require 'bundler/setup' require 'optionparser' require 'csv' require 'mb-util' AVAILABLE_BENCHMARKS = [:node_graph, :resampling, :wavetable] $enabled_benchmarks = [:wavetable] $csv_output = $stdout OptionParser.new do |opt| opt.banner = "Usage: #{$0} [options] [ruby version list]" opt.on('-...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/reverse_delay.rb
Ruby
bsd-2-clause
19
master
4,506
#!/usr/bin/env ruby # A reverse delay effect. This works by playing a delay buffer in reverse. # (C)2022 Mike Bourgeous # # Usage: $0 [delay_s [feedback]] [filename] # # Examples: # DRY=0 $0 0.2 0 sounds/drums.flac require 'bundler/setup' require 'mb/sound' if ARGV.include?('--help') MB::U.print_header_help ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/loopify.rb
Ruby
bsd-2-clause
19
master
1,934
#!/usr/bin/env ruby # Experiment to turn any section of a sound into a seamless loop. # # Usage: # $0 in_filename out_filename loop_start loop_length [crossfade_length] require 'bundler/setup' require 'mb-sound' if ARGV.include?('--help') || ARGV.empty? MB::U.print_header_help exit 1 end data = MB::Sound.re...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/midi_cc_chart.rb
Ruby
bsd-2-clause
19
master
1,784
#!/usr/bin/env ruby # Shows the last-received value of MIDI CCs in a table layout. # # Requires MB::Sound::JackFFI and needs jackd running. require 'bundler/setup' require 'nibbler' require 'forwardable' require 'mb-sound' require 'mb-sound-jackffi' if ARGV.include?('--help') puts MB::U.read_header_comment.join.g...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/reverb.rb
Ruby
bsd-2-clause
19
master
5,872
#!/usr/bin/env ruby # A standalone monaural reverb effect. # # Input and output file can be specified using flags or positional arguments. # # Presets are a good way to get good sounds quickly. You can override preset # defaults by passing options like -w and -g. # # Note: the --diffusion-time and --feedback-time opti...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fm_bell.rb
Ruby
bsd-2-clause
19
master
3,475
#!/usr/bin/env ruby # A tubular bell sound based in part on the T.BL-EXPA preset included with # Dexed. require 'bundler/setup' require 'mb-sound' require 'mb-util' MB::U.sigquit_backtrace repeat = !!ARGV.delete('--loop') # TODO: Build an abstraction around switching between Jack and MIDI files for # input, and FLA...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/plot_windows.rb
Ruby
bsd-2-clause
19
master
2,779
#!/usr/bin/env ruby # Plots different window functions and their overlap # Usage: bin/plot_windows.rb [window_length [hop]] [window and plot names] # Usage: $0 [window names...] or $0 [window length] [window names...] or $0 [window_length hop_size] [window names...] # e.g. bin/plot_windows.rb 2048 Hann dft require 'ru...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/plot.rb
Ruby
bsd-2-clause
19
master
484
#!/usr/bin/env ruby # Plots a given audio file. # Usage: $0 filename require 'bundler/setup' require 'mb/util' require 'mb/sound' graphical = !!ARGV.delete('--graphical') if ARGV.length != 1 || ARGV.include?('--help') MB::U.print_header_help exit 1 end data = MB::Sound.read(ARGV[0]) loop do # TODO: there's ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/write_white_noise.rb
Ruby
bsd-2-clause
19
master
1,287
#!/usr/bin/env ruby # Generates white noise in a file. The output will have a roughly Gaussian # distribution. require 'bundler/setup' require 'pry' require 'pry-byebug' $LOAD_PATH << File.expand_path('../lib', __dir__) require 'mb-sound' PROGRESS_FORMAT = "\e[36m%a \e[35m%e\e[0m \e[34m[\e[1m%B\e[0;34m] %p%%\e[0m...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/plot_resamplers.rb
Ruby
bsd-2-clause
19
master
1,173
#!/usr/bin/env ruby # Plots the same function upsampled by all the different resampling modes, # showing the stairstep and jagged line effects of ZOH and linear resamplers # compared to the smooth sine wave of a sinc resampler. require 'bundler/setup' require 'pry-byebug' require 'mb-sound' GRAPHICAL = ARGV.include...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/midi_parameter_test.rb
Ruby
bsd-2-clause
19
master
1,368
#!/usr/bin/env ruby # Tests assigning multiple parameters to a single MIDI message type. require 'bundler/setup' require 'mb-sound' require 'mb-sound-jackffi' require 'mb-util' MB::U.sigquit_backtrace jack = MB::Sound::JackFFI[] manager = MB::Sound::MIDI::Manager.new(jack: jack, connect: ARGV[0] || :physical, chann...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/wavetable_pr_example.rb
Ruby
bsd-2-clause
19
master
742
#!/usr/bin/env ruby # First wavetable example from the wavetable pull request. # (C)2025 Mike Bourgeous require 'bundler/setup' require 'mb-sound' # Noise LFO nzlfo = 1.hz.gauss.noise.at(100).filter(:highpass, cutoff: 0.02, quality: 0.5).filter(:lowpass, cutoff: 0.3, quality: 0.5).softclip(0, 1) * 26.0/30 + 0.3333 #...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fir_filter.rb
Ruby
bsd-2-clause
19
master
2,464
#!/usr/bin/env ruby # Uses MB::Sound::Filter::FIR to design a filter with a desired response, and # process a sound file with that filter. The filter design algorithm is very # crude, but it works. require 'bundler/setup' require 'pry-byebug' $LOAD_PATH << File.expand_path('../lib', __dir__) require 'mb/sound' def...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/phase_synth.rb
Ruby
bsd-2-clause
19
master
4,061
#!/usr/bin/env ruby # Synthesizes a stereo sine wave with periodic phase transitions between # in-phase, out-of-phase, or between. The final phase will play for 1 second # unless a final delay is given. # # Delays between phases should be at least 100ms to account for phase # transition time. Phase should range from ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fm_experimental_bell.rb
Ruby
bsd-2-clause
19
master
4,317
#!/usr/bin/env ruby # A tubular bell sound based in part on the T.BL-EXPA preset included with # Dexed. require 'bundler/setup' require 'mb-sound' repeat = !!ARGV.delete('--loop') # TODO: Build an abstraction around switching between Jack and MIDI files for # input, and FLAC files for output, for use by all synthesi...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/sound.rb
Ruby
bsd-2-clause
19
master
4,026
#!/usr/bin/env ruby # Interactive sound environment. Uses Pry within the MB::Sound module context. # See README.md for more info, including copyright and license. require 'rubygems' require 'bundler/setup' require 'benchmark' require 'io/console' require 'pry' require 'pry-byebug' Bundler.require MB::U.sigquit_ba...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/info.rb
Ruby
bsd-2-clause
19
master
301
#!/usr/bin/env ruby # Prints information about a media file. # # Usage: $0 filename require 'bundler/setup' require 'mb/util' require 'mb/sound' if ARGV.length != 1 || ARGV.include?('--help') MB::U.print_header_help exit 1 end puts MB::U.highlight(MB::Sound::FFMPEGInput.parse_info(ARGV[0]))
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/midi_info.rb
Ruby
bsd-2-clause
19
master
942
#!/usr/bin/env ruby # Displays number of events from each channel, and other info about a MIDI # file. # # Usage: $0 midi_file.mid require 'bundler/setup' require 'mb-sound' if ARGV.include?('--help') || ARGV.length != 1 puts MB::U.read_header_comment.join.gsub('$0', $0) exit 1 end f = MB::Sound::MIDI::MIDIFile...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/plot_adsr.rb
Ruby
bsd-2-clause
19
master
1,179
#!/usr/bin/env ruby # Plots an ADSR envelope with parameters given on the command line. # # Usage: $0 attack_time decay_time sustain_level release_time [--db[=nn]] [--filter=freq] require 'bundler/setup' require 'pry-byebug' require 'mb-util' require 'mb-sound' db = ARGV.find { |s| s =~ /^--db(=([-+]?\d+(\.\d+)?))?$/...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/loop.rb
Ruby
bsd-2-clause
19
master
343
#!/usr/bin/env ruby # Loops an audio file until interrupted. require 'bundler/setup' require 'mb-sound' MB::U.sigquit_backtrace if ARGV.include?('--help') || ARGV.empty? puts "Usage: \e[1m#{$0}\e[0m sound_filename" exit 1 end data = MB::Sound.read(ARGV[0]) inp = MB::Sound::ArrayInput.new(data: data, repeat: tru...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/stereo_graph_synth_example.rb
Ruby
bsd-2-clause
19
master
834
#!/usr/bin/env ruby require 'bundler/setup' require 'mb-sound' if ARGV[0]&.downcase&.end_with?('.mid') && File.readable?(ARGV[0]) # FIXME: exit when the MIDI file has ended midi = MB::Sound.midi_file(ARGV[0]) else midi = MB::Sound.midi end q = (midi.frequency * 2.001).tone.at(1).with_phase(Math::PI/3) + 0.1.hz...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/simple_syn.rb
Ruby
bsd-2-clause
19
master
1,184
#!/usr/bin/env ruby # One-oscillator synthesizer based on MB::Sound::MIDI::Voice (slight upgrade of # bin/ep2_syn.rb). # # GraphVoice is better so use that for building new synths. require 'bundler/setup' require 'mb-sound' require 'mb-sound-jackffi' MB::Sound::Oscillator.tune_freq = 480 MB::Sound::Oscillator.tune_n...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/resample_benchmark.rb
Ruby
bsd-2-clause
19
master
1,381
#!/usr/bin/env ruby require 'bundler/setup' require 'benchmark' require 'mb-util' require 'mb-sound' MB::U.sigquit_backtrace SAMPLE_COUNT = ENV['SAMPLES']&.to_i || 48000 * 180 MB::U.bench_csv(prefix: MB::U.ruby_info) do |bench| bench.report("ruby_zoh single sample") do 100.hz.forever.at_rate(441) .res...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/ping_pong_delay.rb
Ruby
bsd-2-clause
19
master
2,004
#!/usr/bin/env ruby # A left/right ping-pong delay # (C)2025 Mike Bourgeous # # Usage: [DRY=] [WET=] $0 [delay_s [feedback [extra_time]]] [input_filename] # # Examples: # # Basic ping-pong delay # $0 sounds/transient_synth.flac # # # Weak room slap-back echo simulation # $0 sounds/drums.flac 0.01 0.3 # ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/stereo_graph_example.rb
Ruby
bsd-2-clause
19
master
544
#!/usr/bin/env ruby require 'bundler/setup' require 'mb-sound' q = 120.1.hz.at(1).with_phase(Math::PI/3) + 0.1.hz.lfo.at(1) * 60.hz.lfo.at(Math::PI) a = ( (360.3.hz.pm(q) + 481.4.hz.pm(q)).oversample(3).forever + 30.hz.ramp.at(0.3).filter(:lowpass, cutoff: 0.23.hz.lfo.at(130..2500)) ).softclip.oversample(2) left =...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/haas_pan.rb
Ruby
bsd-2-clause
19
master
2,087
#!/usr/bin/env ruby # Applies time-varying Haas-effect panning to an audio file based on a sequence # of relative delay values in milliseconds and timestamps in seconds. # # Usage: $0 in_file out_file time_s_1 delay_ms_1 [time_s_2 delay_ms_2 [...]] require 'bundler/setup' require 'mb-sound' def usage puts MB::U.rea...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/midi_note_chart.rb
Ruby
bsd-2-clause
19
master
1,935
#!/usr/bin/env ruby # Shows the attack velocity of notes while they are held. # # Requires MB::Sound::JackFFI and needs jackd running, unless displaying a MIDI # file. require 'bundler/setup' require 'nibbler' require 'forwardable' require 'mb-sound' require 'mb-sound-jackffi' if ARGV.include?('--help') puts MB::...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fm_kick.rb
Ruby
bsd-2-clause
19
master
4,277
#!/usr/bin/env ruby # Trying to synthesize a kick inspired by a YouTube tutorial: # https://www.youtube.com/watch?v=ndG-6-vONNc require 'bundler/setup' require 'mb-sound' pry_next = false MB::U.sigquit_backtrace do pry_next = true end # Generates a node graph and GraphVoice to synthesize a kick def kicker pitch...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fm_bellpad.rb
Ruby
bsd-2-clause
19
master
3,588
#!/usr/bin/env ruby # A metallic bell pad sound. require 'bundler/setup' require 'mb-sound' repeat = !!ARGV.delete('--loop') # TODO: Build an abstraction around switching between Jack and MIDI files for # input, and FLAC files for output, for use by all synthesizers jack = MB::Sound::JackFFI[] output = jack.output(c...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/midi_events.rb
Ruby
bsd-2-clause
19
master
2,300
#!/usr/bin/env ruby # Prints events as they occur in real time, either from a jackd input or a MIDI # file. Can optionally forward events to a jackd MIDI output. # # Requires MB::Sound::JackFFI and needs jackd running for realtime input. # # Usage: # $0 [--output[=output_port_name]] [input_port_or_midi_filename] ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/write_brown_noise.rb
Ruby
bsd-2-clause
19
master
1,535
#!/usr/bin/env ruby # Generates brown noise in a file. The output will have a roughly Gaussian # distribution. require 'bundler/setup' require 'pry' require 'pry-byebug' $LOAD_PATH << File.expand_path('../lib', __dir__) require 'mb-sound' PROGRESS_FORMAT = "\e[36m%a \e[35m%e\e[0m \e[34m[\e[1m%B\e[0;34m] %p%%\e[0m...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/midi_roll.rb
Ruby
bsd-2-clause
19
master
5,386
#!/usr/bin/env ruby # Displays an extremely simple piano roll style view of a MIDI file. # # Usage: $0 [options] midi_file.mid # # Example to scroll through a MIDI file: # for f in `seq 0 1 60`; do bin/midi_roll.rb -s $f -d 20 song.mid ; done require 'bundler/setup' require 'optparse' require 'mb-sound' options...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/play_noise.rb
Ruby
bsd-2-clause
19
master
5,871
#!/usr/bin/env ruby # Plays realtime noise of different colors. require 'rubygems' require 'bundler/setup' require 'pry' require 'pry-byebug' $LOAD_PATH << File.expand_path('../lib', __dir__) require 'mb-sound' USAGE = "(usage: #{$0} (white|pink|brown|power|wave) [channels default 2] [db_gain default 0])" class N...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/record.rb
Ruby
bsd-2-clause
19
master
841
#!/usr/bin/env ruby # Records sound from the default input to a given filename. # # Usage: # $0 output_filename # # Example: # $0 /tmp/x.flac require 'bundler/setup' require 'mb-sound' if ARGV.include?('--help') MB::U.print_header_help exit 1 end outfile = ARGV[0] raise "No filename given" unless outfil...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/wavetable_bass.rb
Ruby
bsd-2-clause
19
master
1,787
#!/usr/bin/env ruby # Wavetable- and waveshaping-based monophonic bass synth. require 'bundler/setup' require 'mb-util' require 'mb-sound' MB::U.sigquit_backtrace DETUNE_CENTS = 5 DETUNE_SEMIS = 0.01 * DETUNE_CENTS DETUNE_RANGE = (2 ** -DETUNE_SEMIS)..(2 ** DETUNE_SEMIS) PORTAMENTO_TIME = 0.1 # TODO: control with mi...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/grain_repeater.rb
Ruby
bsd-2-clause
19
master
4,253
#!/usr/bin/env ruby # Very simple granular delay repeater. # (C)2024 Mike Bourgeous # # Usage: $0 [--help] [--delay=seconds] [--count=integer] [--channels=integer] [--output=filename] [filename] # # Examples: # $0 --delay=0.02083333 --count=8 sounds/drums.flac # $0 --delay=0.05 --count=8 sounds/synth0.flac # ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/matrix_process.rb
Ruby
bsd-2-clause
19
master
4,176
#!/usr/bin/env ruby # Multiplies each sample of an audio file by a processing matrix to produce a # new output file. If the --decode flag is given, then the matrix is # transposed and the complex conjugate is taken of all coefficients to turn an # encoding matrix into a decoding matrix (or vice versa). # # The number ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/silence.rb
Ruby
bsd-2-clause
19
master
256
#!/usr/bin/env ruby # Plays silence forever to try to keep the USB audio interface open. require 'bundler/setup' require 'mb-sound' output = MB::Sound.output(channels: 1) data = Numo::SFloat.zeros(output.buffer_size) loop do output.write([data]) end
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/sink.rb
Ruby
bsd-2-clause
19
master
217
#!/usr/bin/env ruby # Ignores input to keep Pipewire from closing a USB audio interface. require 'bundler/setup' require 'mb-sound' input = MB::Sound.input(channels: 1) loop do input.read(input.buffer_size) end
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/freq_estimate.rb
Ruby
bsd-2-clause
19
master
768
#!/usr/bin/env ruby # Prints an estimate of the fundamental frequency of the given sound file. # # Usage: # $0 filename [min_frequency [max_frequency]] require 'bundler/setup' require 'mb-sound' if ARGV.include?('--help') MB::U.print_header_help exit 1 end filename, min_freq, max_freq, *_ = ARGV raise 'No ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/play.rb
Ruby
bsd-2-clause
19
master
296
#!/usr/bin/env ruby # Plays an audio file while showing meters. require 'bundler/setup' require 'pry-byebug' require 'mb-sound' if ARGV.include?('--help') || ARGV.empty? puts "Usage: \e[1m#{$0}\e[0m sound_filename" exit 1 end # TODO: gapless playback ARGV.each do |f| MB::Sound.play f end
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/old_flanger.rb
Ruby
bsd-2-clause
19
master
2,787
#!/usr/bin/env ruby # A simple flanger effect, to demonstrate using a signal node as a delay time. # (C)2022 Mike Bourgeous # # Cool pitch effect: SMOOTHING=0.5 bin/flanger.rb 0.035 0 3 2 require 'bundler/setup' require 'mb/sound' if ARGV.include?('--help') puts "Usage: [WAVE_TYPE=:ramp] \e[1m#{$0}\e[0m [delay_s [...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/make_wavetable.rb
Ruby
bsd-2-clause
19
master
2,833
#!/usr/bin/env ruby # Chops any sound file into a wavetable. # # Works by trying to detect the fundamental frequency of the sound, then # slicing and blending the sound into loopable chunks of the fundamental # period. # # Usage: # $0 [options] in_filename out_filename require 'bundler/setup' require 'optparse' re...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fm_synth.rb
Ruby
bsd-2-clause
19
master
3,395
#!/usr/bin/env ruby # An experimental FM synthesizer that uses later notes to modulate earlier # notes. If only one note is played, that note is unmodulated. Each later # note modulates the note that came before it. The modulation wheel controls # the intensity of modulation. # (C)2021 Mike Bourgeous require 'bundl...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/plot_resampler_window_delta.rb
Ruby
bsd-2-clause
19
master
2,439
#!/usr/bin/env ruby # Plots difference between resampling with a large buffer size and a small # buffer size. There shouldn't be a difference, but at time of writing this # script there is. # TODO: dedupe with other plot_resampler* scripts? require 'bundler/setup' require 'pry-byebug' require 'mb-sound' pry_next ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/flanger.rb
Ruby
bsd-2-clause
19
master
7,777
#!/usr/bin/env ruby # A simple flanger effect, to demonstrate using a signal node as a delay time. # (C)2022 Mike Bourgeous # # Usage: $0 [delay_s [feedback [hz [depth0..1]]]] [filename [output_filename]] [--silent] # Or: $0 [filename [output_filename]] [--silent] # # Environment variables: # WAVE_TYPE - oscillat...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/old_ep2_synth.rb
Ruby
bsd-2-clause
19
master
3,466
#!/usr/bin/env ruby # Synthesizer for episode 2 require 'bundler/setup' require 'nibbler' require 'mb-sound' require 'mb-sound-jackffi' # A ring/pool of objects (e.g. oscillators) to be used in FIFO order. Error # handling and better voice stealing left as an exercise for the reader. class Ring extend Forwardabl...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/write_pink_noise.rb
Ruby
bsd-2-clause
19
master
1,597
#!/usr/bin/env ruby # Generates pink noise in a file. This version uses a window to remove # possible discontinuities at block boundaries. require 'bundler/setup' require 'pry' require 'pry-byebug' $LOAD_PATH << File.expand_path('../lib', __dir__) require 'mb-sound' PROGRESS_FORMAT = "\e[36m%a \e[35m%e\e[0m \e[34...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/fm_drumbass.rb
Ruby
bsd-2-clause
19
master
1,700
#!/usr/bin/env ruby require 'bundler/setup' require 'mb-sound' OSC_COUNT = ENV['OSC_COUNT']&.to_i || 1 voices = OSC_COUNT.times.map { |i| note = MB::Sound::Note.new(36 + i * 16) note2 = MB::Sound::Note.new(note.number + 12) cenv = MB::Sound.adsr(0, 0.005, 0.5, 0.005, auto_release: false).db(30) cenv2 = MB::S...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/plot_waveforms.rb
Ruby
bsd-2-clause
19
master
1,011
#!/usr/bin/env ruby # Plots waveforms supported by MB::Sound::Oscillator and their spectra # Usage: bin/plot_waveforms.rb require 'bundler/setup' require 'pry-byebug' require 'mb-sound' show_imag = !!ARGV.delete('--imag') input = Numo::DComplex.linspace(0, 64.0 * Math::PI, 64000) plots = MB::Sound::Oscillator::WAVE...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/wavetable_benchmark.rb
Ruby
bsd-2-clause
19
master
1,433
#!/usr/bin/env ruby require 'bundler/setup' require 'benchmark' require 'mb-sound' wt = nil phase = nil number = nil number_arr = nil phase_arr = nil SAMPLES = ENV['SAMPLES']&.to_i || 48000 * 60 MB::U.bench_csv(prefix: MB::U.ruby_info) do |bench| bench.report('build wavetable') do phase = 100.hz.ramp.at(1).fo...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/tape_delay.rb
Ruby
bsd-2-clause
19
master
4,512
#!/usr/bin/env ruby # A simple, mono, tape-simulator echo with feedback. # (C)2022-2025 Mike Bourgeous # # Usage: [DRY=1.0] [WET=1.0] [DRIVE=1.0] [PITCH=1 [SMOOTHING=2]] $0 [delay_s [feedback [extra_time]]] [filename] # # Examples: # # synth groove # DRY=1.75 DRIVE=2 WET=1.5 $0 0.25 1 sounds/transient_synth.fla...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/multitap_delay.rb
Ruby
bsd-2-clause
19
master
3,893
#!/usr/bin/env ruby # A filtered multi-tap delay effect. # (C)2022 Mike Bourgeous # # This is inspired by a module I saw on Andrew Huang's YouTube channel. # # Usage: $0 [base_delay_seconds] [filter_frequency] [filter_quality] [reverse_odd_taps] [filename] # # Examples: # Resonant widener: $0 0.001 sounds/transient...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/hilbert_plots.rb
Ruby
bsd-2-clause
19
master
2,325
#!/usr/bin/env ruby # Plots phase difference effects of various experiments with the Hilbert IIR # filter. The goal is to understand how to get closer to 90deg phase across a # wider range of the spectrum, what the effect of each filter is, etc. require 'bundler/setup' require 'mb-sound' filters = { original: [ M...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/plot_resampler_delta.rb
Ruby
bsd-2-clause
19
master
2,453
#!/usr/bin/env ruby # Plots difference between Ruby and libsamplerate implementations of ZOH and # linear resamplers. There shouldn't be a difference (other than possible # lag), but at time of writing, there is. # TODO: dedupe with other plot_resampler* scripts? require 'bundler/setup' require 'pry-byebug' requir...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/ep2_syn.rb
Ruby
bsd-2-clause
19
master
1,044
#!/usr/bin/env ruby # Episode 2 of Code Sound & Surround # Synthesizahh!!! require 'bundler/setup' require 'mb-sound' require 'mb-sound-jackffi' MB::Sound::Oscillator.tune_freq = 480 MB::Sound::Oscillator.tune_note = 71 jack = MB::Sound::JackFFI['EP2Synth'] output = jack.output(port_names: ['Synth', 'Impulse'], cha...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/songs/node_graph_benchmark.rb
Ruby
bsd-2-clause
19
master
4,014
#!/usr/bin/env ruby # This is a simple algorithmically defined song that exercises several common # parts of the GraphNode and Filter code, including processing with complex # numbers. # # Music and code (C)2025 Mike Bourgeous # # Use --bench to run the benchmark, or no arguments to play the song. require 'bundler/set...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/songs/node_graph_grit.rb
Ruby
bsd-2-clause
19
master
1,172
#!/usr/bin/env ruby # Just a 23-ish second bass sound of increasing distortion. The little drum # sound at the end comes from filter pinging when the triangle wave gets cut # off in the middle of a cycle. require 'bundler/setup' require 'mb-sound' MB::Sound.play( ( ( 25.hz.triangle.at(0.25).forever + ...
github
mike-bourgeous/mb-sound
https://github.com/mike-bourgeous/mb-sound
bin/songs/random_drum_pentatonic.rb
Ruby
bsd-2-clause
19
master
2,235
#!/usr/bin/env ruby require 'bundler/setup' require 'mb-sound' d = MB::Sound.read('../mb-sound/sounds/drums.flac').sum d = d[0...MB::M.round_to(d.length - 16000, 16000)] d = d.reshape(nil, 8000) d = Array.new(d.shape[0]) { |idx| d[idx, nil] } drums = MB::Sound::GraphNode::DataShuffler.new(d).softclip(0.1, 0.6) * 0.5....