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 | taikii/redmine_custom_auto_complete | https://github.com/taikii/redmine_custom_auto_complete | lib/custom_auto_complete_hook.rb | Ruby | mit | 19 | master | 809 | class CustomAutoCompleteHook < Redmine::Hook::ViewListener
def view_issues_form_details_bottom(context={})
html = ""
if User.current.allowed_to?(:redmine_custom_auto_complete, Project.find(context[:issue].project_id))
context[:issue].available_custom_fields.each do |field|
if field.is_a?(IssueC... |
github | taw/rlisp | https://github.com/taw/rlisp | Rakefile | Ruby | mit | 19 | master | 5,962 | require 'time'
task :default => :build
desc "Build everything"
task :build => ["rlisp", "doc/rlisp.1"]
desc "Build RLisp package (deb)"
task :deb => :build do
sh "dpkg-buildpackage -rfakeroot -us -uc"
end
# This is ugly, but beats doing it all by hand
#
# TODO: We could take topdir from ~/.rpmmacros
desc "Build R... |
github | taw/rlisp | https://github.com/taw/rlisp | src/rlisp.rb | Ruby | mit | 19 | master | 26,950 | #!/usr/bin/env ruby
$:.unshift File.dirname(__FILE__)
require 'rlisp_support'
require 'rlisp_grammar'
require 'stringio'
require 'optparse'
require 'readline'
RLISP_VERSION="0.1.20070617"
RLISP_PATH=if ENV["RLISP_PATH"] then ENV["RLISP_PATH"].split(/:/) else [File.dirname(__FILE__), "/usr/lib/rlisp", "/usr/local/lib... |
github | taw/rlisp | https://github.com/taw/rlisp | src/rlisp_highlighter.rb | Ruby | mit | 19 | master | 4,595 | #!/usr/bin/ruby
require 'rlisp_grammar'
Highlighted_symbols = %w{
do if let set! fn letmacro
send quote quasiquote unquote unquote-splicing
defun defmacro
false true nil self
cond and or hash match case
& .
}
class RLispHighlighter
# It does very minimal parsing, just grouping ( ... )
def self.parse_... |
github | taw/rlisp | https://github.com/taw/rlisp | src/rlisp_indent.rb | Ruby | mit | 19 | master | 1,603 | #!/usr/bin/ruby
require 'rlisp_grammar'
module RLispIndent
def self.indent(code)
tokens = RLispGrammarAlternative.tokenize(code)
level = 0
correction_list = []
tokens.each_with_index{|(tok, cls), i|
case cls
when :open, :sqopen
level += 1
when :close, :sqclose
lev... |
github | taw/rlisp | https://github.com/taw/rlisp | src/rlisp_support.rb | Ruby | mit | 19 | master | 2,343 | # Lisp pretty-printing
# pretty_id support
#
# NOTE:
# Per-class pretty_id - it's not quite cool, because we sometimes
# want X and Y<X to have the same ids and sometimes don't,
# e.g. we definitely do not want all subclases of Object to share ids
# but we'd like subclasses of Opcode to do so.
#
# In such case overlo... |
github | taw/rlisp | https://github.com/taw/rlisp | src/rlisp_grammar.rb | Ruby | mit | 19 | master | 10,548 | class RLispGrammar
def initialize(input, file_name="example.rl")
if input.is_a? String
@input = nil
@buf = input.dup
@eof = true
else
@input = input
@buf = ""
@eof = false
end
@tokens = []
@file_name = file_name
@line = 1
@column = 0
end
def get_... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_support.rb | Ruby | mit | 19 | master | 2,243 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp'
class Test_RLisp_support < Minitest::Test
def test_variable
a = Variable.new
assert_nil(a.get)
a.set "foo"
assert_equal("foo", a.get)
a.set "bar"
assert_equal("bar", a.get)
end
def test_to_s_lisp
cases = [
[0, "0"]... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_all.rb | Ruby | mit | 19 | master | 646 | #!/usr/bin/env ruby
$:.unshift File.dirname(__FILE__)
$:.unshift File.dirname(__FILE__) + "/../src"
require 'test_parser'
require 'test_rlvm'
require 'test_rlisp'
require 'test_run'
require 'test_support'
require 'test_indent'
require 'test_highlighter'
require 'test_tokenizer'
RLISP_PATH << File.dirname(__FILE__)
R... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_run.rb | Ruby | mit | 19 | master | 6,086 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp'
class Test_RLisp_Run < Minitest::Test
def bin_rlisp
"./src/rlisp.rb"
end
def assert_runs(program, expected_output)
actual_output = `#{bin_rlisp} tests/#{program}.rl`
expected_output = expected_output.gsub(/^ {4}/, "").sub(/^\n/,"")
... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_highlighter.rb | Ruby | mit | 19 | master | 4,900 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp_highlighter'
class Test_Indent < Minitest::Test
def assert_highlights(code_out,code_in)
highlighted = RLispHighlighter.highlight_html(code_in)
header = "<html><head><title>Highlighted RLisp example</title></head><body><pre>"
footer = "</pre><... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_parser.rb | Ruby | mit | 19 | master | 3,497 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp'
##
# Passes if +expected+.eql?(+actual).
#
# Note that the ordering of arguments is important, since a helpful
# error message is generated when this one fails that tells you the
# values of expected and actual.
#
# Example:
# assert_eql 'MY STRING', 'm... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_tokenizer.rb | Ruby | mit | 19 | master | 2,057 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp'
class Test_Tokenizer < Minitest::Test
def test_tokenizer
code = '2.3 4 , ,@ ` ( ) [ ] foo bar x-y u19 #t #f bah "foo" "bar #{ 3 }" "#{1}" [] []= "#{a} #{b} #{c}"'
rg = RLispGrammar.new(code)
assert_equal([:expr, 2.3, 1, 0], rg.get_token)
... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_rlvm.rb | Ruby | mit | 19 | master | 6,864 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp'
class Test_RLVM_Ruby < Minitest::Test
def assert_compiles(code, expected, test_id)
expr = RLispGrammar.new(code).expr
expected = expected.gsub(/^ {4}/, "").sub(/^\n/,"")
expected = expected.gsub(/^ */, "").gsub(/;/,"\n").chomp
actual =... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_indent.rb | Ruby | mit | 19 | master | 1,272 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp_indent'
class Test_Indent < Minitest::Test
def assert_indent(code_out,code_in)
assert_equal(code_out,RLispIndent.indent(code_in))
end
def test_indent
assert_indent(<<OUT, <<IN)
(let a (+ 1 2))
(let b (+ 3 4))
OUT
(let a (+ 1 2))
(let b (+ 3... |
github | taw/rlisp | https://github.com/taw/rlisp | tests/test_rlisp.rb | Ruby | mit | 19 | master | 13,817 | #!/usr/bin/env ruby
require "minitest/autorun"
require 'rlisp'
##
# Passes if +expected+.eql?(+actual).
#
# Note that the ordering of arguments is important, since a helpful
# error message is generated when this one fails that tells you the
# values of expected and actual.
#
# Example:
# assert_eql 'MY STRING', 'm... |
github | taw/rlisp | https://github.com/taw/rlisp | benchmarks/ruby/ary.ruby | Ruby | mit | 19 | master | 395 | #!/usr/bin/env ruby
# -*- mode: ruby -*-
# $Id: ary.ruby,v 1.3 2004/06/20 08:39:45 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# with help from Paul Brannan and Mark Hubbart
n = Integer(ARGV.shift || 1)
x = Array.new(n)
y = Array.new(n, 0)
for i in 0 ... n
x[i] = i + 1
end
(0 .. 999).each do
(n-1).st... |
github | taw/rlisp | https://github.com/taw/rlisp | benchmarks/ruby/ackermann.ruby | Ruby | mit | 19 | master | 352 | #!/usr/bin/env ruby
# -*- mode: ruby -*-
# $Id: ackermann.ruby,v 1.2 2005/06/10 00:57:22 igouy-guest Exp $
# http://www.bagley.org/~doug/shootout/
def ack(m, n)
if m == 0 then
n + 1
elsif n == 0 then
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end
NUM = Integer(ARGV.shift || 1)
print "Ack(3,"... |
github | taw/rlisp | https://github.com/taw/rlisp | examples/ar_albums.rb | Ruby | mit | 19 | master | 2,335 | #!/usr/bin/ruby
# Example from http://snippets.dzone.com/posts/show/3097
# Copyright © Mike Wilson
# With permission from the author
require 'rubygems'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = false
ActiveRecord::Base.establish_connection(
:adapte... |
github | taw/rlisp | https://github.com/taw/rlisp | examples/http_server_hello.rb | Ruby | mit | 19 | master | 409 | #!/usr/bin/ruby
require 'webrick'
# Configure the server
config = {:Port => 1337}
# Tell the class to make us a server object
server = WEBrick::HTTPServer.new(config)
# Tell server to call our Hello World handler
server.mount_proc("/hello") {|req,res|
res.body = "<html><body><h3>Hello, world!</h3></body></ht... |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | Rakefile | Ruby | mit | 19 | main | 223 | require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "appraisal"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
task :default => :appraisal
end |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | Appraisals | Ruby | mit | 19 | main | 439 | appraise "rspec-3-0" do
gem "rspec", "~> 3.0.0"
end
appraise "rspec-3-1" do
gem "rspec", "~> 3.1.0"
end
appraise "rspec-3-2" do
gem "rspec", "~> 3.2.0"
end
appraise "rspec-3-3" do
gem "rspec", "~> 3.3.0"
end
appraise "rspec-3-4" do
gem "rspec", "~> 3.4.0"
end
appraise "rspec-3-5" do
gem "rspec", "~> 3.... |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | rspec-buildkite.gemspec | Ruby | mit | 19 | main | 927 | lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "rspec/buildkite/version"
Gem::Specification.new do |spec|
spec.name = "rspec-buildkite"
spec.version = RSpec::Buildkite::VERSION
spec.author = "Samuel Cochran"
spec.email = "sj2... |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | lib/rspec/buildkite/recolorizer.rb | Ruby | mit | 19 | main | 1,560 | # frozen_string_literal: true
module RSpec::Buildkite
module Recolorizer
module_function
# Re-color an ANSI-colorized string using terminal CSS classes:
# https://github.com/buildkite/terminal/blob/05a77905c468b9150cac41298fdb8a0735024d42/style.go#L34
def recolorize(string)
level = 0
str... |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | lib/rspec/buildkite/annotation_formatter.rb | Ruby | mit | 19 | main | 2,564 | # frozen_string_literal: true
require "thread"
require "rspec/core"
require "rspec/buildkite/recolorizer"
module RSpec::Buildkite
# Create a Buildkite annotation for RSpec failures
#
# Help folks fix their builds as soon as possible when failures crop up by
# calling out failures in an annotation, even while... |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | spec/spec_helper.rb | Ruby | mit | 19 | main | 389 | require "bundler/setup"
require "coderay"
require "rspec/buildkite"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
... |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | spec/rspec/buildkite_spec.rb | Ruby | mit | 19 | main | 316 | RSpec.describe RSpec::Buildkite do
it "has a version number" do
expect(RSpec::Buildkite::VERSION).not_to be nil
end
it "does something useful" do
sleep(5)
expect(false).to eq(true)
sleep(5)
end
it "fails several times" do
sleep(5)
expect(false).to eq(true)
sleep(5)
end
end |
github | buildkite/rspec-buildkite | https://github.com/buildkite/rspec-buildkite | spec/rspec/buildkite/recolorizer_spec.rb | Ruby | mit | 19 | main | 1,565 | # frozen_string_literal: true
RSpec.describe RSpec::Buildkite::Recolorizer do
describe ".recolorize" do
it "converts ANSI color codes to HTML spans" do
input = "\e[31mred text\e[0m"
result = described_class.recolorize(input)
expect(result).to include('class="term-fg31"')
expect(result).t... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | Rakefile | Ruby | bsd-2-clause | 19 | master | 561 | require "bundler/gem_tasks"
require 'rake/extensiontask'
task :default => :spec
Rake::ExtensionTask.new 'mb-fast_sound' do |ext|
ext.name = 'fast_sound'
ext.ext_dir = 'ext/mb/fast_sound'
ext.lib_dir = 'lib/mb'
end
Rake::ExtensionTask.new 'mb-sound-fast_resample' do |ext|
ext.name = 'fast_resample'
ext.ext_... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | Gemfile | Ruby | bsd-2-clause | 19 | master | 346 | # frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
gemspec
gem 'readline', require: true
gem 'mb-math', github: 'mike-bourgeous/mb-math.git'
gem 'mb-util', github: 'mike-bourgeous/mb-util.git'
gem 'mb-sound-jackffi', github: 'mike-bourge... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | mb-sound.gemspec | Ruby | bsd-2-clause | 19 | master | 3,013 | require_relative 'lib/mb/sound/version'
Gem::Specification.new do |spec|
spec.name = "mb-sound"
spec.version = MB::Sound::VERSION
spec.authors = ["Mike Bourgeous"]
spec.email = ["mike@mikebourgeous.com"]
spec.summary = %q{A library of simple Ruby tools for processing sound... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | experiments/noise_generation/pink_noise_gain_experiment.rb | Ruby | bsd-2-clause | 19 | master | 1,737 | #!/usr/bin/env ruby
# An experiment to determine reasonable frequency domain amplitudes for
# generating pink noise in a range of -1..1 in the time domain by using
# descending gain with random phase.
require 'rubygems'
require 'bundler/setup'
require 'pry'
require 'pry-byebug'
$LOAD_PATH << File.expand_path('../../... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | experiments/noise_generation/white_noise_gain_experiment.rb | Ruby | bsd-2-clause | 19 | master | 1,375 | #!/usr/bin/env ruby
# An experiment to determine reasonable frequency domain amplitudes for
# generating white noise in a range of -1..1 in the time domain by using
# constant gain with random phase.
require 'bundler/setup'
require 'pry'
require 'pry-byebug'
$LOAD_PATH << File.expand_path('../../lib', __dir__)
requ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | experiments/noise_generation/brown_noise_gain_experiment.rb | Ruby | bsd-2-clause | 19 | master | 1,740 | #!/usr/bin/env ruby
# An experiment to determine reasonable frequency domain amplitudes for
# generating brown noise in a range of -1..1 in the time domain by using
# descending gain with random phase.
require 'rubygems'
require 'bundler/setup'
require 'pry'
require 'pry-byebug'
$LOAD_PATH << File.expand_path('../..... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | ext/mb/fast_sound/extconf.rb | Ruby | bsd-2-clause | 19 | master | 836 | require 'mkmf'
# This require line ensures that the narray gem spec is loaded when installing this extension
require 'numo/narray'
# Used numo-pocketfft as a reference for finding narray.h
# https://github.com/yoshoku/numo-pocketfft/blob/1ab489b165d4cde06b6d3a443ed9bfbc8e5c69d0/ext/numo/pocketfft/extconf.rb
# https:/... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | ext/mb/sound/fast_resample/extconf.rb | Ruby | bsd-2-clause | 19 | master | 988 | require 'mkmf'
# This require line ensures that the narray gem spec is loaded when installing this extension
require 'numo/narray'
# Used numo-pocketfft as a reference for finding narray.h
# https://github.com/yoshoku/numo-pocketfft/blob/1ab489b165d4cde06b6d3a443ed9bfbc8e5c69d0/ext/numo/pocketfft/extconf.rb
# https:/... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | ext/mb/sound/fast_wavetable/extconf.rb | Ruby | bsd-2-clause | 19 | master | 846 | require 'mkmf'
# This require line ensures that the narray gem spec is loaded when installing this extension
require 'numo/narray'
# Used numo-pocketfft as a reference for finding narray.h
# https://github.com/yoshoku/numo-pocketfft/blob/1ab489b165d4cde06b6d3a443ed9bfbc8e5c69d0/ext/numo/pocketfft/extconf.rb
# https:/... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/spec_helper.rb | Ruby | bsd-2-clause | 19 | master | 5,363 | require 'fileutils'
require 'simplecov'
SimpleCov.start do
track_files("bin/**/*.rb")
enable_coverage :branch
end
# Ensure subprocesses load simplecov
require 'shellwords'
ENV['RUBYOPT'] = "-r#{File.join(__dir__, 'simplecov_helper.rb')}"
ENV['GLHTUI'] = '0' # FIXME: still can't run rspec when injecting plotter
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/simplecov_helper.rb | Ruby | bsd-2-clause | 19 | master | 427 | # File to be included via simplecov_runner.rb when testing standalone scripts from bin/
require 'securerandom'
require 'simplecov'
SimpleCov.start do
command_name "#{$0} #{$$} #{SecureRandom.uuid}"
formatter SimpleCov::Formatter::SimpleFormatter
minimum_coverage 0
enable_coverage :branch
end
# This require li... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/write_noise_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,522 | RSpec.describe('Noise generation scripts') do
let(:output) { 'tmp/write_noise_test.flac' }
let(:out_sound) { MB::Sound.read(output) }
before(:each) do
FileUtils.mkdir_p('tmp')
File.unlink(output) rescue nil
end
['brown', 'pink', 'white'].each do |n|
describe "bin/write_#{n}_noise.rb" do
it... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/plot_windows_spec.rb | Ruby | bsd-2-clause | 19 | master | 668 | RSpec.describe('bin/plot_windows.rb') do
it 'can be called without arguments' do
text = `PLOT_TERMINAL=dumb PLOT_WIDTH=800 PLOT_HEIGHT=800 bin/plot_windows.rb 2>&1`
expect($?).to be_success
expect(text).to match(/----.*\*.*----/m)
text.gsub!(/[^A-Za-z0-9]+/, ' ')
MB::Sound::Window.windows.each do... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/sound_spec.rb | Ruby | bsd-2-clause | 19 | master | 556 | RSpec.describe('bin/sound.rb', :aggregate_failures) do
it 'can start up and plot a sine wave' do
raw_text = `printf "plot 123.hz\nexit\n" | bin/sound.rb`
result = $?
output = MB::U.remove_ansi(raw_text)
expect(result).to be_success
expect(output).to include('Welcome to the'), 'shows the welcome t... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/tape_delay_spec.rb | Ruby | bsd-2-clause | 19 | master | 985 | RSpec.describe('bin/tape_delay.rb') do
let(:outfile) { 'tmp/tape_delay_output.flac' }
before do
FileUtils.mkdir_p(File.dirname(outfile))
File.unlink(outfile) if File.exist?(outfile)
end
it 'can generate an output file' do
output = `bin/tape_delay.rb --quiet sounds/piano0.flac #{outfile} 2>&1`
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/plot_waveforms_spec.rb | Ruby | bsd-2-clause | 19 | master | 330 | RSpec.describe('bin/plot_waveforms.rb') do
it 'plots all the waveforms' do
text = `PLOT_TERMINAL=dumb PLOT_WIDTH=800 PLOT_HEIGHT=800 bin/plot_waveforms.rb 2>&1 < /dev/null`
expect($?).to be_success
MB::Sound::Oscillator::WAVE_TYPES.each do |o|
expect(text).to include(o.to_s.gsub('_', ' '))
end
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/phase_synth_spec.rb | Ruby | bsd-2-clause | 19 | master | 597 | RSpec.describe('bin/phase_synth.rb') do
before(:each) {
FileUtils.mkdir_p('tmp')
File.unlink('tmp/phase_synth_test.flac') rescue nil
}
it 'can generate an audio file of the expected length' do
text = `bin/phase_synth.rb tmp/phase_synth_test.flac 300 0 1 45 1 90 1 135 1 180 1 135 1 90 1 47 1 0 1`
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/play_noise_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,075 | require 'benchmark'
RSpec.describe('bin/play_noise.rb') do
let(:test_sequence) {
# Each 10x gain increment/decrement line delays by about half a second
<<-EOF.gsub(/\s+/, '')
#{'-+' * 10}
b
#{'-+' * 10}
w
#{'-+' * 10}
p
#{'-+' * 10}
!
#{'<' * 10}
#{'>' * 10}
~
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/midi_roll_spec.rb | Ruby | bsd-2-clause | 19 | master | 4,263 | RSpec.describe('bin/midi_roll.rb', :aggregate_failures) do
def run(cmd, success = true)
`#{cmd}`.tap { |text|
result = $?
if success != result.success?
MB::U.headline("failing text from #{result}")
puts text
end
expect(result.success?).to eq(success)
}
end
it 'can ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/make_wavetable_spec.rb | Ruby | bsd-2-clause | 19 | master | 846 | RSpec.describe('bin/make_wavetable.rb', aggregate_failures: true) do
let(:name) { 'tmp/make_wavetable_test.flac' }
before(:each) do
FileUtils.mkdir_p('tmp')
File.unlink(name) rescue nil
end
it 'can make a wavetable from a piano note' do
text = `bin/make_wavetable.rb --quiet sounds/piano_120hz_b2.f... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/reverb_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,041 | RSpec.describe('bin/reverb.rb') do
before do
FileUtils.mkdir_p('tmp/')
end
it 'can create an output file from an input file' do
output = `bin/reverb.rb -f -q sounds/piano0.flac tmp/reverb_test.flac 2>&1`
expect($?).to be_success, "bin/reverb.rb failed: #{output}"
expect(MB::Sound::FFMPEGInput.par... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/midi_info_spec.rb | Ruby | bsd-2-clause | 19 | master | 243 | RSpec.describe('bin/midi_info.rb') do
it 'can show MIDI info' do
text = `bin/midi_info.rb spec/test_data/midi.mid 2>&1`
expect($?).to be_success
expect(text).to include('Events')
expect(text).to include('Unnamed')
end
end |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/freq_estimate_spec.rb | Ruby | bsd-2-clause | 19 | master | 433 | RSpec.describe('bin/freq_estimate.rb') do
it 'prints the expected value for a sine wave' do
text = `bin/freq_estimate.rb sounds/sine/sine_100_1s_mono.flac`
expect($?).to be_success
expect(text.strip).to eq('100Hz')
end
it 'prints the expected value of a single piano note' do
text = `bin/freq_esti... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/info_spec.rb | Ruby | bsd-2-clause | 19 | master | 353 | RSpec.describe('bin/info.rb') do
it 'can print help' do
expect(MB::U.remove_ansi(`bin/info.rb --help`)).to include('bin/info.rb filename')
expect($?).not_to be_success
end
it 'can parse a FLAC file' do
expect(MB::U.remove_ansi(`bin/info.rb sounds/piano0.flac`)).to include(/sample_rate.*48000/)
ex... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/node_graph_benchmark_spec.rb | Ruby | bsd-2-clause | 19 | master | 520 | require 'fileutils'
require 'shellwords'
RSpec.describe('bin/songs/node_graph_benchmark.rb') do
let(:outfile) { 'tmp/node_graph_output.flac' }
it 'can save the song to a file' do
FileUtils.mkdir_p(File.dirname(outfile))
output = `LOOP_COUNT=60 bin/songs/node_graph_benchmark.rb #{outfile.shellescape} --ov... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/haas_pan_spec.rb | Ruby | bsd-2-clause | 19 | master | 828 | RSpec.describe('bin/haas_pan.rb') do
before(:each) do
FileUtils.mkdir_p('tmp')
File.unlink('tmp/haas_pan_test.flac') rescue nil
end
it 'generates a 2ch output file' do
text = `bin/haas_pan.rb sounds/synth0.flac tmp/haas_pan_test.flac 0 100 1 -100 2 100 3 0 4 0`
result = $?
raise "ERROR: #{MB:... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/resample_benchmark_spec.rb | Ruby | bsd-2-clause | 19 | master | 245 | RSpec.describe('bin/resample_benchmark.rb') do
it 'runs' do
text = `SAMPLES=48000 bin/resample_benchmark.rb 2>&1`
expect($?).to be_success
expect(text).to include('upsampling')
expect(text).to include('downsampling')
end
end |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/bin/matrix_process_spec.rb | Ruby | bsd-2-clause | 19 | master | 3,435 | RSpec.describe('bin/matrix_process.rb') do
before(:each) do
FileUtils.mkdir_p('tmp')
File.unlink('tmp/matrix_process_test.flac') rescue nil
File.unlink('tmp/matrix_process_qs.flac') rescue nil
File.unlink('tmp/matrix_process_qs_enc.flac') rescue nil
end
it 'can convert a 2ch file to a 4ch file' d... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,957 | require 'fileutils'
RSpec.describe MB::Sound do
describe '.apply_filter' do
it 'reduces the amplitude of high frequencies more than low frequencies in lowpass mode' do
low = MB::Sound.apply_filter(123.hz.at(0.1), frequency: 1000, quality: 0.5)
low_gain = low[0].abs.max / 0.1
high = MB::Sound.a... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/fast_sound_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,511 | RSpec.describe(MB::FastSound) do
[:smoothstep, :smootherstep].each do |m_base|
m = "#{m_base}_buf".to_sym
describe ".#{m}" do
[Numo::SFloat, Numo::SComplex].each do |cls|
context "(#{cls})" do
let(:expected) {
Numo::SFloat.zeros(752).inplace.map_with_index { |v, idx|
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/note_spec.rb | Ruby | bsd-2-clause | 19 | master | 9,402 | RSpec.describe MB::Sound::Note do
describe '#initialize' do
context 'when given a MIDI note number' do
let!(:note_names) {
[
'C',
'Cs',
'D',
'Ds',
'E',
'F',
'Fs',
'G',
'Gs',
'A',
'As',
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/adsr_envelope_spec.rb | Ruby | bsd-2-clause | 19 | master | 11,680 | RSpec.describe(MB::Sound::ADSREnvelope, :aggregate_failures) do
let(:env) {
MB::Sound::ADSREnvelope.new(
attack_time: 0.1,
decay_time: 0.2,
sustain_level: 0.75,
release_time: 0.5,
sample_rate: 48000
)
}
it 'produces the expected attack/decay curve and sustain level' do
e... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/analysis_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 486 | RSpec.describe(MB::Sound::AnalysisMethods) do
pending '#crosscorrelate'
pending '#peak_correlation'
describe '#freq_estimate' do
it 'works with complex values' do
data = 150.hz.complex_ramp.sample(48000)
expect(MB::Sound.freq_estimate(data).round(6)).to eq(150)
end
it 'returns nil if no ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/oscillator_spec.rb | Ruby | bsd-2-clause | 19 | master | 19,850 | RSpec.describe MB::Sound::Oscillator do
[:value_at, :value_at_c, :value_at_ruby].each do |method|
describe "##{method}" do
it 'returns expected sine wave values for given phases' do
lfo = MB::Sound::Oscillator.new(:sine)
expect(lfo.send(method, 0).round(6)).to eq(0)
expect(lfo.send(m... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/playback_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 730 | RSpec.describe(MB::Sound::PlaybackMethods) do
before(:each) do
ENV['OUTPUT_TYPE'] = 'null'
end
after(:each) do
ENV.delete('OUTPUT_TYPE')
end
describe '#play' do
it 'can play a sound file' do
expect(Kernel).to receive(:sleep).at_least(10).times
expect_any_instance_of(MB::Sound::NullOu... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/input_buffer_wrapper_spec.rb | Ruby | bsd-2-clause | 19 | master | 5,227 | RSpec.describe(MB::Sound::InputBufferWrapper, :aggregate_failures) do
let(:buffer_size) { 7 }
let(:length) { 100 }
let(:c1) { 12000.hz.square.at(1).with_phase(0.0000001).sample(length) }
let(:c2) { 8000.hz.square.at(-1).with_phase(0.0000001).sample(length) }
let(:c3) { 6000.hz.square.at(1).with_phase(0.000000... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/window_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 3,306 | require 'fileutils'
RSpec.describe(MB::Sound::WindowMethods) do
describe '#process' do
let(:input) { 'sounds/synth0.flac' }
let(:output) { 'tmp/process_test.flac' }
let(:in_sound) { MB::Sound.read(input) }
let(:out_sound) { MB::Sound.read(output) }
before(:each) do
FileUtils.mkdir_p('tmp')... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/plot_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 10,652 | RSpec.describe(MB::Sound::PlotMethods) do
before(:each) do
ENV['PLOT_TERMINAL'] = 'dumb'
ENV['PLOT_WIDTH'] = '80'
ENV['PLOT_HEIGHT'] = '40'
MB::Sound.close_plotter
MB::Sound.plotter(width: 80, height: 40).print = false
end
after(:each) do
ENV.delete('PLOT_TERMINAL')
ENV.delete('PLOT_W... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/gain_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 6,269 | RSpec.describe(MB::Sound::GainMethods) do
describe '#normalize_max' do
let(:loud_sound_orig) { Numo::SFloat[0.1, 0.3, 0.5, 2.5, 1.5].freeze }
let(:quiet_sound_orig) { Numo::DFloat[0.2, 0.3, 0.4, 0.3].freeze }
let(:both_orig) { [loud_sound_orig, quiet_sound_orig].freeze }
let(:multi_orig) { [loud_sound... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/haas_pan_spec.rb | Ruby | bsd-2-clause | 19 | master | 2,669 | RSpec.describe(MB::Sound::HaasPan) do
let(:d_default) { MB::Sound::HaasPan.new }
let(:d_32k_r) { MB::Sound::HaasPan.new(delay: 0.1, sample_rate: 32000) }
let(:d_44k1_l) { MB::Sound::HaasPan.new(delay: -0.2, sample_rate: 44100) }
describe '#initialize' do
it 'can be constructed with no parameters' do
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/process_reader_spec.rb | Ruby | bsd-2-clause | 19 | master | 808 | RSpec.describe(MB::Sound::ProcessReader) do
it 'processes read audio through the block given to the constructor' do
d = Numo::SFloat[1,2,3,4,5,6,7,8].freeze
ai = MB::Sound::ArrayInput.new(data: [d].freeze, buffer_size: 2)
pr = MB::Sound::ProcessReader.new(ai) do |data|
data.map { |c| -2 * c }
en... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/output_buffer_wrapper_spec.rb | Ruby | bsd-2-clause | 19 | master | 5,212 | RSpec.describe(MB::Sound::OutputBufferWrapper, :aggregate_failures) do
let(:buffer_size) { 7 }
let(:length) { 100 }
let(:c1) { 12000.hz.square.at(1).with_phase(0.0000001).sample(length) }
let(:c2) { 8000.hz.square.at(-1).with_phase(0.0000001).sample(length) }
let(:c3) { 6000.hz.square.at(1).with_phase(0.00000... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/array_input_spec.rb | Ruby | bsd-2-clause | 19 | master | 9,996 | RSpec.describe(MB::Sound::ArrayInput, :aggregate_failures) do
describe '#initialize' do
let(:input) {
MB::Sound::ArrayInput.new(data: data, sample_rate: 1)
}
it 'wraps a bare NArray as a single-channel array' do
arr = MB::Sound::ArrayInput.new(data: Numo::SFloat[1, 2, 3, 4, 5])
expect(a... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/io_logger_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,206 | require 'stringio'
RSpec.describe(MB::Sound::IOLogger, :aggregate_failures) do
let(:filename) { 'sounds/piano0.flac' }
let(:file) { MB::Sound.file_input(filename) }
let(:nulloutput) { MB::Sound::NullOutput.new(channels: 2) }
it 'can attach to a file input' do
file.singleton_class.prepend(MB::Sound::IOLogg... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/complex_pan_spec.rb | Ruby | bsd-2-clause | 19 | master | 3,022 | RSpec.describe(MB::Sound::ComplexPan) do
let(:f45) { MB::Sound::ComplexPan.new }
describe '#process' do
it 'can process a single input' do
expect(f45.process(1)).to eq([0.5 ** 0.75, 0.5 ** 0.75])
end
it 'can process Numo::SFloat' do
data = Numo::SFloat[-1, 0, 1]
expected = [Numo::SFl... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/circular_buffer_spec.rb | Ruby | bsd-2-clause | 19 | master | 12,504 | RSpec.describe(MB::Sound::CircularBuffer, :aggregate_failures) do
let(:cbuf) { MB::Sound::CircularBuffer.new(buffer_size: 7) }
describe '::Reader' do
describe '#read' do
it 'can adapt to changes in data type' do
r1 = cbuf.reader
r2 = cbuf.reader(1)
cbuf.write(Numo::SFloat[1,2,3,4]... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/ffmpeg_output_spec.rb | Ruby | bsd-2-clause | 19 | master | 4,673 | require 'fileutils'
RSpec.describe MB::Sound::FFMPEGOutput do
let(:test_data) {
[
Numo::SFloat[0, 0.5, -0.5, 0],
Numo::SFloat[0, -0.75, 0.25, 0],
Numo::SFloat[0, -0.25, 0.75, 0],
]
}
before(:each) do
FileUtils.mkdir_p('./tmp')
File.unlink('./tmp/test_out.flac') rescue nil
F... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/filter_spec.rb | Ruby | bsd-2-clause | 19 | master | 843 | RSpec.describe(MB::Sound::Filter) do
describe '#double_process' do
pending
end
describe '#chain' do
it 'returns a filter chain that contains the two starting filters' do
f1 = 123.hz.highpass
f2 = 1000.hz.lowpass
chain = f1.chain(f2)
expect(chain).to be_a(MB::Sound::Filter::FilterC... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/window_reader_spec.rb | Ruby | bsd-2-clause | 19 | master | 2,393 | RSpec.describe MB::Sound::WindowReader do
describe '#read' do
def read_everything(frames:, window_size:, hop:, fill_value:)
w = MB::Sound::Window::DoubleHann.new(1024)
w.force_hop(hop)
ni = MB::Sound::NullInput.new(channels: 1, length: frames, fill: fill_value, strict_buffer_size: true)
w... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/graph_node_input_spec.rb | Ruby | bsd-2-clause | 19 | master | 5,522 | RSpec.describe(MB::Sound::GraphNodeInput, :aggregate_failures) do
describe '#initialize' do
it 'accepts an Array of nodes' do
gni = MB::Sound::GraphNodeInput.new([1.constant, 2.constant])
expect(gni.read(1)).to eq([Numo::SFloat[1], Numo::SFloat[2]])
end
it 'accepts a variable argument list of... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/multi_writer_spec.rb | Ruby | bsd-2-clause | 19 | master | 4,851 | RSpec.describe(MB::Sound::MultiWriter) do
let(:null_out_1) { MB::Sound::NullOutput.new(channels: 1, sleep: false) }
let(:null_out_2) { MB::Sound::NullOutput.new(channels: 2, sleep: false) }
let(:null_out_5) { MB::Sound::NullOutput.new(channels: 5, sleep: false) }
let(:null_out_44k) { MB::Sound::NullOutput.new(c... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/io_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 8,734 | RSpec.describe(MB::Sound::IOMethods) do
describe '#input' do
it 'returns the same input when called twice with the same options' do
o1 = MB::Sound.input(device: :null)
o2 = MB::Sound.input(device: :null)
expect(o1).to equal(o2)
end
it 'returns a different input when called with differen... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/fft_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 18,298 | # FFTMethods are tested via Sound
RSpec.describe(MB::Sound::FFTMethods) do
[:fft, :real_fft].each do |m|
describe "##{m}" do
it 'can process a Tone object' do
fft = MB::Sound.send(m, 4000.hz.at(1).for(1))
expect(fft.abs.max_index).to eq(4000)
expect(fft[4000].abs.round(3)).to eq(1)
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/softest_clip_spec.rb | Ruby | bsd-2-clause | 19 | master | 4,508 | RSpec.describe(MB::Sound::SoftestClip) do
let(:data) { Numo::SFloat.linspace(-3, 3, 101) }
it 'rejects a limit that is less than the threshold' do
expect { MB::Sound::SoftestClip.new(threshold: 1, limit: 0.9) }.to raise_error(/limit/i)
end
it 'can start the hyperbolic section at 0' do
c = MB::Sound::S... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/loopback_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,981 | RSpec.describe(MB::Sound::Loopback) do
let(:lo) { MB::Sound::Loopback.new(channels: 3, buffer_size: 123) }
it 'returns all zeros if nothing has been written' do
5.times do
expect(lo.read).to eq([Numo::SFloat.zeros(123)] * 3)
end
end
it 'returns data in the order it was written' do
5.times do... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/numeric_sound_mixins_spec.rb | Ruby | bsd-2-clause | 19 | master | 5,549 | RSpec.describe(MB::Sound::NumericSoundMixins) do
describe MB::Sound::NumericSoundMixins::Meters do
it 'can be converted to feet' do
expect(1.meter.feet).to be_a(MB::Sound::NumericSoundMixins::Feet)
expect(1.meter.feet).to eq(100 / 2.54 / 12.0)
end
it 'pluralizes' do
# https://en.wikiped... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/generation_methods_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,195 | RSpec.describe(MB::Sound::GenerationMethods) do
describe '#noise' do
it 'creates a noise generator node' do
n = MB::Sound.noise.sample(48000)
expect(n.mean.round(3)).to eq(0)
expect(n.min.round(3)).to eq(-0.1)
expect(n.max.round(3)).to eq(0.1)
histogram = {}
n.each do |v|
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/wavetable_spec.rb | Ruby | bsd-2-clause | 19 | master | 18,930 | RSpec.describe(MB::Sound::Wavetable, aggregate_failures: true) do
let(:table) {
Numo::SFloat[
[1, 2, 3, 4, 5],
[5, -3, 3, -1, 2],
[-1, 1, 0, 3, -4],
]
}
describe '.load_wavetable' do
it 'can load an existing wavetable' do
data = MB::Sound::Wavetable.load_wavetable('spec/test_d... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/ffmpeg_input_spec.rb | Ruby | bsd-2-clause | 19 | master | 8,676 | require 'benchmark'
RSpec.describe MB::Sound::FFMPEGInput do
describe '.parse_info' do
let(:info) {
MB::Sound::FFMPEGInput.parse_info('sounds/sine/sine_100_1s_mono.flac')
}
let(:info_multi) {
MB::Sound::FFMPEGInput.parse_info('spec/test_data/two_audio_streams.mkv')
}
it 'can read st... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/buffer_helper_spec.rb | Ruby | bsd-2-clause | 19 | master | 11,333 | RSpec.describe(MB::Sound::BufferHelper, :aggregate_failures) do
let(:bufhelper) {
c = Class.new do
include MB::Sound::BufferHelper
attr_reader :buf, :tmpbuf
def setup_buffer(*a, **ka)
super
end
def expand_buffer(*a, **ka)
super
end
def promote_buffer(*... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/timeline_interpolator_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,808 | RSpec.describe(MB::Sound::TimelineInterpolator) do
let(:ti) {
MB::Sound::TimelineInterpolator.new([
{ time: 0.0, data: [ 0, 0, 0 ], blend: :linear },
{ time: 1.0, data: [ 1, -1, 0 ], blend: :smoothstep },
{ time: 3.5, data: [ -1, 1, -1 ], blend: :smootherstep },
{ time: 5.0, data: [ 0, 0, ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/graph_node_spec.rb | Ruby | bsd-2-clause | 19 | master | 26,259 | # Tests for the DSL overall, including Tone, Mixer, Multiplier
RSpec.describe(MB::Sound::GraphNode, aggregate_failures: true) do
it 'can create a complex signal graph' do
graph = (1.hz.square.at_rate(20).at(1) - 2.hz.square.at_rate(20).at(0.5) - 5 + 3 + 2) * 0.5.hz.square.at_rate(20).at(2..1) * 3 + 1
expect(g... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/plot_output_spec.rb | Ruby | bsd-2-clause | 19 | master | 2,836 | RSpec.describe(MB::Sound::PlotOutput) do
let(:plot) { MB::M::Plot.new(terminal: 'dumb', width: 80, height: 40).tap { |p| p.print = false } }
let(:output) { MB::Sound::NullOutput.new(channels: 4) }
let(:po_time) { MB::Sound::PlotOutput.new(output, window_size: 800, plot: plot).tap { |p| p.sleep = false } }
let(:... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/tone_spec.rb | Ruby | bsd-2-clause | 19 | master | 9,002 | RSpec.describe MB::Sound::Tone do
describe '#generate' do
it 'can generate triangle wave samples in an NArray' do
data = 500.hz.triangle.at(0.85).generate(48000)
expect(data.length).to eq(48000)
expect(data.max.round(3)).to eq(0.85)
expect(data.min.round(3)).to eq(-0.85)
expect(data.... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/processing_matrix_spec.rb | Ruby | bsd-2-clause | 19 | master | 5,484 | RSpec.describe(MB::Sound::ProcessingMatrix) do
let(:l) { Numo::SFloat[1, 2, 3, 0] }
let(:r) { Numo::SFloat[-1, 0, 3, -4] }
describe '.from_file' do
let(:matrix_flat) {
[ 1, 2, 3, 4 ]
}
let(:matrix_5_1) {
[ [1], [2], [3], [4], [5] ]
}
let(:matrix_1_5) {
[ [1, 2, 3, 4, 5] ]
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/window_writer_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,136 | RSpec.describe MB::Sound::WindowWriter do
describe '#initialize' do
it 'can wrap a NullOutput' do
writer = MB::Sound::WindowWriter.new(
MB::Sound::NullOutput.new(channels: 3, buffer_size: 576),
MB::Sound::Window::DoubleHann.new(1234)
)
expect(writer.buffer_size).to eq(1234)
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/null_input_spec.rb | Ruby | bsd-2-clause | 19 | master | 3,739 | RSpec.describe MB::Sound::NullInput do
describe '#initialize' do
describe 'strict_buffer_size parameter' do
it 'defaults to false' do
expect(MB::Sound::NullInput.new(channels: 1).strict_buffer_size?).to eq(false)
end
it 'can be set to false' do
expect(MB::Sound::NullInput.new(ch... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/null_output_spec.rb | Ruby | bsd-2-clause | 19 | master | 2,092 | require 'benchmark'
RSpec.describe(MB::Sound::NullOutput) do
let(:null_sleep) { MB::Sound::NullOutput.new(channels: 1, sleep: true) }
let(:null_sleep_44k) { MB::Sound::NullOutput.new(channels: 1, sleep: true, sample_rate: 44100) }
let(:null_no_sleep) { MB::Sound::NullOutput.new(channels: 1, sleep: false) }
let... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/window/all_windows_spec.rb | Ruby | bsd-2-clause | 19 | master | 912 | MB::Sound::Window.windows.each do |wclass|
length = 256
bin = 8
RSpec.describe wclass do
it 'should have an FFT value of 1.0 for a bin-centered sine wave' do
window = wclass.new(length)
sine = length.times.map { |i| Math.sin(bin * 2.0 * Math::PI * i / length) }
wsine = Numo::SFloat.cast(si... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/midi/parameter_spec.rb | Ruby | bsd-2-clause | 19 | master | 1,167 | RSpec.describe(MB::Sound::MIDI::Parameter) do
it 'can be constructed with a control change event' do
MB::Sound::MIDI::Parameter.new(message: MIDIMessage::ControlChange.new(-1, 1, 0))
end
it 'can be constructed with a note-on event' do
MB::Sound::MIDI::Parameter.new(message: 440.hz.to_midi)
end
it 'c... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/midi/manager_spec.rb | Ruby | bsd-2-clause | 19 | master | 3,212 | RSpec.describe(MB::Sound::MIDI::Manager) do
let (:midi_file) { MB::Sound::MIDI::MIDIFile.new('spec/test_data/midi.mid') }
let (:manager) { MB::Sound::MIDI::Manager.new(jack: nil, input: midi_file) }
it 'can be constructed with a MIDIFile' do
expect { manager }.not_to raise_error
end
describe '#update' d... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | spec/lib/mb/sound/midi/midi_file_spec.rb | Ruby | bsd-2-clause | 19 | master | 3,500 | RSpec.describe(MB::Sound::MIDI::MIDIFile) do
let(:clock) { MB::Sound::MIDI::MIDIFile::ConstantClock.new }
let(:seq) { MB::Sound::MIDI::MIDIFile.new('spec/test_data/midi.mid', clock: clock) }
it 'can be constructed and can load a MIDI file' do
expect { seq }.not_to raise_error
expect(seq.empty?).to eq(fal... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.