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 | lib/mb/sound.rb | Ruby | bsd-2-clause | 19 | master | 5,950 | require 'cmath'
require 'numo/narray'
require 'mb-sound-jackffi'
require 'mb-math'
require 'mb-util'
require_relative 'sound/numeric_sound_mixins'
# Load C extensions
require_relative 'fast_sound'
require_relative 'sound/fast_resample'
require_relative 'sound/fast_wavetable'
require_relative 'sound/version'
require... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/processing_matrix.rb | Ruby | bsd-2-clause | 19 | master | 11,471 | require 'matrix'
require 'csv'
require 'yaml'
require 'json'
module MB
module Sound
# Multiplies each sample of one or more incoming streams of time- or
# frequency-domain data by a Ruby Matrix object, producing one or more output
# streams (depending on the size of the Matrix).
#
# The incoming ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/jack_output.rb | Ruby | bsd-2-clause | 19 | master | 2,727 | require 'shellwords'
module MB
module Sound
# An audio output stream that opens the `jack-stdin` command in a pipe and
# writes 32-bit little-endian float data to it, for playing directly to a
# jackd audio network.
#
# Use the mb-sound-jackffi gem instead, if you can.
class JackOutput < MB::... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/null_output.rb | Ruby | bsd-2-clause | 19 | master | 2,835 | module MB
module Sound
# A process_stream-compatible output stream that ignores all audio given,
# but verifies that the correct number of channels are provided. Primarily
# used for testing.
class NullOutput
# Number of channels this null output will expect to be passed to #write.
attr_r... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/wavetable.rb | Ruby | bsd-2-clause | 19 | master | 15,195 | module MB
module Sound
# Methods related to saving, loading, generating, and sampling from
# wavetables.
#
# See MB::Sound::GraphNode::Wavetable.
# See bin/make_wavetable.rb.
module Wavetable
# Loads an existing wavetable from the given +filename+, using the
# mb_sound_wavetable_pe... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/plot_methods.rb | Ruby | bsd-2-clause | 19 | master | 14,835 | module MB
module Sound
# Command-line interface methods related to plotting sounds. MB::Sound
# extends itself with this module.
module PlotMethods
# Sets up SIGWINCH (window-size change) handler when MB::Sound extends
# itself with this module.
def self.extended(within)
# Make ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/jack_input.rb | Ruby | bsd-2-clause | 19 | master | 2,975 | require 'shellwords'
module MB
module Sound
# An audio input stream that opens the `jack-stdout` command in a pipe and
# reads 32-bit little-endian float data from it, for recording directly
# from a jackd audio network.
#
# Note: as a starting point, set the buffer size equal to the hop size use... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/io_logger.rb | Ruby | bsd-2-clause | 19 | master | 2,395 | module MB
module Sound
# Include in I/O objects or classes to log reads and writes. Set the IOLOG
# environment variable to "1" to log a number of inputs and outputs.
module IOLogger
def iolog_output=(o)
@iolog_output = o
end
def iolog_output
@iolog_output ||= STDOUT
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node.rb | Ruby | bsd-2-clause | 19 | master | 43,378 | require 'shellwords'
require_relative 'graph_node/nameable'
require_relative 'graph_node/traversable'
require_relative 'graph_node/node_output'
require_relative 'graph_node/multi_output'
module MB
module Sound
# Adds methods to any class that implements a :sample method to build
# signal generation and proc... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node_input.rb | Ruby | bsd-2-clause | 19 | master | 5,520 | module MB
module Sound
# An input object that reads from a node graph.
class GraphNodeInput
attr_reader :channels, :sample_rate, :buffer_size
# Creates a graph node input that returns the nodes' output across at
# least +:channels+ channels. If +:channels+ is greater than the number
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/buffer_helper.rb | Ruby | bsd-2-clause | 19 | master | 5,108 | module MB
module Sound
# This mixin provides the setup_buffer method for use by any class that
# needs an internal Numo::NArray buffer, and potentially needs to be able
# to convert that buffer from real to complex when data types change.
#
# Typical usage is to call #setup_buffer from a GraphNode... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/ffmpeg_output.rb | Ruby | bsd-2-clause | 19 | master | 5,081 | module MB
module Sound
class FFMPEGOutput < IOOutput
attr_reader :filename
# Starts an FFMPEG process to write audio to the given +filename+. The
# +filename+ must point to a writable directory, unless a +format+
# override is specified (to allow using ffmpeg's virtual output formats,
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/meter.rb | Ruby | bsd-2-clause | 19 | master | 3,572 | require 'io/console'
module MB
module Sound
module Meter
# Draws volume meters on the console for each of the DFTs passed in,
# starting at dfts.size + rows_below rows up.
def self.meters(dfts, rows_below = 0, hz_per_bin = nil)
levels = []
freq_text = []
dfts.each_with_i... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/plot_output.rb | Ruby | bsd-2-clause | 19 | master | 4,782 | require 'forwardable'
module MB
module Sound
# A wrapper for any audio output stream that responds to the #write method
# that plots whatever's being written as fast as the display can keep up.
class PlotOutput
extend Forwardable
def_delegators :@output, :sample_rate, :channels, :buffer_size... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/complex_pan.rb | Ruby | bsd-2-clause | 19 | master | 5,128 | module MB
module Sound
# This class takes a single complex-valued input stream and produces two
# output streams, one for left and one for right.
#
# The "pan" parameter controls relative left/right volume. -1 is left, 1
# is right, 0 is center. The output gain curve for the left and right
#... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/null_input.rb | Ruby | bsd-2-clause | 19 | master | 2,559 | module MB
module Sound
# A process_stream-compatible input stream that generates a stream of a
# constant value of a given length. Primarily used for testing.
#
# Note: the buffer will be reused unless it has to be resized, so do not make
# any modifications to the buffer.
class NullInput
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window.rb | Ruby | bsd-2-clause | 19 | master | 4,673 | module MB
module Sound
# A base class for describing a normalized window function and its optimal
# overlap. All window functions should be normalized so a bin-centered 0dBFS
# sine wave has a value of 1.0 in the FFT.
#
# Subclass constructors should support being called with a single argument,
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/output_buffer_wrapper.rb | Ruby | bsd-2-clause | 19 | master | 4,293 | require 'forwardable'
module MB
module Sound
# A wrapper around an output object that uses circular buffers to allow
# writes of arbitrary size, instead of requiring writes to be equal to the
# output's buffer size.
class OutputBufferWrapper
extend Forwardable
include GraphNode
inc... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/circular_buffer.rb | Ruby | bsd-2-clause | 19 | master | 13,957 | module MB
module Sound
# A 1D circular buffer implemented around Numo::SFloat, Numo::DFloat,
# Numo::SComplex, or Numo::DComplex, supporting reads and writes of
# arbitrary sizes. Also supports multiple readers with different offsets,
# useful for fanout or delays.
#
# Single-reader example:
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/io_output.rb | Ruby | bsd-2-clause | 19 | master | 2,152 | module MB
module Sound
# Base functionality for audio output streams that writes 32-bit
# little-endian floats to a byte-wise IO stream (e.g. STDOUT, or an
# application opened with IO.popen).
#
# See FFMPEGOutput for an example.
class IOOutput < IOBase
attr_reader :frames_written
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/loopback.rb | Ruby | bsd-2-clause | 19 | master | 1,525 | module MB
module Sound
# Acts as both an input stream and an output stream. Whatever is written
# can later be read. Data must be written in #buffer_size chunks.
class Loopback
attr_reader :buffer_size, :sample_rate, :channels
# Initializes a loopback I/O. A block may be given to process e... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window_reader.rb | Ruby | bsd-2-clause | 19 | master | 2,925 | module MB
module Sound
# Reads windowed time-domain data from an input stream using a given window
# function, padding with zeros to drain the buffer at the end.
class WindowReader
attr_reader :channels, :length, :buffer_size
def initialize(input_stream, window, pad_factor: 1)
raise '... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/midi.rb | Ruby | bsd-2-clause | 19 | master | 343 | require 'midi-message'
module MB
module Sound
# Namespace for MIDI-related classes/modules/methods.
module MIDI
end
end
end
require_relative 'midi/parameter'
require_relative 'midi/manager'
require_relative 'midi/voice_pool'
require_relative 'midi/voice'
require_relative 'midi/midi_file'
require_relat... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/io_methods.rb | Ruby | bsd-2-clause | 19 | master | 15,439 | require 'logger'
# YARD provides File.relative_path
require 'yard'
module MB
module Sound
# IO-related methods to include in the sound command-line interface.
#
# See the modules MB::Sound extends itself with to find all command-line
# interface methods.
module IOMethods
# Returns true if ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/io_input.rb | Ruby | bsd-2-clause | 19 | master | 1,695 | module MB
module Sound
# Base functionality for input streams that read 32-bit little-endian
# floats from a byte-wise IO stream (e.g. STDIN, or a program via popen).
#
# See FFMPEGInput for an example.
class IOInput < IOBase
include GraphNode
include GraphNode::IOSampleMixin
at... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/fft_methods.rb | Ruby | bsd-2-clause | 19 | master | 8,563 | # TODO: load FFTW if it's present
require 'numo/pocketfft'
module MB
module Sound
# Command-line methods for performing forward and inverse FFTs. MB::Sound
# extends itself with this module (e.g. use MB::Sound.fft to call the #fft
# method).
#
# Multiple dimensions are supported, but not as thor... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/fft_writer.rb | Ruby | bsd-2-clause | 19 | master | 1,604 | module MB
module Sound
# Writes overlapping FFT frames to an output sound stream. The output stream
# must be closed separately when done writing.
#
# Uses WindowWriter, so see that class for more details.
class FFTWriter
# Initializes a new FFT writer with the given output stream and windo... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/alsa_input.rb | Ruby | bsd-2-clause | 19 | master | 1,533 | module MB
module Sound
# A sound input stream that opens the `arecord` command in a pipe and reads
# 32-bit little-endian float data from it, for recording directly from a
# sound card.
#
# Note: as a starting point, set the buffer size equal to the hop size used
# in any processing algorithms... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/timeline_interpolator.rb | Ruby | bsd-2-clause | 19 | master | 7,029 | module MB
module Sound
# Interpolates values using keyframes along a timeline using linear,
# smoothstep, or other interpolation techniques.
#
# Note that :catmull_rom is quite a bit slower than other methods.
#
# Examples:
# # The :blend value controls the segment after the given keyf... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter.rb | Ruby | bsd-2-clause | 19 | master | 3,784 | module MB
module Sound
# Template/base class for filters showing the methods filter objects should
# implement. For implementation examples see MB::Sound::Filter::Biquad or
# MB::Sound::Filter::FilterChain.
class Filter
# Should accept either a Float or a Numo::NArray (e.g. Numo::SFloat) and
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/io_base.rb | Ruby | bsd-2-clause | 19 | master | 2,555 | module MB
module Sound
# Base class for IOInput and IOOutput with shared code for setting buffer
# sizes, etc. Use IOInput or IOOutput instead of using this directly.
class IOBase
attr_reader :buffer_size, :frame_bytes, :channels, :sample_rate
DEFAULT_BUFFER = 1024
# Called from IOInp... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/analysis_methods.rb | Ruby | bsd-2-clause | 19 | master | 3,192 | module MB
module Sound
# Methods related to analyzing sound signals to find things like
# cross-correlation, peak autocorrelation/estimated frequency, etc.
module AnalysisMethods
# Returns the cross correlation array of the two given arrays using
# FFT-based convolution.
#
# The mi... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window_methods.rb | Ruby | bsd-2-clause | 19 | master | 18,521 | module MB
module Sound
# Methods for processing sound in overlapping or non-overlapping chunks
# (called "windows"), whether in the time domain or frequency domain.
# MB::Sound extends itself with this module.
#
# These methods represent an evolution of techniques over time, starting
# with #p... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/numeric_sound_mixins.rb | Ruby | bsd-2-clause | 19 | master | 4,853 | module MB
module Sound
# Audio-related methods like #hz and #db to mix into the Numeric core
# class.
module NumericSoundMixins
# Superclass of Meters and Feet for detecting their presence.
class Distance < Numeric
end
# Represents a distance in meters. A simple trick inspired by... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/input_buffer_wrapper.rb | Ruby | bsd-2-clause | 19 | master | 3,363 | require 'forwardable'
module MB
module Sound
# A wrapper around an input object that uses circular buffers to allow
# reads of arbitrary size, instead of requiring reads to be equal to the
# input's buffer size.
class InputBufferWrapper
extend Forwardable
include GraphNode
include ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/oscillator.rb | Ruby | bsd-2-clause | 19 | master | 20,484 | require 'midi-message'
require 'nibbler'
require 'mb/fast_sound'
module MB
module Sound
# An oscillator that can generate different wave types. This can be used
# to generate sound, or as an LFO (low-frequency oscillator). It can also
# generate noise with various statistical distributions by setting ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/generation_methods.rb | Ruby | bsd-2-clause | 19 | master | 971 | module MB
module Sound
# Methods to help generating sounds, either as source GraphNodes or as an
# Array of Numo::NArrays.
#
# Included in MB::Sound for the bin/sound.rb DSL.
module GenerationMethods
# Creates a uniformly distributed white noise generator that can be
# combined with ot... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window_writer.rb | Ruby | bsd-2-clause | 19 | master | 4,117 | module MB
module Sound
# Writes overlapping time domain frames to an output stream. The output
# stream is not closed, so more audio can be written and the caller should
# close the output stream.
class WindowWriter
attr_reader :channels, :length, :buffer_size, :sample_rate
# Initializes... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/softest_clip.rb | Ruby | bsd-2-clause | 19 | master | 2,729 | module MB
module Sound
# A soft-clipping filter that preserves perfect linearity for the vast
# majority of the dynamic range, preserves continuity of the first
# derivative, and gently clips an infinite amount of excess dynamic range
# into the given limit.
#
# This is a design I made in the ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/process_reader.rb | Ruby | bsd-2-clause | 19 | master | 1,080 | require 'forwardable'
module MB
module Sound
# Reads audio data from another I/O and yields it to a block given to the
# constructor before returning it in #read. This allows audio to be e.g.
# filtered before being passed to another class that expects an I/O object.
class ProcessReader
extend... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/ffmpeg_input.rb | Ruby | bsd-2-clause | 19 | master | 8,224 | require 'shellwords'
require 'json'
module MB
module Sound
# An input stream type that uses FFMPEG to parse an audio stream from most
# file formats.
class FFMPEGInput < IOInput
# Note: number of frames may be approximate
attr_reader :filename, :frames, :info, :raw_info, :duration, :metadata
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/haas_pan.rb | Ruby | bsd-2-clause | 19 | master | 3,550 | module MB
module Sound
# A delay-based panner. Delays the right speaker to shift sounds to the
# left, delays the left speaker to shift sounds to the right.
class HaasPan
# Delay in seconds. Positive values delay the right channel, negative
# values delay the left channel.
attr_reader ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/noise.rb | Ruby | bsd-2-clause | 19 | master | 4,295 | module MB
module Sound
# Methods for generating noise with different spectral characteristics.
module Noise
# TODO: Remember why a separate Random instance was used here, and make a
# better way to set the seed for reproducibility.
RAND = ENV['RANDOM_SEED'] ? Random.new(ENV['RANDOM_SEED'].to... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/gain_methods.rb | Ruby | bsd-2-clause | 19 | master | 1,915 | module MB
module Sound
# Methods for adjusting and normalizing the loudness of sounds.
module GainMethods
# Normalizes +channels+ (either a single Numo::NArray or an Array of
# Numo::NArray) together to have a maximum absolute value less than or
# equal to +limit+. All channels receive the ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/tone.rb | Ruby | bsd-2-clause | 19 | master | 18,512 | module MB
module Sound
# Representation of a tone to generate or play. Uses MB::Sound::Oscillator
# for tone generation.
class Tone
include GraphNode
include GraphNode::SampleRateHelper
attr_reader :wave_type, :frequency, :amplitude, :range, :duration, :wavelength, :phase
attr_re... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/alsa_output.rb | Ruby | bsd-2-clause | 19 | master | 1,515 | module MB
module Sound
# A sound output stream that opens the `aplay` command in a pipe and writes
# 32-bit little-endian float data to it, for playing directly to a sound
# card.
#
# Note: as a starting point, set the buffer size equal to the hop size used
# in any processing algorithms.
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/array_input.rb | Ruby | bsd-2-clause | 19 | master | 5,009 | module MB
module Sound
# An input stream that returns chunks from an Array or Numo::NArray.
class ArrayInput
include GraphNode
include GraphNode::IOSampleMixin
attr_reader :channels, :frames, :sample_rate, :offset, :remaining, :buffer_size, :repeat, :repeat_count, :duration
alias leng... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/adsr_envelope.rb | Ruby | bsd-2-clause | 19 | master | 13,328 | module MB
module Sound
# An envelope generator with a traditional attack-decay-sustain-release
# layout. The envelope rises from 0 to +peak+ in #attack_time seconds when
# #trigger(peak) is called, then decays to #sustain_level over #decay_time
# seconds. The envelope stays at #sustain_level until #... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/playback_methods.rb | Ruby | bsd-2-clause | 19 | master | 6,180 | module MB
module Sound
# Command-line interface methods for playing sounds. MB::Sound extends
# itself with this module.
module PlaybackMethods
# Plays a sound file if a String is given, a generated tone if a Tone is
# given, or an audio buffer if an audio buffer is given. If an audio
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/multi_writer.rb | Ruby | bsd-2-clause | 19 | master | 1,823 | module MB
module Sound
# Writes audio to multiple output streams. All output streams must accept
# the same buffer size. If some streams support fewer channels
class MultiWriter
class SampleRateMismatch < ArgumentError; end
class BufferSizeMismatch < ArgumentError; end
class ChannelCou... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/note.rb | Ruby | bsd-2-clause | 19 | master | 5,682 | module MB
module Sound
# Represents a musical note in the 12-tone equal temperament scale, using
# MIDI note numbers.
class Note < Tone
# Major scale intervals (for calculating note name offsets).
SCALE_INTERVAL = [
200,
200,
100,
200,
200,
200
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/sample_rate_helper.rb | Ruby | bsd-2-clause | 19 | master | 3,851 | module MB
module Sound
module GraphNode
# Provides basic support for recursive sample rate changes on a node
# chain. Classes that want to support sample rate changes after
# construction may start by including this module, then overriding the
# sample_rate= method as needed (e.g. to reca... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/input_channel_split.rb | Ruby | bsd-2-clause | 19 | master | 5,643 | require 'forwardable'
module MB
module Sound
module GraphNode
# Splits the channels from an Input with a #read method into separate graph
# nodes for each input channel. Sampling a channel's node twice causes the
# next frame/buffer/window of data to be read from the input.
#
# The... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/resample.rb | Ruby | bsd-2-clause | 19 | master | 8,983 | module MB
module Sound
module GraphNode
# This graph node converts from one sample rate to another. The upstream
# sample rate is detected from the source node.
#
# TODO: should this be a Filter, and/or should we add a Filter variant?
class Resample
include GraphNode
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/constant.rb | Ruby | bsd-2-clause | 19 | master | 6,864 | module MB
module Sound
module GraphNode
# A signal generator (with a #sample method; see GraphNode and Tone)
# that returns a constant numeric value.
class Constant
include GraphNode
include BufferHelper
module NumericConstantMethods
# Converts this numeric val... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl.rb | Ruby | bsd-2-clause | 19 | master | 12,249 | require_relative 'midi_dsl/midi_value'
require_relative 'midi_dsl/midi_cc'
require_relative 'midi_dsl/midi_frequency'
require_relative 'midi_dsl/midi_number'
require_relative 'midi_dsl/midi_envelope'
require_relative 'midi_dsl/midi_tone'
require_relative 'midi_dsl/midi_velocity'
require_relative 'midi_dsl/midi_bend'
re... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/proc_node.rb | Ruby | bsd-2-clause | 19 | master | 2,171 | module MB
module Sound
module GraphNode
# A signal-processing graph node that calls a given Ruby Proc with each
# buffer retrieved from the source, with the result of the Proc returned
# from the #sample method.
class ProcNode
include GraphNode
include SampleRateHelper
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/data_shuffler.rb | Ruby | bsd-2-clause | 19 | master | 1,454 | module MB
module Sound
module GraphNode
# Seamlessly plays samples in a random order over and over.
class DataShuffler
include GraphNode
# TODO: should the data be resampled if we get a new sample rate?
attr_accessor :sample_rate
# Creates a shuffling source with the ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/multitap_delay.rb | Ruby | bsd-2-clause | 19 | master | 8,362 | require 'forwardable'
module MB
module Sound
module GraphNode
# A delay object, simplified from the Filter::Delay class, plus support
# for multiple delay taps from a single input stream.
#
# Use GraphNode#multitap_delay to create a multi-tap delay in a graph.
class MultitapDelay
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/nameable.rb | Ruby | bsd-2-clause | 19 | master | 858 | module MB
module Sound
module GraphNode
# Methods that allow a GraphNode or other objects to have and report an
# object name.
module Nameable
# The name assigned to this object with #named.
attr_reader :graph_node_name
# Gives a name to this graph node to make it easier... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/traversable.rb | Ruby | bsd-2-clause | 19 | master | 6,643 | module MB
module Sound
module GraphNode
# Methods related to building and traversing node graphs. Classes should
# include this if they want to have #sources, #graph, #graph_edges, and
# similar methods.
module Traversable
# Overridden by users of this mixin to return the inputs t... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/complex_node.rb | Ruby | bsd-2-clause | 19 | master | 3,036 | require 'forwardable'
module MB
module Sound
module GraphNode
# Coerces a signal to its real, imaginary, magnitude, or phase component.
class ComplexNode
extend Forwardable
include GraphNode
VALID_MODES = [:real, :imag, :abs, :arg]
MODE_NAMES = {
real: 'Re... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/matrix_mixer.rb | Ruby | bsd-2-clause | 19 | master | 4,130 | require 'forwardable'
module MB
module Sound
module GraphNode
# Uses an MxN matrix (provided as an Array of Arrays, a Matrix, or a 2D
# Numo::NArray) to combine N inputs to M outputs.
class MatrixMixer
include MultiOutput
include Nameable
# Represents a single output no... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/graph_node_array_mixin.rb | Ruby | bsd-2-clause | 19 | master | 970 | module MB
module Sound
module GraphNode
module GraphNodeArrayMixin
# Converts an Array of GraphNodes to an Input with a #read method.
#
# +num_channels+ - Minimum number of channels to return.
# +:buffer_size+ - Buffer size to report to consumers of the Input
# ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/quantize.rb | Ruby | bsd-2-clause | 19 | master | 3,196 | module MB
module Sound
module GraphNode
# This node quantizes the amplitude of incoming audio to a given
# increment.
class Quantize
include GraphNode
include SampleRateHelper
# Sample rate (does not affect behavior of this node).
attr_reader :sample_rate
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/multiplier.rb | Ruby | bsd-2-clause | 19 | master | 8,042 | module MB
module Sound
module GraphNode
# Multiplies zero or more inputs that have a #sample method that takes a
# buffer size parameter, such as an Oscillator or an ADSREnvelope. The
# main uses for this class are for applying envelopes to sounds, and for
# amplitude modulation.
#
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/io_sample_mixin.rb | Ruby | bsd-2-clause | 19 | master | 2,594 | module MB
module Sound
module GraphNode
# Extends any audio I/O object with a #read method with a #sample method
# for compatibility with the arithmetic DSL.
#
# You'll generally also want to include GraphNode in any class that
# includes this module.
module IOSampleMixin
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/tee.rb | Ruby | bsd-2-clause | 19 | master | 7,639 | require 'forwardable'
module MB
module Sound
module GraphNode
# Creates fan-out branches from a signal node (any object that responds
# to #sample and returns a single audio buffer), using buffer copies to
# prevent parallel branches from interfering with each other.
#
# The ideal w... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/reverb.rb | Ruby | bsd-2-clause | 19 | master | 24,456 | require 'set'
module MB
module Sound
module GraphNode
# An artificial reverberation algorithm based on a presentation by
# Geraint Luff at ADC21. The basic algorithm is a number of
# delay-and-mix diffusion steps followed by a feedback delay network.
#
# See MB::Sound::GraphNode#re... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/wavetable.rb | Ruby | bsd-2-clause | 19 | master | 2,935 | module MB
module Sound
module GraphNode
# Implementation of a wavetable waveshaper/synthesizer based on a wave
# table stored as a 2D Numo::NArray.
#
# See bin/make_wavetable.rb.
# See MB::Sound::Wavetable.
# See MB::Sound::GraphNode#wavetable.
class Wavetable
inc... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/buffer_adapter.rb | Ruby | bsd-2-clause | 19 | master | 3,450 | require 'forwardable'
module MB
module Sound
module GraphNode
# A graph node that samples its upstream graph using a different sample
# count from whatever is passed to this node's #sample method.
#
# This works by calling the upstream GraphNode#sample method as many
# times as nece... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/arithmetic_node_helper.rb | Ruby | bsd-2-clause | 19 | master | 3,766 | module MB
module Sound
module GraphNode
# Common functions for nodes that perform arithmetic operations on
# multiple inputs, like Mixer and Mulitiplier.
#
# Any GraphNode using this helper must also include BufferHelper.
module ArithmeticNodeHelper
# TODO: should there be an... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/node_output.rb | Ruby | bsd-2-clause | 19 | master | 585 | module MB
module Sound
module GraphNode
# Interface for an output on a multi-output graph node. Inheritors must
# set @owner to the MultiOutput node that contains them.
module NodeOutput
# Returns the source node for this output. Subclasses may override
# this to bypass the con... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/multi_output.rb | Ruby | bsd-2-clause | 19 | master | 971 | module MB
module Sound
module GraphNode
# Mixin/interface for pseudo-nodes with multiple output nodes, like Tee,
# InputChannelSplit, etc.
module MultiOutput
# When implemented, returns an Array of NodeOutput nodes that may be
# sampled to retrieve the node's individual output va... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/node_sequence.rb | Ruby | bsd-2-clause | 19 | master | 4,396 | module MB
module Sound
module GraphNode
# A signal graph node that switches from input node to input node as each
# input node runs out of data. See GraphNode#and_then.
#
# Note that some input sources, such as IO objects and Tones, will pad
# their outputs to fill an entire buffer ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/mixer.rb | Ruby | bsd-2-clause | 19 | master | 8,933 | module MB
module Sound
module GraphNode
# Sums zero or more inputs that have a #sample method that takes a buffer
# size parameter, such as an Oscillator. One example use of this is as the
# frequency input of an Oscillator. See MB::Sound::Tone#fm.
#
# This is taking a step further... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_number.rb | Ruby | bsd-2-clause | 19 | master | 1,982 | module MB
module Sound
module GraphNode
class MidiDsl
# A graph node that produces a MIDI note number, with optional pitch
# bend, in the original logarithmic scale of MIDI semitones.
class MidiNumber < MidiValue
# Initializes a MIDI number graph node.
#
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_click.rb | Ruby | bsd-2-clause | 19 | master | 1,672 | module MB
module Sound
module GraphNode
class MidiDsl
# Produces a single-sample click whenever a note-on event is received.
# Useful for filter pinging.
class MidiClick
include GraphNode
include GraphNode::SampleRateHelper
# Initializes a MIDI note-on ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_tone.rb | Ruby | bsd-2-clause | 19 | master | 530 | require_relative '../../tone'
module MB
module Sound
module GraphNode
class MidiDsl
# Wraps MB::Sound::Tone with a #sample method that helps MidiDsl manage
# its internal node cache.
class MidiTone < ::MB::Sound::Tone
def initialize(dsl:, frequency:)
super(freq... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_value.rb | Ruby | bsd-2-clause | 19 | master | 1,375 | module MB
module Sound
module GraphNode
class MidiDsl
# Represents a value derived from MIDI inputs. In all cases the default
# output range is 0..1. Generally only used through subclasses.
class MidiValue < ::MB::Sound::GraphNode::Constant
# +:manager+ - MIDI manager for... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_cc.rb | Ruby | bsd-2-clause | 19 | master | 774 | module MB
module Sound
module GraphNode
class MidiDsl
# A graph node that scales MIDI CC values to a given range.
class MidiCc < MidiValue
# Initializes a MIDI-control-change graph node.
#
# See MidiDsl#cc.
def initialize(dsl:, number:, range:, unit:, ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_gate.rb | Ruby | bsd-2-clause | 19 | master | 2,422 | module MB
module Sound
module GraphNode
class MidiDsl
# A graph node that outputs a value based on attack velocity and
# sustain pedal while a note is held or the sustain pedal is pressed.
#
# This class uses velocity to set the initial gate level and half-pedal
# amo... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_envelope.rb | Ruby | bsd-2-clause | 19 | master | 2,137 | module MB
module Sound
module GraphNode
class MidiDsl
# A MIDI-controlled envelope triggered by note on/off events and
# sustain pedal (TODO).
class MidiEnvelope < MB::Sound::ADSREnvelope
def initialize(dsl:, attack:, decay:, sustain:, release:, sample_rate:, range:)
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_frequency.rb | Ruby | bsd-2-clause | 19 | master | 2,317 | module MB
module Sound
module GraphNode
class MidiDsl
# A graph node that scales MIDI note numbers and pitch bend values to
# frequencies in Hz. This is useful for controlling the frequency of
# oscillators or filters.
class MidiFrequency < MidiValue
# Initializes ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_bend.rb | Ruby | bsd-2-clause | 19 | master | 918 | module MB
module Sound
module GraphNode
class MidiDsl
# A graph node that outputs MIDI pitch bend values.
class MidiBend < MidiValue
# Initializes a MIDI pitch bend graph node.
#
# See MidiDsl#bend.
def initialize(dsl:, range:, unit:, si:, sample_rate:... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/graph_node/midi_dsl/midi_velocity.rb | Ruby | bsd-2-clause | 19 | master | 1,307 | module MB
module Sound
module GraphNode
class MidiDsl
# A graph node that outputs the MIDI velocity of the most recently
# pressed note.
class MidiVelocity < MidiValue
# Initializes a MIDI velocity graph node.
#
# See MidiDsl#velocity.
def init... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/filter_chain.rb | Ruby | bsd-2-clause | 19 | master | 4,256 | require 'set'
module MB
module Sound
class Filter
# A linear chain of filters, with the output of one applied to the input of
# the next.
class FilterChain < FilterSet
class FilterDuplicationError < RuntimeError; end
# Initializes a filter chain with the given filters. Filters... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/linear_follower.rb | Ruby | bsd-2-clause | 19 | master | 5,022 | module MB
module Sound
class Filter
# Follows the value (or absolute value) of incoming samples with some
# maximum velocity up or down. If the signal's derivative is always
# lower than the max, then the signal passes unaltered.
#
# If the derivative is greater than the max, then t... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/smoothstep.rb | Ruby | bsd-2-clause | 19 | master | 3,929 | module MB
module Sound
class Filter
# Whenever the incoming sample value changes, this filter draws a
# smoothstep curve of constant length (given to the constructor) from the
# current value to the new value. That is, each step change in the input
# is replaced by a longer smoothstep cur... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/biquad.rb | Ruby | bsd-2-clause | 19 | master | 8,906 | require 'cmath'
module MB
module Sound
class Filter
# Implements a biquad filter with internal state, so new samples can be
# passed in chunks instead of having to process an entire file at once.
#
# See https://shepazu.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html
# See https:... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/first_order.rb | Ruby | bsd-2-clause | 19 | master | 2,114 | module MB
module Sound
class Filter
# Implements first-order low-pass and high-pass filters based on
# experimentation with online filter generators, as well as pole-only (no
# zero) filters.
#
# See http://www.dspguide.com/ch19/2.htm
class FirstOrder < Biquad
FILTER_TY... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/simple_envelope_follower.rb | Ruby | bsd-2-clause | 19 | master | 1,177 | module MB
module Sound
class Filter
# Implements a very simple envelope follower based on instant rise and
# exponential decay.
class SimpleEnvelopeFollower < Filter
attr_reader :decay_db, :decay_s, :decay_per_sample, :sample_rate
# Initializes a simple envelope follower. Peaks... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/filter_set.rb | Ruby | bsd-2-clause | 19 | master | 5,674 | module MB
module Sound
class Filter
# Subclass for multi-filter classes like FilterChain and FilterSum with
# helpers for managing extra inputs, calling multiple filters, etc.
class FilterSet < Filter
class FilterCycleError < RuntimeError; end
class FilterSampleRateError < Runtim... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/filter_sum.rb | Ruby | bsd-2-clause | 19 | master | 2,249 | module MB
module Sound
class Filter
# A parallel set of filters, all fed the same input, with the outputs
# summed.
class FilterSum < FilterSet
# Initializes a filter sum with the given filters. All filters receive
# the original input, and are added to produce the final output.... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/filter_bank.rb | Ruby | bsd-2-clause | 19 | master | 5,975 | module MB
module Sound
class Filter
# An array of identical filters. When called with an array of data to
# process, each filter receives its corresponding element of the array.
class FilterBank < Filter
class << self
# Used by #butterworth and #cookbook to scale filter freque... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/delay.rb | Ruby | bsd-2-clause | 19 | master | 13,639 | module MB
module Sound
class Filter
# A fractionally addressed delay line, allowing dynamic changes of the
# delay time and odd pitch shift effects.
#
# See bin/flanger.rb and bin/tape_delay.rb for examples.
class Delay < Filter
include GraphNode::SampleRateHelper
# ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/cookbook.rb | Ruby | bsd-2-clause | 19 | master | 14,482 | require 'forwardable'
module MB
module Sound
class Filter
# Implements a filter based on Robert Bristow-Johnson's Audio EQ Cookbook
# formulae.
#
# See https://shepazu.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html
# Or see https://webaudio.github.io/Audio-EQ-Cookbook/audio-eq-c... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/gain.rb | Ruby | bsd-2-clause | 19 | master | 934 | module MB
module Sound
class Filter
# A filter that applies a constant gain to its input.
#
# TODO: do we need this? this might be superseded by the graph node system and its mixer and multiplier nodes
class Gain < Filter
# The filter gain (should be an integer or float).
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/hilbert_iir.rb | Ruby | bsd-2-clause | 19 | master | 6,354 | module MB
module Sound
class Filter
# Implements a 6th-order phase difference network that converts a
# real-valued input signal to a complex-valued output signal with the
# cosine and sine components of an analytic signal. Both of these
# components have some varying absolute phase shift... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/sample_wrapper.rb | Ruby | bsd-2-clause | 19 | master | 8,567 | require 'forwardable'
module MB
module Sound
class Filter
# Provides a #sample method that processes another #sample source through
# a Filter. It's easiest to use the MB::Sound::Filter#wrap method or the
# MB::Sound::GraphNode#filter method to create a sample wrapper.
#
# Example:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.