├── .gitignore ├── .rspec ├── .rubocop.yml ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── Gemfile ├── Gemfile.lock ├── LICENSE.txt ├── README.md ├── README.rdoc ├── Rakefile ├── TODO.markdown ├── bin ├── console ├── setup └── ugen_gen.rb ├── lib ├── scruby.rb └── scruby │ ├── attributes.rb │ ├── buffer.rb │ ├── bus.rb │ ├── core_ext │ └── fixnum.rb │ ├── encode.rb │ ├── env.rb │ ├── equatable.rb │ ├── graph.rb │ ├── graph │ ├── decoder.rb │ ├── node.rb │ └── print.rb │ ├── group.rb │ ├── helpers.rb │ ├── par_group.rb │ ├── pretty_inspectable.rb │ ├── process.rb │ ├── process │ └── registry.rb │ ├── sclang.rb │ ├── sclang │ └── helpers.rb │ ├── server.rb │ ├── server │ ├── local.rb │ ├── message_queue.rb │ ├── nodes.rb │ └── options.rb │ ├── server_node.rb │ ├── server_node │ └── properties.rb │ ├── synth.rb │ ├── synth_def.rb │ ├── ugen.rb │ ├── ugen │ ├── a2_k.rb │ ├── abstract_out.rb │ ├── allpass_c.rb │ ├── allpass_l.rb │ ├── allpass_n.rb │ ├── amp_comp.rb │ ├── amp_comp_a.rb │ ├── amplitude.rb │ ├── apf.rb │ ├── b_all_pass.rb │ ├── b_band_pass.rb │ ├── b_band_stop.rb │ ├── b_hi_pass.rb │ ├── b_hi_shelf.rb │ ├── b_low_pass.rb │ ├── b_low_shelf.rb │ ├── b_peak_eq.rb │ ├── balance2.rb │ ├── ball.rb │ ├── base.rb │ ├── beat_track.rb │ ├── beat_track2.rb │ ├── bi_pan_b2.rb │ ├── binary_op_ugen.rb │ ├── blip.rb │ ├── block_size.rb │ ├── bpf.rb │ ├── bpz2.rb │ ├── brf.rb │ ├── brown_noise.rb │ ├── brz2.rb │ ├── buf_allpass_c.rb │ ├── buf_allpass_l.rb │ ├── buf_allpass_n.rb │ ├── buf_channels.rb │ ├── buf_comb_c.rb │ ├── buf_comb_l.rb │ ├── buf_comb_n.rb │ ├── buf_delay_c.rb │ ├── buf_delay_l.rb │ ├── buf_delay_n.rb │ ├── buf_dur.rb │ ├── buf_frames.rb │ ├── buf_rate_scale.rb │ ├── buf_rd.rb │ ├── buf_sample_rate.rb │ ├── buf_samples.rb │ ├── buf_wr.rb │ ├── c_osc.rb │ ├── check_bad_values.rb │ ├── clip.rb │ ├── clip_noise.rb │ ├── coin_gate.rb │ ├── comb_c.rb │ ├── comb_l.rb │ ├── comb_n.rb │ ├── compander.rb │ ├── compander_d.rb │ ├── control.rb │ ├── control_dur.rb │ ├── control_rate.rb │ ├── convolution.rb │ ├── convolution2.rb │ ├── convolution2_l.rb │ ├── convolution3.rb │ ├── crackle.rb │ ├── cusp_l.rb │ ├── cusp_n.rb │ ├── dbrown.rb │ ├── dbufrd.rb │ ├── dbufwr.rb │ ├── dc.rb │ ├── dconst.rb │ ├── decay.rb │ ├── decay2.rb │ ├── decode_b2.rb │ ├── degree_to_key.rb │ ├── del_tap_rd.rb │ ├── del_tap_wr.rb │ ├── delay1.rb │ ├── delay2.rb │ ├── delay_c.rb │ ├── delay_l.rb │ ├── delay_n.rb │ ├── demand.rb │ ├── demand_env_gen.rb │ ├── detect_index.rb │ ├── detect_silence.rb │ ├── dgeom.rb │ ├── dibrown.rb │ ├── disk_in.rb │ ├── disk_out.rb │ ├── diwhite.rb │ ├── done.rb │ ├── done_actions.rb │ ├── dpoll.rb │ ├── drand.rb │ ├── dreset.rb │ ├── dseq.rb │ ├── dser.rb │ ├── dseries.rb │ ├── dshuf.rb │ ├── dstutter.rb │ ├── dswitch.rb │ ├── dswitch1.rb │ ├── dunique.rb │ ├── dust.rb │ ├── dust2.rb │ ├── duty.rb │ ├── dwhite.rb │ ├── dwrand.rb │ ├── dxrand.rb │ ├── env_gen.rb │ ├── exp_rand.rb │ ├── f_sin_osc.rb │ ├── fb_sine_c.rb │ ├── fb_sine_l.rb │ ├── fb_sine_n.rb │ ├── fft.rb │ ├── fold.rb │ ├── formant.rb │ ├── formlet.rb │ ├── fos.rb │ ├── free.rb │ ├── free_self.rb │ ├── free_self_when_done.rb │ ├── free_verb.rb │ ├── free_verb2.rb │ ├── freq_shift.rb │ ├── g_verb.rb │ ├── gate.rb │ ├── gbman_l.rb │ ├── gbman_n.rb │ ├── gen.rb │ ├── gendy1.rb │ ├── gendy2.rb │ ├── gendy3.rb │ ├── grain_buf.rb │ ├── grain_fm.rb │ ├── grain_in.rb │ ├── grain_sin.rb │ ├── gray_noise.rb │ ├── hasher.rb │ ├── henon_c.rb │ ├── henon_l.rb │ ├── henon_n.rb │ ├── hilbert.rb │ ├── hpf.rb │ ├── hpz1.rb │ ├── hpz2.rb │ ├── i_env_gen.rb │ ├── i_rand.rb │ ├── ifft.rb │ ├── impulse.rb │ ├── in.rb │ ├── in_feedback.rb │ ├── in_range.rb │ ├── in_rect.rb │ ├── in_trig.rb │ ├── index.rb │ ├── index_in_between.rb │ ├── index_l.rb │ ├── info_u_gen_base.rb │ ├── integrator.rb │ ├── k2_a.rb │ ├── key_state.rb │ ├── key_track.rb │ ├── klang.rb │ ├── klank.rb │ ├── lag.rb │ ├── lag2.rb │ ├── lag2_ud.rb │ ├── lag3.rb │ ├── lag3_ud.rb │ ├── lag_in.rb │ ├── lag_ud.rb │ ├── last_value.rb │ ├── latch.rb │ ├── latoocarfian_c.rb │ ├── latoocarfian_l.rb │ ├── latoocarfian_n.rb │ ├── leak_dc.rb │ ├── least_change.rb │ ├── lf_clip_noise.rb │ ├── lf_cub.rb │ ├── lf_gauss.rb │ ├── lf_noise0.rb │ ├── lf_noise1.rb │ ├── lf_noise2.rb │ ├── lf_par.rb │ ├── lf_pulse.rb │ ├── lf_saw.rb │ ├── lf_tri.rb │ ├── lfd_clip_noise.rb │ ├── lfd_noise0.rb │ ├── lfd_noise1.rb │ ├── lfd_noise3.rb │ ├── limiter.rb │ ├── lin_cong_c.rb │ ├── lin_cong_l.rb │ ├── lin_cong_n.rb │ ├── lin_exp.rb │ ├── lin_pan2.rb │ ├── lin_rand.rb │ ├── lin_x_fade2.rb │ ├── line.rb │ ├── linen.rb │ ├── local_buf.rb │ ├── local_in.rb │ ├── local_out.rb │ ├── logistic.rb │ ├── lorenz_l.rb │ ├── loudness.rb │ ├── lpf.rb │ ├── lpz1.rb │ ├── lpz2.rb │ ├── mantissa_mask.rb │ ├── median.rb │ ├── mfcc.rb │ ├── mid_eq.rb │ ├── mod_dif.rb │ ├── moog_ff.rb │ ├── most_change.rb │ ├── mouse_button.rb │ ├── mouse_x.rb │ ├── mouse_y.rb │ ├── mul_add.rb │ ├── multi_channel.rb │ ├── n_rand.rb │ ├── node_id.rb │ ├── normalizer.rb │ ├── num_audio_buses.rb │ ├── num_buffers.rb │ ├── num_control_buses.rb │ ├── num_input_buses.rb │ ├── num_output_buses.rb │ ├── num_running_synths.rb │ ├── offset_out.rb │ ├── one_pole.rb │ ├── one_zero.rb │ ├── onsets.rb │ ├── operation.rb │ ├── operations.rb │ ├── osc.rb │ ├── osc_n.rb │ ├── out.rb │ ├── p_sin_grain.rb │ ├── pan2.rb │ ├── pan4.rb │ ├── pan_az.rb │ ├── pan_b.rb │ ├── pan_b2.rb │ ├── part_conv.rb │ ├── pause.rb │ ├── pause_self.rb │ ├── pause_self_when_done.rb │ ├── peak.rb │ ├── peak_follower.rb │ ├── phasor.rb │ ├── pink_noise.rb │ ├── pitch.rb │ ├── pitch_shift.rb │ ├── play_buf.rb │ ├── pluck.rb │ ├── poll.rb │ ├── pulse.rb │ ├── pulse_count.rb │ ├── pulse_divider.rb │ ├── pv_add.rb │ ├── pv_bin_scramble.rb │ ├── pv_bin_shift.rb │ ├── pv_bin_wipe.rb │ ├── pv_brick_wall.rb │ ├── pv_chain_u_gen.rb │ ├── pv_conformal_map.rb │ ├── pv_conj.rb │ ├── pv_copy.rb │ ├── pv_copy_phase.rb │ ├── pv_diffuser.rb │ ├── pv_div.rb │ ├── pv_hainsworth_foote.rb │ ├── pv_jensen_andersen.rb │ ├── pv_local_max.rb │ ├── pv_mag_above.rb │ ├── pv_mag_below.rb │ ├── pv_mag_clip.rb │ ├── pv_mag_div.rb │ ├── pv_mag_freeze.rb │ ├── pv_mag_mul.rb │ ├── pv_mag_noise.rb │ ├── pv_mag_shift.rb │ ├── pv_mag_smear.rb │ ├── pv_mag_squared.rb │ ├── pv_max.rb │ ├── pv_min.rb │ ├── pv_mul.rb │ ├── pv_phase_shift.rb │ ├── pv_phase_shift270.rb │ ├── pv_phase_shift90.rb │ ├── pv_rand_comb.rb │ ├── pv_rand_wipe.rb │ ├── pv_rect_comb.rb │ ├── pv_rect_comb2.rb │ ├── quad_c.rb │ ├── quad_l.rb │ ├── quad_n.rb │ ├── radians_per_sample.rb │ ├── ramp.rb │ ├── rand.rb │ ├── rand_id.rb │ ├── rand_seed.rb │ ├── record_buf.rb │ ├── replace_out.rb │ ├── resonz.rb │ ├── rhpf.rb │ ├── ringz.rb │ ├── rlpf.rb │ ├── rotate2.rb │ ├── running_max.rb │ ├── running_min.rb │ ├── running_sum.rb │ ├── sample_dur.rb │ ├── sample_rate.rb │ ├── sanitize.rb │ ├── saw.rb │ ├── schmidt.rb │ ├── scope_out.rb │ ├── scope_out2.rb │ ├── select.rb │ ├── send_trig.rb │ ├── set_reset_ff.rb │ ├── shaper.rb │ ├── sin_osc.rb │ ├── sin_osc_fb.rb │ ├── slew.rb │ ├── slope.rb │ ├── sos.rb │ ├── spec_centroid.rb │ ├── spec_flatness.rb │ ├── spec_pcile.rb │ ├── spring.rb │ ├── standard_l.rb │ ├── standard_n.rb │ ├── stepper.rb │ ├── stereo_convolution2_l.rb │ ├── subsample_offset.rb │ ├── sum3.rb │ ├── sum4.rb │ ├── sweep.rb │ ├── sync_saw.rb │ ├── t2_a.rb │ ├── t2_k.rb │ ├── t_ball.rb │ ├── t_delay.rb │ ├── t_duty.rb │ ├── t_exp_rand.rb │ ├── t_grains.rb │ ├── t_rand.rb │ ├── t_windex.rb │ ├── ti_rand.rb │ ├── timer.rb │ ├── toggle_ff.rb │ ├── trig.rb │ ├── trig1.rb │ ├── trig_control.rb │ ├── two_pole.rb │ ├── two_zero.rb │ ├── unary_op_ugen.rb │ ├── v_disk_in.rb │ ├── v_osc.rb │ ├── v_osc3.rb │ ├── var_lag.rb │ ├── var_saw.rb │ ├── vibrato.rb │ ├── warp1.rb │ ├── white_noise.rb │ ├── wrap.rb │ ├── wrap_index.rb │ ├── x_fade2.rb │ ├── x_line.rb │ ├── x_out.rb │ └── zero_crossing.rb │ ├── ugen_graph.rb │ ├── ugen_graph │ ├── constant.rb │ ├── control.rb │ ├── control_name.rb │ └── ugen_node.rb │ ├── utils │ └── positional_keyword_args.rb │ └── version.rb ├── scruby.gemspec └── spec ├── attributes_spec.rb ├── buffer_spec.rb ├── env_spec.rb ├── equatable_spec.rb ├── graph ├── decoder_spec.rb └── node_spec.rb ├── graph_spec.rb ├── group_spec.rb ├── in_out_spec.rb ├── integration ├── multichannel_graph_spec.rb └── operation_graph_spec.rb ├── server ├── nodes_spec.rb └── options_spec.rb ├── server_spec.rb ├── spec_helper.rb ├── support ├── buffer_examples.rb ├── done_action_examples.rb ├── encode_matcher.rb ├── equality_examples.rb ├── graph_node_examples.rb └── node_examples.rb ├── synth_def_spec.rb ├── synth_spec.rb ├── ugen ├── base_spec.rb ├── binary_op_ugen_spec.rb ├── demand_env_gen_spec.rb ├── env_gen_spec.rb ├── gen_spec.rb ├── graph │ ├── constant_spec.rb │ ├── control_name_spec.rb │ └── control_spec.rb ├── graph_spec.rb ├── line_spec.rb ├── linen_spec.rb ├── multi_channel_spec.rb ├── play_buf_spec.rb ├── record_buf_spec.rb ├── unary_op_ugen_spec.rb └── x_line_spec.rb ├── ugen_graph ├── constant_spec.rb ├── control_name_spec.rb ├── control_spec.rb └── ugen_node_spec.rb └── utils └── positional_keyword_args_spec.rb /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /_yardoc/ 4 | /coverage/ 5 | /doc/ 6 | /pkg/ 7 | /spec/reports/ 8 | /tmp/ 9 | .rspec_status 10 | .byebug_history 11 | TAGS 12 | /.gtm/ 13 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | --require spec_helper 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: false 3 | language: ruby 4 | cache: bundler 5 | rvm: 6 | - 2.6.5 7 | before_install: gem install bundler -v 2.0.2 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at maca@aelita.io. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Specify your gem's dependencies in scruby.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | scruby (0.3) 5 | concurrent-ruby (~> 1.1) 6 | concurrent-ruby-edge (~> 0.6.0) 7 | facets (~> 3.1) 8 | ruby-osc (~> 1.0) 9 | tty-which (~> 0.4) 10 | 11 | GEM 12 | remote: https://rubygems.org/ 13 | specs: 14 | ast (2.4.2) 15 | byebug (11.1.3) 16 | concurrent-ruby (1.1.9) 17 | concurrent-ruby-edge (0.6.0) 18 | concurrent-ruby (~> 1.1.6) 19 | diff-lcs (1.4.4) 20 | eventmachine (1.2.7) 21 | facets (3.1.0) 22 | ffi (1.15.3) 23 | io-console (0.5.9) 24 | irb (1.3.6) 25 | reline (>= 0.2.5) 26 | listen (3.5.1) 27 | rb-fsevent (~> 0.10, >= 0.10.3) 28 | rb-inotify (~> 0.9, >= 0.9.10) 29 | parallel (1.20.1) 30 | parser (3.0.1.1) 31 | ast (~> 2.4.1) 32 | rainbow (3.0.0) 33 | rantly (2.0.0) 34 | rb-fsevent (0.11.0) 35 | rb-inotify (0.10.1) 36 | ffi (~> 1.0) 37 | rdoc (6.3.2) 38 | regexp_parser (2.1.1) 39 | reline (0.2.6) 40 | io-console (~> 0.5) 41 | rexml (3.2.5) 42 | rspec (3.10.0) 43 | rspec-core (~> 3.10.0) 44 | rspec-expectations (~> 3.10.0) 45 | rspec-mocks (~> 3.10.0) 46 | rspec-core (3.10.1) 47 | rspec-support (~> 3.10.0) 48 | rspec-expectations (3.10.1) 49 | diff-lcs (>= 1.2.0, < 2.0) 50 | rspec-support (~> 3.10.0) 51 | rspec-mocks (3.10.2) 52 | diff-lcs (>= 1.2.0, < 2.0) 53 | rspec-support (~> 3.10.0) 54 | rspec-support (3.10.2) 55 | rubocop (1.18.3) 56 | parallel (~> 1.10) 57 | parser (>= 3.0.0.0) 58 | rainbow (>= 2.2.2, < 4.0) 59 | regexp_parser (>= 1.8, < 3.0) 60 | rexml 61 | rubocop-ast (>= 1.7.0, < 2.0) 62 | ruby-progressbar (~> 1.7) 63 | unicode-display_width (>= 1.4.0, < 3.0) 64 | rubocop-ast (1.7.0) 65 | parser (>= 3.0.1.1) 66 | ruby-osc (1.0.0) 67 | eventmachine (~> 1.2) 68 | ruby-progressbar (1.11.0) 69 | tty-which (0.4.2) 70 | unicode-display_width (2.0.0) 71 | yard (0.9.26) 72 | zeitwerk (2.4.2) 73 | 74 | PLATFORMS 75 | ruby 76 | 77 | DEPENDENCIES 78 | bundler 79 | byebug 80 | irb 81 | listen 82 | rantly 83 | rdoc 84 | rspec 85 | rubocop 86 | scruby! 87 | yard 88 | zeitwerk 89 | 90 | BUNDLED WITH 91 | 2.2.17 92 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Macario 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scruby 2 | 3 | Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/scruby`. To experiment with that code, run `bin/console` for an interactive prompt. 4 | 5 | TODO: Delete this and the text above, and describe your gem 6 | 7 | ## Installation 8 | 9 | Add this line to your application's Gemfile: 10 | 11 | ```ruby 12 | gem 'scruby' 13 | ``` 14 | 15 | And then execute: 16 | 17 | $ bundle 18 | 19 | Or install it yourself as: 20 | 21 | $ gem install scruby 22 | 23 | ## Usage 24 | 25 | TODO: Write usage instructions here 26 | 27 | ## Development 28 | 29 | After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. 30 | 31 | To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). 32 | 33 | ## Contributing 34 | 35 | Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/scruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. 36 | 37 | ## License 38 | 39 | The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). 40 | 41 | ## Code of Conduct 42 | 43 | Everyone interacting in the Scruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/scruby/blob/master/CODE_OF_CONDUCT.md). 44 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | == Scruby 2 | 3 | Is a bare-bones SuperCollider livecoding library for Ruby, it provides comunication with a remote or local scsynth server and SynthDef creation with a 4 | in a similar way to Sclang. 5 | 6 | SynthDef creation and sending is robust but some features are not implemented such as SynthDef variations and others I may not be aware of. 7 | 8 | livecode.rb executable is located in the bin directory and a TextMate bundle included in extras permits livecoding from TextMate, comunication is 9 | thrugh *nix pipes. Similar functionality shouldn't be too dificult to implement from Emacs or Vim. 10 | 11 | == Install 12 | 13 | $ [sudo] gem install scruby 14 | 15 | Scruby is just a SuperCollider client so SC must be installed on the system. There's a PPA for installing SC under Ubuntu: https://launchpad.net/~supercollider/+archive/ppa. 16 | 17 | 18 | == Usage 19 | 20 | require 'scruby' 21 | 22 | s = Server.new 23 | s.boot 24 | 25 | SynthDef.new :fm do |freq, amp, dur| 26 | mod_env = EnvGen.kr Env.new( d(600, 200, 100), d(0.7,0.3) ), 1, :timeScale => dur 27 | mod = SinOsc.ar freq * 1.4, :mul => mod_env 28 | sig = SinOsc.ar freq + mod 29 | env = EnvGen.kr Env.new( d(0, 1, 0.6, 0.2, 0.1, 0), d(0.001, 0.005, 0.3, 0.5, 0.7) ), 1, :timeScale => dur, :doneAction => 2 30 | sig = sig * amp * env 31 | Out.ar 0, [sig, sig] 32 | end.send 33 | 34 | Synth.new :fm, :freq => 220, :amp => 0.4, :dur => 1 35 | 36 | 37 | To start a live coding session: 38 | 39 | $ live 40 | 41 | See http://github.com/maca/live 42 | 43 | 44 | == Todo 45 | 46 | Receive OSC messages from SuperCollider 47 | 48 | == License: 49 | 50 | Copyright (c) 2008 Macario Ortega 51 | 52 | This program is free software: you can redistribute it and/or modify 53 | it under the terms of the GNU General Public License as published by 54 | the Free Software Foundation, either version 3 of the License, or 55 | (at your option) any later version. 56 | 57 | This program is distributed in the hope that it will be useful, 58 | but WITHOUT ANY WARRANTY; without even the implied warranty of 59 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 60 | GNU General Public License for more details. 61 | 62 | You should have received a copy of the GNU General Public License 63 | along with this program. If not, see . 64 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | task default: :spec 3 | -------------------------------------------------------------------------------- /TODO.markdown: -------------------------------------------------------------------------------- 1 | **Array workarrounds** 2 | 3 | * Buffer as Ugen input 4 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require "bundler/setup" 5 | require "byebug" 6 | require "zeitwerk" 7 | require "listen" 8 | 9 | 10 | 11 | module Scruby 12 | class UgenInflector < Zeitwerk::Inflector 13 | ACRONYMS = %w(apf bpf bpz brf dc fft fos hpf 14 | hpz ifft lf lfd lpf lpz rhpf rlpf) 15 | 16 | def camelize(basename, abspath) 17 | if basename =~ /\A(#{Regexp.union(ACRONYMS)})(.*)/ 18 | $1.upcase + super($2, abspath) 19 | else 20 | super 21 | end 22 | end 23 | end 24 | end 25 | 26 | 27 | $loader = Zeitwerk::Loader.new 28 | $loader.inflector = Scruby::UgenInflector.new 29 | $loader.push_dir File.join(__dir__, "..", "lib") 30 | $loader.enable_reloading 31 | $loader.setup 32 | 33 | Listen.to(*$loader.root_dirs.keys) { 34 | $loader.reload 35 | include Scruby::Helpers 36 | }.start 37 | 38 | 39 | require "ruby-osc" 40 | 41 | include Scruby::Helpers 42 | 43 | require "irb" 44 | IRB.start(__FILE__) 45 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /bin/ugen_gen.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require "json" 5 | require "erb" 6 | require "facets/string/camelcase" 7 | require "facets/string/snakecase" 8 | 9 | 10 | path = ARGV[0] or raise "Provide a path for the json dump of Ugens" 11 | file = File.open File.expand_path(path) 12 | data = JSON.load file 13 | 14 | 15 | 16 | data.each do |name, specs| 17 | rate_map = { ar: :audio, kr: :control, ir: :scalar } 18 | rates = specs["methods"].map { |k, _| rate_map[k.to_sym] } 19 | 20 | 21 | inputs = specs["methods"].to_a.first.last.to_h 22 | attrs = {} 23 | 24 | 25 | if specs['isMultiOut'] 26 | names = %w(numChannels numChans) 27 | 28 | attrs = inputs.slice(*names).transform_values { 1 } 29 | inputs = inputs.reject { |k, _| names.include?(k) } 30 | end 31 | 32 | 33 | map_names = proc do |input, value| 34 | values = 35 | specs["methods"].map { |_, values| values.assoc(input).last } 36 | 37 | defaults = 38 | if values.uniq.size == 1 39 | value.inspect 40 | else 41 | "{ %s }" % rates.zip(values) 42 | .map { |r, v| "#{r}: #{v.inspect}" }.join(", ") 43 | end 44 | 45 | input = 46 | case input 47 | when "in" then "input" 48 | when "end" then "finish" 49 | when "numChannels" then "channel_count" 50 | when "numChans" then "channel_count" 51 | when "rate" then "playback_rate" 52 | else 53 | input 54 | end 55 | 56 | "#{input.snakecase}: #{defaults}".gsub(/\.0$/, "") 57 | end 58 | 59 | 60 | inputs = inputs.map(&map_names) 61 | attrs = attrs.map(&map_names) 62 | 63 | 64 | template = 65 | <<~RUBY 66 | module Scruby 67 | module Ugen 68 | class <%= name.sub("_", "") -%> 69 | <% if specs['isOut'] == true %> 70 | < AbstractOut 71 | <% else %> 72 | < Gen 73 | <% end -%> 74 | 75 | rates <%= rates.map(&:inspect).join(', ') -%> 76 | <% unless attrs.empty? %> 77 | attributes <%= attrs.join(', ') 78 | .scan(/(.{1,60})(?:,|$)/m).join(",\n#{ ' ' * 16 }") %> 79 | <% end -%> 80 | <% unless inputs.empty? %> 81 | inputs <%= inputs.join(', ') 82 | .scan(/(.{1,60})(?:,|$)/m).join(",\n#{ ' ' * 12 }") %> 83 | <% end -%> 84 | 85 | end 86 | end 87 | end 88 | RUBY 89 | 90 | file_name = "./lib/scruby/ugen/#{name.snakecase}.rb" 91 | File.write file_name, ERB.new(template, nil, "-").result(binding) 92 | end 93 | -------------------------------------------------------------------------------- /lib/scruby/attributes.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Attributes 3 | class AttributeMap 4 | attr_reader :attributes 5 | 6 | def initialize(&block) 7 | @attributes = {} 8 | instance_eval(&block) 9 | end 10 | 11 | def attribute(name, value = nil) 12 | attributes.merge!(name.to_s => value) 13 | end 14 | end 15 | 16 | def attributes(&block) 17 | defaults = AttributeMap.new(&block).attributes 18 | 19 | dynamic_module = 20 | Module.new do 21 | attr_accessor *defaults.keys 22 | 23 | define_method :initialize do |**attrs| 24 | defaults.merge(attrs).each do |k, v| 25 | unless defaults.keys.include?(k.to_s) 26 | raise ArgumentError, "(unknown keyword: #{k})" 27 | end 28 | 29 | public_send("#{k}=", v) 30 | end 31 | end 32 | 33 | define_method :attributes do 34 | defaults.keys 35 | .map { |attr| [ attr, public_send(attr) ] }.to_h 36 | end 37 | end 38 | 39 | include dynamic_module 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/scruby/bus.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Bus 3 | attr_reader :server, :rate, :channels, :main_bus 4 | 5 | def initialize(server, rate, channels = 1, main_bus = self, hardware_out = false) 6 | @server, @rate, @channels, @main_bus, @hardware_out = server, rate, channels, main_bus, hardware_out 7 | end 8 | 9 | def index 10 | @index ||= @server.__send__("#{ @rate }_buses").index(self) 11 | end 12 | 13 | def free 14 | @index = nil 15 | @server.__send__("#{ @rate }_buses").delete(self) 16 | end 17 | 18 | def to_map 19 | raise SCError, "Audio buses cannot be mapped" if rate == :audio 20 | 21 | "c#{ index }" 22 | end 23 | 24 | def audio_out? 25 | index < @server.instance_variable_get(:@opts)[:audio_outputs] 26 | end 27 | 28 | # Messaging 29 | def set(*args) 30 | args.flatten! 31 | message_args = [] 32 | (index...channels).to_a.zip(args) do |chan, val| 33 | message_args.push(chan).push(val) if chan and val 34 | end 35 | if args.size > channels 36 | warn "You tried to set #{ args.size } values for bus #{ index } that only has #{ channels } channels, extra values are ignored." 37 | end 38 | @server.send "/c_set", *message_args 39 | end 40 | 41 | def fill(value, channels = @channels) 42 | if channels > @channels 43 | warn "You tried to set #{ channels } values for bus #{ index } that only has #{ @channels } channels, extra values are ignored." 44 | end 45 | @server.send "/c_fill", index, channels.min(@channels), value 46 | end 47 | 48 | class << self 49 | private :new 50 | 51 | def control(server, channels = 1) 52 | buses = [ new(server, :control, channels) ] 53 | buses.push new(server, :control, channels, buses.first) while buses.size < channels 54 | server.allocate :control_buses, buses 55 | buses.first 56 | end 57 | 58 | def audio(server, channels = 1) 59 | buses = [ new(server, :audio, channels) ] 60 | buses.push new(server, :audio, channels, buses.first) while buses.size < channels 61 | server.allocate :audio_buses, buses 62 | buses.first 63 | end 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /lib/scruby/core_ext/fixnum.rb: -------------------------------------------------------------------------------- 1 | class Fixnum 2 | def freq 3 | 440 * (2**((self - 69) * 0.083333333333)) 4 | end 5 | # method next tone 6 | # 1:1.05946 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/encode.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Encode 3 | module_function 4 | 5 | def encode_int8(num) 6 | encode_int8_array [ num & 255 ] 7 | end 8 | 9 | def encode_int16(num) 10 | encode_int16_array [ num ] 11 | end 12 | 13 | def encode_int32(num) 14 | encode_int32_array [ num ] 15 | end 16 | 17 | def encode_floats_array(array) 18 | [ array.size ].pack("N") + array.pack("g*") 19 | end 20 | 21 | def encode_string(string) 22 | encode_int8(string.size) + string[0..255] 23 | end 24 | 25 | def encode_int8_array(ary) 26 | ary.pack("C*") 27 | end 28 | 29 | def encode_int16_array(ary) 30 | ary.pack("n*") 31 | end 32 | 33 | def encode_int32_array(ary) 34 | ary.pack("N*") 35 | end 36 | 37 | def string_to_hex(string) 38 | string.unpack("C*").map { |num| num.to_s(16).rjust(2, "0") } 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/scruby/equatable.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Equatable 3 | def ==(other) 4 | self.class == other.class && 5 | other.equatable_state == equatable_state 6 | end 7 | 8 | protected 9 | 10 | def equatable_state 11 | instance_variables.map { |name| instance_variable_get(name) } 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/scruby/graph.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Graph 3 | include Enumerable 4 | 5 | attr_reader :nodes, :parent_indices 6 | private :nodes 7 | 8 | def initialize(nodes) 9 | @nodes = nodes.map(&method(:node_pair)).to_h 10 | @parent_indices = nodes.group_by(&:parent) 11 | end 12 | 13 | def add(node) 14 | node.graph = self 15 | nodes[node.id] = node 16 | parent_indices[node.parent] = [ *children_for(node.parent), node ] 17 | node 18 | end 19 | 20 | def children_for(parent) 21 | parent_indices[parent] || [] 22 | end 23 | 24 | def [](idx) 25 | nodes[idx] 26 | end 27 | 28 | def each(&block) 29 | return enum_for(:each) unless block_given? 30 | nodes.each(&:last.to_proc >> block) 31 | end 32 | 33 | private 34 | 35 | def node_pair(node) 36 | [ node.id, node.tap { |n| n.graph = self } ] 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/scruby/graph/decoder.rb: -------------------------------------------------------------------------------- 1 | require "ostruct" 2 | 3 | module Scruby 4 | class Graph 5 | module Decoder 6 | class << self 7 | def decode(msg) 8 | Graph.new decode_node(msg.to_enum.tap(&:next), nil, []) 9 | end 10 | 11 | private 12 | 13 | def decode_node(bytes, parent, acc) 14 | id = bytes.next 15 | children_count = bytes.next 16 | 17 | if children_count == -1 18 | acc << associate(decode_synth(bytes), id, parent) 19 | else 20 | nparent = associate(Node.new, id, parent) 21 | acc << nparent 22 | 23 | children_count.times 24 | .each { decode_node(bytes, nparent, acc) } 25 | end 26 | 27 | acc 28 | end 29 | 30 | def decode_synth(bytes) 31 | name = bytes.next 32 | params_count = bytes.next 33 | 34 | params = 35 | Hash[ *(params_count * 2).times.map { bytes.next } ] 36 | .transform_keys(&:to_sym) 37 | 38 | Node.new ServerNode::Properties.new(name, **params) 39 | end 40 | 41 | def associate(node, id, parent) 42 | node.id = id 43 | node.parent = parent 44 | node 45 | end 46 | end 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /lib/scruby/graph/node.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Graph 3 | class Node 4 | attr_accessor :obj, :id, :parent, :graph 5 | 6 | def initialize(obj = nil, id = nil, parent = nil) 7 | @obj, @id, @parent = obj, id, parent 8 | end 9 | 10 | def children 11 | graph.children_for(self) 12 | end 13 | 14 | def ==(other) 15 | self.class == other.class && 16 | self.id == other.id && 17 | self.graph == other.graph 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/scruby/graph/print.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Graph 3 | module Print 4 | class << self 5 | def print(root) 6 | puts visualize(root) 7 | end 8 | 9 | def visualize(root) 10 | visualize_node(root, [], "", nil) 11 | end 12 | 13 | protected 14 | 15 | def visualize_node(node, siblings, padding, param_name) 16 | is_last = node.eql? siblings.last 17 | 18 | # TODO: refactor 19 | inputs = 20 | if node.respond_to?(:inputs) 21 | node.inputs 22 | elsif node.respond_to?(:children) 23 | node.children 24 | else 25 | [] 26 | end 27 | 28 | # TODO: refactor 29 | param_names = UgenGraph::UgenNode === node ? node.parameter_names : [] 30 | 31 | child_padding = 32 | case 33 | when siblings.empty? 34 | padding 35 | when is_last 36 | padding + " " 37 | else 38 | padding + " │ " 39 | end 40 | 41 | [ 42 | padding, 43 | (" #{is_last ? '└' : '├'}─ " unless siblings.empty?), 44 | [ param_name, node.print_name ].compact.join(": "), 45 | ("\n" if inputs.any?), 46 | 47 | inputs.zip(param_names).map { |i, name| 48 | visualize_node(i, inputs, child_padding, name) 49 | }, 50 | 51 | ("\n" unless is_last) 52 | ].join 53 | end 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /lib/scruby/group.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Group 3 | include ServerNode 4 | 5 | def node_to_head(other) 6 | other.move_to_head(self) 7 | end 8 | 9 | def node_to_tail(other) 10 | other.move_to_tail(self) 11 | end 12 | 13 | def free_all 14 | send_msg("/g_freeAll", id) 15 | end 16 | 17 | def deep_free 18 | send_msg("/g_deepFree", id) 19 | end 20 | 21 | def dump_tree 22 | end 23 | 24 | def query_tree 25 | end 26 | 27 | def create(action, target) 28 | super(id, map_action(action), target.id) 29 | end 30 | 31 | def creation_message(action, target) 32 | super(id, map_action(action), target.id) 33 | end 34 | 35 | # TODO: no specs 36 | def children 37 | server.nodes.children_for(node) 38 | end 39 | 40 | def inspect 41 | super(id: id) 42 | end 43 | 44 | private 45 | 46 | def creation_cmd; "/g_new" end 47 | 48 | class << self 49 | def create(server) 50 | new(server).create(:head, server.node(1)) 51 | end 52 | 53 | def head(group) 54 | new(group.server).create(:head, group) 55 | end 56 | 57 | def tail(group) 58 | new(group.server).create(:tail, group) 59 | end 60 | 61 | def before(node) 62 | new(node.server).create(:before, node) 63 | end 64 | 65 | def after(node) 66 | new(node.server).create(:after, node) 67 | end 68 | 69 | def replace(node) 70 | new(node.server).create(:replace, node) 71 | end 72 | end 73 | end 74 | end 75 | -------------------------------------------------------------------------------- /lib/scruby/helpers.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Helpers 3 | class << self 4 | def included(base) 5 | base.include Scruby 6 | base.include Ugen 7 | base.include Ugen::Operations::OperationHelpers 8 | end 9 | end 10 | 11 | def control(val) 12 | UgenGraph::ControlName.new(val, :control) 13 | end 14 | 15 | def scalar(val) 16 | UgenGraph::ControlName.new(val, :scalar) 17 | end 18 | 19 | def trigger(val) 20 | UgenGraph::ControlName.new(val, :trigger) 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/scruby/par_group.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class ParGroup < Group 3 | private 4 | 5 | def creation_cmd; "/p_new" end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/pretty_inspectable.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module PrettyInspectable 3 | def inspect(**params) 4 | params = params.map { |k, v| "#{k}=#{v.inspect}" }.join(" ") 5 | "#<#{self.class.name || self.class} #{params}>" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/process.rb: -------------------------------------------------------------------------------- 1 | require "tty-which" 2 | require "forwardable" 3 | require "concurrent-edge" 4 | 5 | 6 | module Scruby 7 | class Process 8 | extend Forwardable 9 | include PrettyInspectable 10 | 11 | attr_reader :binary, :flags, :env, :pid 12 | 13 | 14 | def initialize(binary, flags = "", env: {}) 15 | @binary = TTY::Which.which(binary) || binary 16 | @flags = flags 17 | @env = env.map { |k, v| "#{k.to_s.upcase}=#{v}" }.join(" ") 18 | @semaphore = Mutex.new 19 | @reader, @writer = IO.pipe 20 | end 21 | 22 | def spawn 23 | return self if alive? 24 | 25 | @stdout, stdoutw = IO.pipe 26 | stdinr, @stdin = IO.pipe 27 | 28 | @pid = Kernel.spawn("#{env} #{binary} #{flags}", in: stdinr, 29 | err: [ :child, :out ], 30 | out: stdoutw) 31 | 32 | @io_thread = Thread.new { loop &method(:stdout_gets) } 33 | 34 | Registry.register(self) 35 | ::Process.detach(pid) 36 | self 37 | end 38 | 39 | def alive? 40 | pid && ::Process.kill(0, pid) && true || false 41 | rescue Errno::ESRCH # No such process 42 | false 43 | rescue Errno::EPERM # The process exists 44 | true 45 | end 46 | alias running? alive? 47 | 48 | def kill 49 | return false unless alive? 50 | ::Process.kill("HUP", pid) 51 | io_thread.kill 52 | true 53 | end 54 | 55 | def stdin_puts(str) 56 | stdin.puts(str) 57 | end 58 | 59 | def read 60 | ios, _ = IO.select([ reader ], nil, nil, 0.001) 61 | ios&.first&.gets 62 | end 63 | 64 | def puts_gets(str) 65 | semaphore.synchronize do 66 | true while read 67 | stdin_puts str 68 | read 69 | end 70 | end 71 | 72 | def inspect 73 | super(binary: binary) 74 | end 75 | 76 | private 77 | 78 | attr_reader :semaphore, :stdout, :stdin, :reader, :writer, 79 | :io_thread 80 | 81 | def stdout_gets 82 | line = stdout.gets 83 | 84 | writer.puts(line) 85 | print_line(stdout, line) 86 | end 87 | 88 | def print_line(io, line) 89 | color = (io.to_i % 7) + 31 90 | print "\e[#{color}m[#{binary} #{pid}] #{line}\e[0m\e[1000D" 91 | end 92 | 93 | class << self 94 | def spawn(binary, *args, env: {}) 95 | new(binary, *args, env: env).spawn 96 | end 97 | end 98 | end 99 | end 100 | -------------------------------------------------------------------------------- /lib/scruby/process/registry.rb: -------------------------------------------------------------------------------- 1 | require "concurrent" 2 | require "singleton" 3 | 4 | 5 | module Scruby 6 | class Process 7 | class Registry 8 | include Singleton 9 | 10 | def initialize 11 | @processes = Concurrent::Array.new 12 | 13 | at_exit { @processes.each(&:kill) } 14 | 15 | Thread.new do 16 | loop do 17 | @processes.select!(&:alive?) 18 | sleep 0.5 19 | end 20 | end 21 | end 22 | 23 | def register(process) 24 | @processes.push(process) 25 | end 26 | 27 | def processes 28 | @processes.dup 29 | end 30 | 31 | class << self 32 | def register(process) 33 | instance.register(process) 34 | end 35 | 36 | def deregister(process) 37 | instance.deregister(process) 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/scruby/sclang.rb: -------------------------------------------------------------------------------- 1 | require "concurrent-edge" 2 | 3 | 4 | module Scruby 5 | class SclangError < StandardError; end 6 | 7 | class Sclang 8 | include Concurrent 9 | 10 | def initialize 11 | @process = Process.new("sclang", "-i scruby") 12 | end 13 | 14 | def spawn 15 | spawn_async.value! 16 | end 17 | 18 | def spawn_async 19 | return Promises.fulfilled_future(self) if process.alive? 20 | 21 | process.spawn 22 | 23 | Promises.future(Cancellation.timeout(3)) do |cancelation| 24 | loop { 25 | case process.read 26 | when /Welcome/ then break 27 | when /Error/ then raise(SclangError, "failed to spawn sclang") 28 | else 29 | cancelation.check! 30 | end 31 | } 32 | 33 | self 34 | end 35 | end 36 | 37 | def kill 38 | process.kill 39 | end 40 | 41 | def eval(code) 42 | unless process.alive? 43 | raise SclangError, "sclang process not running, try `sclang.spawn`" 44 | end 45 | 46 | eval_async(code).value! 47 | end 48 | 49 | def eval_async(code) 50 | Promises.future do 51 | process.puts_gets("(#{code}).postcs \e")&.strip 52 | end 53 | end 54 | 55 | private 56 | 57 | attr_reader :process 58 | 59 | class << self 60 | def spawn 61 | new.spawn 62 | end 63 | 64 | def main 65 | @main ||= new 66 | end 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /lib/scruby/sclang/helpers.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Sclang 3 | module Helpers 4 | module_function 5 | 6 | def literal(value) 7 | case value 8 | when String, TrueClass, FalseClass, NilClass, Numeric 9 | value.inspect 10 | when Symbol 11 | "'#{value}'" 12 | else 13 | raise(ArgumentError, 14 | "#{value.inspect} is not of a valid server option type") 15 | end 16 | end 17 | 18 | def camelize(str) 19 | str.split("_").each_with_index 20 | .map { |s, i| i.zero? ? s : s.capitalize }.join 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/scruby/server/local.rb: -------------------------------------------------------------------------------- 1 | require "singleton" 2 | 3 | module Scruby 4 | class Server 5 | class Local < Server 6 | include Singleton 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/server/message_queue.rb: -------------------------------------------------------------------------------- 1 | require "ruby-osc" 2 | require "concurrent-edge" 3 | 4 | module Scruby 5 | class Server 6 | class MessageQueue 7 | include Concurrent 8 | include OSC 9 | 10 | attr_reader :message_id, :server, :patterns, :thread 11 | attr_accessor :debug 12 | 13 | private :message_id, :server, :patterns, :thread 14 | 15 | def initialize(server) 16 | @server = server 17 | @message_id = Concurrent::AtomicFixnum.new 18 | @patterns = Concurrent::Array.new 19 | end 20 | 21 | def receive(address = nil, timeout: 0.5, &pred) 22 | run 23 | 24 | future = Promises.resolvable_future 25 | patterns << [ address, pred, future ] 26 | 27 | return future unless timeout 28 | Promises.any(future, cancellation_future(timeout)) 29 | end 30 | 31 | def sync 32 | id = message_id.increment 33 | 34 | server.send_bundle Message.new("/sync", id) 35 | receive(timeout: 0.2) do |msg| 36 | msg.address == "/synced" && msg.args.first == id 37 | end 38 | end 39 | 40 | def run 41 | return thread if alive? 42 | 43 | @thread = Thread.new do 44 | loop { dispatch socket.recvfrom(65_535).first } 45 | end 46 | end 47 | 48 | def alive? 49 | thread&.alive? || false 50 | end 51 | alias running? alive? 52 | 53 | def flush 54 | patterns.delete_if do |_, _, future| 55 | future.reject CancelledOperationError.new("server quitted") 56 | end 57 | end 58 | 59 | private 60 | 61 | def dispatch(raw) 62 | msg = OSC.decode(raw) 63 | puts "[#{server.host} #{server.port}] #{msg.inspect}" if debug 64 | dispatch_msg msg 65 | end 66 | 67 | def dispatch_msg(message) 68 | patterns.delete_if do |pattern, pred, future| 69 | next true if future.rejected? 70 | 71 | next unless 72 | (pattern || pred) && 73 | (pattern.nil? || pattern === message.address) && 74 | (pred.nil? || pred.call(message, future)) 75 | 76 | future.evaluate_to { message } if future.pending? 77 | 78 | true 79 | rescue StandardError => e 80 | puts e 81 | end 82 | end 83 | 84 | def socket 85 | server.socket 86 | end 87 | 88 | def cancellation_future(timeout) 89 | cancellation = Cancellation.timeout(timeout) 90 | 91 | Promises.future(cancellation) do |c| 92 | loop { c.check!; sleep 0.1 } 93 | end 94 | end 95 | end 96 | end 97 | end 98 | -------------------------------------------------------------------------------- /lib/scruby/server/nodes.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Server 3 | class Nodes 4 | include Enumerable 5 | 6 | attr_reader :server, :semaphore, :graph 7 | private :server, :semaphore 8 | 9 | def initialize(server) 10 | @graph = Graph.new([]) 11 | @server = server 12 | @semaphore = Mutex.new 13 | end 14 | 15 | def decode_and_update(msg) 16 | graph = Graph::Decoder.decode(msg) 17 | synchronize { @graph = graph } 18 | self 19 | end 20 | 21 | def clear 22 | synchronize { @graph = Graph.new([]) } 23 | end 24 | 25 | def add(node) 26 | synchronize { graph.add(node) } 27 | end 28 | 29 | def each(&block) 30 | graph.to_a.each(&method(:wrap) >> block) 31 | end 32 | 33 | def children_for(node) 34 | graph.children_for(node).map(&method(:wrap)) 35 | end 36 | 37 | def [](idx) 38 | n = node(idx) 39 | wrap(n) if n 40 | end 41 | 42 | def node(idx) 43 | synchronize { graph[idx] } 44 | end 45 | 46 | def inspect 47 | first.visualize 48 | end 49 | 50 | private 51 | 52 | def synchronize(&block) 53 | semaphore.synchronize(&block) 54 | end 55 | 56 | def wrap(node) 57 | return Group.new(server, node.id) if node.obj&.name.nil? 58 | Synth.new(server, node.id) 59 | end 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /lib/scruby/server_node/properties.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module ServerNode 3 | class Properties 4 | attr_reader :name, :params 5 | 6 | def initialize(name, params) 7 | @name, @params = name, params 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/synth.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class Synth 3 | include ServerNode 4 | 5 | def get 6 | end 7 | 8 | def get_n 9 | end 10 | 11 | def name 12 | obj&.name 13 | end 14 | 15 | def params 16 | obj&.params 17 | end 18 | 19 | def create(action, target, name, **params) 20 | super(name, id, map_action(action), target.id, *params.flatten) 21 | end 22 | 23 | def creation_message(action, target, name, **params) 24 | super(name, id, map_action(action), target.id, *params.flatten) 25 | end 26 | 27 | def print_name 28 | params = params&.map { |k, v| "#{k}: #{v}" }&.join(', ') 29 | "#{super} - #{name} #{params}" 30 | end 31 | 32 | def inspect 33 | super(**{ name: name, id: id }.compact) 34 | end 35 | 36 | private 37 | 38 | def creation_cmd; "/s_new" end 39 | def obj; node&.obj end 40 | 41 | class << self 42 | def create(name, server, **args) 43 | new(server).create(:head, server.node(1), name, **args) 44 | end 45 | 46 | def head(group, name, **args) 47 | new(group.server).create(:head, group, name, **args) 48 | end 49 | 50 | def tail(group, name, **args) 51 | new(group.server).create(:tail, group, name, **args) 52 | end 53 | 54 | def before(node, name, **args) 55 | new(node.server).create(:before, node, name, **args) 56 | end 57 | 58 | def after(node, name, **args) 59 | new(node.server).create(:after, node, name, **args) 60 | end 61 | 62 | def replace(node, name, **args) 63 | new(node.server).create(:replace, node, name, **args) 64 | end 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /lib/scruby/synth_def.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class SynthDef 3 | extend Forwardable 4 | 5 | attr_reader :graph 6 | def_delegators :graph, :encode, :send_to, :print, :name 7 | 8 | 9 | def initialize(name = nil, &block) 10 | controls = catch(:args) { param_defaults(&block) } 11 | root_ugen = yield(*controls.keys) 12 | 13 | unless root_ugen.is_a? Ugen::Base 14 | raise TypeError, %W[ 15 | expected return of block to be a Ugen::Base 16 | but it is `#{root_ugen.inspect}` 17 | ].join(" ") 18 | end 19 | 20 | @graph = UgenGraph.new(root_ugen, name, **controls) 21 | end 22 | 23 | private 24 | 25 | def param_defaults(&block) 26 | found = false 27 | 28 | TracePoint.new(:b_call) { |t| 29 | next found = t.method_id == __method__ unless found 30 | 31 | throw :args, 32 | t.parameters.map { |_, n| [ n, t.binding.eval(n.to_s) ] }.to_h 33 | }.enable { yield } 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /lib/scruby/ugen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | RATES = %i(scalar trigger demand control audio).freeze 4 | E_RATES = %i(scalar control audio demand).freeze 5 | 6 | class << self 7 | def max_rate(*args) 8 | MultiChannel.new([*args].flatten).rate 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/scruby/ugen/a2_k.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class A2K < Gen 4 | rates :control 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/abstract_out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class AbstractOut < Ugen::Base 4 | def output_specs; [] end 5 | def channel_count; 0 end 6 | 7 | def input_values 8 | super.flatten 9 | end 10 | 11 | def parameter_names 12 | super - %i(channels_array) 13 | end 14 | 15 | def out? 16 | true 17 | end 18 | 19 | class << self 20 | def ar(*args, **kwargs) 21 | build(:audio, *args, **kwargs) 22 | end 23 | alias audio ar 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/scruby/ugen/allpass_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class AllpassC < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/allpass_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class AllpassL < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/allpass_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class AllpassN < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/amp_comp.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class AmpComp < Gen 4 | rates :control, :audio, :scalar 5 | inputs freq: nil, root: nil, exp: 0.3333 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/amp_comp_a.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class AmpCompA < Gen 4 | rates :control, :audio, :scalar 5 | inputs freq: 1000, root: 0, min_amp: 0.32, root_amp: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/amplitude.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Amplitude < Gen 4 | rates :control, :audio 5 | inputs input: 0, attack_time: 0.01, release_time: 0.01 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/apf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class APF < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, radius: 0.8 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_all_pass.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BAllPass < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, rq: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_band_pass.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BBandPass < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, bw: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_band_stop.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BBandStop < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, bw: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_hi_pass.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BHiPass < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, rq: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_hi_shelf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BHiShelf < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, rs: 1, db: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_low_pass.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BLowPass < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, rq: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_low_shelf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BLowShelf < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, rs: 1, db: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/b_peak_eq.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BPeakEQ < Gen 4 | rates :audio 5 | inputs input: nil, freq: 1200, rq: 1, db: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/balance2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Balance2 < Gen 4 | rates :control, :audio 5 | inputs left: nil, right: nil, pos: 0, level: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/ball.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Ball < Gen 4 | rates :control, :audio 5 | inputs input: 0, g: 1, damp: 0, friction: 0.01 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/beat_track.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BeatTrack < Gen 4 | rates :control 5 | inputs chain: nil, lock: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/beat_track2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BeatTrack2 < Gen 4 | rates :control 5 | inputs busindex: nil, numfeatures: nil, windowsize: 2, 6 | phaseaccuracy: 0.02, lock: 0, weightingscheme: nil 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/bi_pan_b2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BiPanB2 < Gen 4 | rates :control, :audio 5 | inputs in_a: nil, in_b: nil, azimuth: nil, gain: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/binary_op_ugen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BinaryOpUgen < Operation 4 | attributes operation: nil 5 | inputs left: nil, right: nil 6 | 7 | class << self 8 | def apply(operation, left, right) 9 | rate = Ugen.max_rate(left, right) 10 | 11 | return optimize_add(rate, left, right) if operation == :add 12 | new(operation, left, right, rate: rate) 13 | end 14 | 15 | private 16 | 17 | def optimize_add(rate, left, right) 18 | ary = MultiChannel.new([ *left ]) 19 | .zip([ *right ]) 20 | .map { |a, b| optimize(rate, a, b) } 21 | 22 | ary.size == 1 ? ary.first : MultiChannel.new(ary) 23 | end 24 | 25 | def optimize(rate, left, right) 26 | if [ mul?(left), mul?(right) ].any? 27 | mul_add(rate, left, right) 28 | else 29 | new(:add, left, right, rate: rate) 30 | end 31 | end 32 | 33 | def mul_add(rate, one, other) 34 | if mul?(one) 35 | MulAdd.new(one.left, one.right, other, rate: rate) 36 | else 37 | MulAdd.new(other.left, other.right, one, rate: rate) 38 | end 39 | end 40 | 41 | def mul?(ugen) 42 | BinaryOpUgen === ugen && ugen.operation == :mul 43 | end 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/scruby/ugen/blip.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Blip < Gen 4 | rates :control, :audio 5 | inputs freq: 440, numharm: 200 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/block_size.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BlockSize < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/bpf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BPF < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, rq: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/bpz2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BPZ2 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/brf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BRF < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, rq: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/brown_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BrownNoise < Gen 4 | rates :control, :audio 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/brz2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BRZ2 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_allpass_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufAllpassC < Gen 4 | rates :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_allpass_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufAllpassL < Gen 4 | rates :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_allpass_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufAllpassN < Gen 4 | rates :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_channels.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufChannels < Gen 4 | rates :control, :scalar 5 | inputs bufnum: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_comb_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufCombC < Gen 4 | rates :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_comb_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufCombL < Gen 4 | rates :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_comb_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufCombN < Gen 4 | rates :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_delay_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufDelayC < Gen 4 | rates :control, :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_delay_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufDelayL < Gen 4 | rates :control, :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_delay_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufDelayN < Gen 4 | rates :control, :audio 5 | inputs buf: 0, input: 0, delaytime: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_dur.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufDur < Gen 4 | rates :control, :scalar 5 | inputs bufnum: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_frames.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufFrames < Gen 4 | rates :control, :scalar 5 | inputs bufnum: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_rate_scale.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufRateScale < Gen 4 | rates :control, :scalar 5 | inputs bufnum: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_rd.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufRd < Gen 4 | rates :control, :audio 5 | attributes channel_count: 1 6 | 7 | inputs bufnum: 0, phase: 0, loop: 1, interpolation: 2 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_sample_rate.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufSampleRate < Gen 4 | rates :control, :scalar 5 | inputs bufnum: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_samples.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufSamples < Gen 4 | rates :control, :scalar 5 | inputs bufnum: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/buf_wr.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class BufWr < Gen 4 | rates :control, :audio 5 | inputs input_array: nil, bufnum: 0, phase: 0, loop: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/c_osc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class COsc < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, freq: 440, beats: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/check_bad_values.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CheckBadValues < Gen 4 | rates :control, :audio 5 | inputs input: 0, id: 0, post: 2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/clip.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Clip < Gen 4 | rates :control, :audio, :scalar 5 | inputs input: 0, lo: 0, hi: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/clip_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ClipNoise < Gen 4 | rates :control, :audio 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/coin_gate.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CoinGate < Gen 4 | rates :control, :audio 5 | inputs prob: nil, input: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/comb_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CombC < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/comb_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CombL < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/comb_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CombN < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/compander.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Compander < Gen 4 | rates :audio 5 | inputs input: 0, control: 0, thresh: 0.5, slope_below: 1, 6 | slope_above: 1, clamp_time: 0.01, relax_time: 0.1 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/compander_d.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CompanderD < Gen 4 | rates :audio 5 | inputs input: 0, thresh: 0.5, slope_below: 1, slope_above: 1, 6 | clamp_time: 0.01, relax_time: 0.01 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/control.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Control < Gen 4 | rates :scalar, :control, :trigger 5 | attributes control_names: [] 6 | 7 | def output_specs 8 | control_names.map(&:rate_index) 9 | end 10 | 11 | def channel_count 12 | control_names.count 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/scruby/ugen/control_dur.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ControlDur < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/control_rate.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ControlRate < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/convolution.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Convolution < Gen 4 | rates :audio 5 | inputs input: nil, kernel: nil, framesize: 512 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/convolution2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Convolution2 < Gen 4 | rates :audio 5 | inputs input: nil, kernel: nil, trigger: 0, framesize: 2048 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/convolution2_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Convolution2L < Gen 4 | rates :audio 5 | inputs input: nil, kernel: nil, trigger: 0, framesize: 2048, 6 | crossfade: 1 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/convolution3.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Convolution3 < Gen 4 | rates :control, :audio 5 | inputs input: nil, kernel: nil, trigger: 0, framesize: 2048 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/crackle.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Crackle < Gen 4 | rates :control, :audio 5 | inputs chaos_param: 1.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/cusp_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CuspL < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: 1.9, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/cusp_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class CuspN < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: 1.9, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dbrown.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dbrown < Gen 4 | rates nil 5 | inputs lo: 0, hi: 1, step: 0.01, length: "inf" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dbufrd.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dbufrd < Gen 4 | rates nil 5 | inputs bufnum: 0, phase: 0, loop: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dbufwr.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dbufwr < Gen 4 | rates nil 5 | inputs input: 0, bufnum: 0, phase: 0, loop: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DC < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dconst.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dconst < Gen 4 | rates nil 5 | inputs sum: nil, input: nil, tolerance: 0.001 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/decay.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Decay < Gen 4 | rates :control, :audio 5 | inputs input: 0, decay_time: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/decay2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Decay2 < Gen 4 | rates :control, :audio 5 | inputs input: 0, attack_time: 0.01, decay_time: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/decode_b2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DecodeB2 < Gen 4 | rates :control, :audio 5 | attributes channel_count: 1 6 | 7 | inputs w: nil, x: nil, y: nil, orientation: 0.5 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/degree_to_key.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DegreeToKey < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, input: 0, octave: 12 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/del_tap_rd.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DelTapRd < Gen 4 | rates :control, :audio 5 | inputs buffer: nil, phase: nil, del_time: nil, interp: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/del_tap_wr.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DelTapWr < Gen 4 | rates :control, :audio 5 | inputs buffer: nil, input: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/delay1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Delay1 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/delay2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Delay2 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/delay_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DelayC < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/delay_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DelayL < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/delay_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DelayN < Gen 4 | rates :control, :audio 5 | inputs input: 0, maxdelaytime: 0.2, delaytime: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/demand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Demand < Gen 4 | rates :control, :audio 5 | inputs trig: nil, reset: nil, demand_u_gens: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/demand_env_gen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DemandEnvGen < Gen 4 | rates :control, :audio 5 | inputs level: nil, dur: nil, shape: 1, curve: 0, gate: 1, reset: 1, 6 | level_scale: 1, level_bias: 0, time_scale: 1, 7 | done_action: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/detect_index.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DetectIndex < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/detect_silence.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DetectSilence < Gen 4 | rates :control, :audio 5 | inputs input: 0, amp: 0.0001, time: 0.1, done_action: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dgeom.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dgeom < Gen 4 | rates nil 5 | inputs start: 1, grow: 2, length: "inf" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dibrown.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dibrown < Gen 4 | rates nil 5 | inputs lo: 0, hi: 1, step: 0.01, length: "inf" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/disk_in.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DiskIn < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs bufnum: nil, loop: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/disk_out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class DiskOut < Gen 4 | rates :audio 5 | inputs bufnum: nil, channels_array: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/diwhite.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Diwhite < Gen 4 | rates nil 5 | inputs lo: 0, hi: 1, length: "inf" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/done.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Done < Gen 4 | rates :control 5 | inputs src: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/done_actions.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | module DoneActions 4 | ACTIONS = %i( 5 | none 6 | pause 7 | free 8 | free_and_prev 9 | free_and_next 10 | free_and_all_in_prev 11 | free_and_all_in_next 12 | free_self_to_head 13 | free_self_to_tail 14 | free_and_pause_prev 15 | free_and_pause_next 16 | free_and_deep_prev 17 | free_and_deep_next 18 | free_and_siblings 19 | free_group 20 | free_and_resume_next 21 | ) 22 | 23 | protected 24 | 25 | def done_action=(action) 26 | super ACTIONS.index(action) || action 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dpoll.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dpoll < Gen 4 | rates nil 5 | inputs input: nil, label: nil, run: 1, trigid: -1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/drand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Drand < Gen 4 | rates nil 5 | inputs list: nil, repeats: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dreset.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dreset < Gen 4 | rates nil 5 | inputs input: nil, reset: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dseq.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dseq < Gen 4 | rates nil 5 | inputs list: nil, repeats: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dser.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dser < Gen 4 | rates nil 5 | inputs list: nil, repeats: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dseries.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dseries < Gen 4 | rates nil 5 | inputs start: 1, step: 1, length: "inf" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dshuf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dshuf < Gen 4 | rates nil 5 | inputs list: nil, repeats: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dstutter.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dstutter < Gen 4 | rates nil 5 | inputs n: nil, input: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dswitch.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dswitch < Gen 4 | rates nil 5 | inputs list: nil, index: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dswitch1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dswitch1 < Gen 4 | rates nil 5 | inputs list: nil, index: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dunique.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dunique < Gen 4 | rates nil 5 | inputs source: nil, max_buffer_size: 1024, protected: true 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dust.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dust < Gen 4 | rates :control, :audio 5 | inputs density: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dust2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dust2 < Gen 4 | rates :control, :audio 5 | inputs density: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/duty.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Duty < Gen 4 | rates :control, :audio 5 | inputs dur: 1, reset: 0, level: 1, done_action: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dwhite.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dwhite < Gen 4 | rates nil 5 | inputs lo: 0, hi: 1, length: "inf" 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dwrand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dwrand < Gen 4 | rates nil 5 | inputs list: nil, weights: nil, repeats: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/dxrand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Dxrand < Gen 4 | rates nil 5 | inputs list: nil, repeats: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/env_gen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class EnvGen < Gen 4 | rates :control, :audio 5 | inputs envelope: nil, gate: 1, level_scale: 1, level_bias: 0, 6 | time_scale: 1, done_action: 0 7 | 8 | def inputs 9 | %i(gate level_scale level_bias time_scale done_action envelope) 10 | .map { |name| [ name, super.fetch(name) ] }.to_h 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/scruby/ugen/exp_rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ExpRand < Gen 4 | rates nil 5 | inputs lo: 0.01, hi: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/f_sin_osc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FSinOsc < Gen 4 | rates :control, :audio 5 | inputs freq: 440, iphase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/fb_sine_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FBSineC < Gen 4 | rates :audio 5 | inputs freq: 22_050, im: 1, fb: 0.1, a: 1.1, c: 0.5, xi: 0.1, 6 | yi: 0.1 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/fb_sine_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FBSineL < Gen 4 | rates :audio 5 | inputs freq: 22_050, im: 1, fb: 0.1, a: 1.1, c: 0.5, xi: 0.1, 6 | yi: 0.1 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/fb_sine_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FBSineN < Gen 4 | rates :audio 5 | inputs freq: 22_050, im: 1, fb: 0.1, a: 1.1, c: 0.5, xi: 0.1, 6 | yi: 0.1 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/fft.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FFT < Gen 4 | rates nil 5 | inputs buffer: nil, input: 0, hop: 0.5, wintype: 0, active: 1, 6 | winsize: 0 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/fold.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Fold < Gen 4 | rates :control, :audio, :scalar 5 | inputs input: 0, lo: 0, hi: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/formant.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Formant < Gen 4 | rates :audio 5 | inputs fundfreq: 440, formfreq: 1760, bwfreq: 880 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/formlet.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Formlet < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, attacktime: 1, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/fos.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FOS < Gen 4 | rates :control, :audio 5 | inputs input: 0, a0: 0, a1: 0, b1: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/free.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Free < Gen 4 | rates :control 5 | inputs trig: nil, id: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/free_self.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FreeSelf < Gen 4 | rates :control 5 | inputs input: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/free_self_when_done.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FreeSelfWhenDone < Gen 4 | rates :control 5 | inputs src: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/free_verb.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FreeVerb < Gen 4 | rates :audio 5 | inputs input: nil, mix: 0.33, room: 0.5, damp: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/free_verb2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FreeVerb2 < Gen 4 | rates :audio 5 | inputs input: nil, in2: nil, mix: 0.33, room: 0.5, damp: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/freq_shift.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class FreqShift < Gen 4 | rates :audio 5 | inputs input: nil, freq: 0, phase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/g_verb.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GVerb < Gen 4 | rates :audio 5 | inputs input: nil, roomsize: 10, revtime: 3, damping: 0.5, 6 | inputbw: 0.5, spread: 15, drylevel: 1, earlyreflevel: 0.7, 7 | taillevel: 0.5, maxroomsize: 300 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gate.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Gate < Gen 4 | rates :control, :audio 5 | inputs input: 0, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gbman_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GbmanL < Gen 4 | rates :audio 5 | inputs freq: 22_050, xi: 1.2, yi: 2.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gbman_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GbmanN < Gen 4 | rates :audio 5 | inputs freq: 22_050, xi: 1.2, yi: 2.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Gen < Base 4 | class << self 5 | def ar(*args, **kwargs) 6 | build(:audio, *args, **kwargs) 7 | end 8 | alias audio ar 9 | 10 | def kr(*args, **kwargs) 11 | build(:control, *args, **kwargs) 12 | end 13 | alias control kr 14 | 15 | def ir(*args, **kwargs) 16 | build(:scalar, *args, **kwargs) 17 | end 18 | alias scalar ir 19 | 20 | private 21 | 22 | def build(rate, *args, **kwargs) 23 | defaults = self.defaults.merge(mul: 1, add: 0) 24 | params = positional_keyword_args(defaults, *args, **kwargs) 25 | mul, add = params.delete(:mul), params.delete(:add) 26 | ugen = new(rate: rate, **params) 27 | 28 | case [ mul, add ] 29 | in [ 1, 0 ] then ugen 30 | in [ 1, _ ] then ugen + add 31 | in [ _, 0 ] then ugen * mul 32 | in [ _, _ ] 33 | build_mul_add(ugen, rate, mul, add) 34 | end 35 | end 36 | 37 | def build_mul_add(ugen, rate, mul, add) 38 | MulAdd.new(ugen, mul, add, rate: rate) 39 | end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gendy1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Gendy1 < Gen 4 | rates :control, :audio 5 | inputs ampdist: 1, durdist: 1, adparam: 1, ddparam: 1, 6 | minfreq: { control: 20, audio: 440 }, 7 | maxfreq: { control: 1000, audio: 660 }, ampscale: 0.5, 8 | durscale: 0.5, init_c_ps: 12, knum: nil 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gendy2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Gendy2 < Gen 4 | rates :control, :audio 5 | inputs ampdist: 1, durdist: 1, adparam: 1, ddparam: 1, 6 | minfreq: { control: 20, audio: 440 }, 7 | maxfreq: { control: 1000, audio: 660 }, ampscale: 0.5, 8 | durscale: 0.5, init_c_ps: 12, knum: nil, a: 1.17, c: 0.31 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gendy3.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Gendy3 < Gen 4 | rates :control, :audio 5 | inputs ampdist: 1, durdist: 1, adparam: 1, ddparam: 1, freq: 440, 6 | ampscale: 0.5, durscale: 0.5, init_c_ps: 12, knum: nil 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/grain_buf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GrainBuf < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs trigger: 0, dur: 1, sndbuf: nil, playback_rate: 1, pos: 0, 8 | interp: 2, pan: 0, envbufnum: -1, max_grains: 512 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/grain_fm.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GrainFM < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs trigger: 0, dur: 1, carfreq: 440, modfreq: 200, index: 1, 8 | pan: 0, envbufnum: -1, max_grains: 512 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/grain_in.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GrainIn < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs trigger: 0, dur: 1, input: nil, pan: 0, envbufnum: -1, 8 | max_grains: 512 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/grain_sin.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GrainSin < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs trigger: 0, dur: 1, freq: 440, pan: 0, envbufnum: -1, 8 | max_grains: 512 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/gray_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class GrayNoise < Gen 4 | rates :control, :audio 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/hasher.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Hasher < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/henon_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class HenonC < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1.4, b: 0.3, x0: 0, x1: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/henon_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class HenonL < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1.4, b: 0.3, x0: 0, x1: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/henon_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class HenonN < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1.4, b: 0.3, x0: 0, x1: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/hilbert.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Hilbert < Gen 4 | rates :audio 5 | inputs input: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/hpf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class HPF < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/hpz1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class HPZ1 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/hpz2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class HPZ2 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/i_env_gen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class IEnvGen < Gen 4 | rates :control, :audio 5 | inputs envelope: nil, index: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/i_rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class IRand < Gen 4 | rates nil 5 | inputs lo: 0, hi: 127 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/ifft.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class IFFT < Gen 4 | rates :control, :audio 5 | inputs buffer: nil, wintype: 0, winsize: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/impulse.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Impulse < Gen 4 | rates :control, :audio 5 | inputs freq: 440, phase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/in.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class In < Gen 4 | rates :control, :audio 5 | attributes channel_count: 1 6 | 7 | inputs bus: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/in_feedback.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class InFeedback < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs bus: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/in_range.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class InRange < Gen 4 | rates :control, :audio, :scalar 5 | inputs input: 0, lo: 0, hi: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/in_rect.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class InRect < Gen 4 | rates :control, :audio 5 | inputs x: 0, y: 0, rect: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/in_trig.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class InTrig < Gen 4 | rates :control 5 | attributes channel_count: 1 6 | 7 | inputs bus: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/index.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Index < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/index_in_between.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class IndexInBetween < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/index_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class IndexL < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/info_u_gen_base.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class InfoUGenBase < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/integrator.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Integrator < Gen 4 | rates :control, :audio 5 | inputs input: 0, coef: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/k2_a.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class K2A < Gen 4 | rates :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/key_state.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class KeyState < Gen 4 | rates :control 5 | inputs keycode: 0, minval: 0, maxval: 1, lag: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/key_track.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class KeyTrack < Gen 4 | rates :control 5 | inputs chain: nil, keydecay: 2, chromaleak: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/klang.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Klang < Gen 4 | rates :audio 5 | inputs specifications_array_ref: nil, freqscale: 1, freqoffset: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/klank.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Klank < Gen 4 | rates :audio 5 | inputs specifications_array_ref: nil, input: nil, freqscale: 1, 6 | freqoffset: 0, decayscale: 1 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lag.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Lag < Gen 4 | rates :control, :audio 5 | inputs input: 0, lag_time: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lag2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Lag2 < Gen 4 | rates :control, :audio 5 | inputs input: 0, lag_time: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lag2_ud.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Lag2UD < Gen 4 | rates :control, :audio 5 | inputs input: 0, lag_time_u: 0.1, lag_time_d: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lag3.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Lag3 < Gen 4 | rates :control, :audio 5 | inputs input: 0, lag_time: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lag3_ud.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Lag3UD < Gen 4 | rates :control, :audio 5 | inputs input: 0, lag_time_u: 0.1, lag_time_d: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lag_in.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LagIn < Gen 4 | rates :control 5 | attributes channel_count: 1 6 | 7 | inputs bus: 0, lag: 0.1 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lag_ud.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LagUD < Gen 4 | rates :control, :audio 5 | inputs input: 0, lag_time_u: 0.1, lag_time_d: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/last_value.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LastValue < Gen 4 | rates :control, :audio 5 | inputs input: 0, diff: 0.01 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/latch.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Latch < Gen 4 | rates :control, :audio 5 | inputs input: 0, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/latoocarfian_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LatoocarfianC < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: 3, c: 0.5, d: 0.5, xi: 0.5, yi: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/latoocarfian_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LatoocarfianL < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: 3, c: 0.5, d: 0.5, xi: 0.5, yi: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/latoocarfian_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LatoocarfianN < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: 3, c: 0.5, d: 0.5, xi: 0.5, yi: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/leak_dc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LeakDC < Gen 4 | rates :control, :audio 5 | inputs input: 0, coef: { control: 0.9, audio: 0.995 } 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/least_change.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LeastChange < Gen 4 | rates :control, :audio 5 | inputs a: 0, b: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_clip_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFClipNoise < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_cub.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFCub < Gen 4 | rates :control, :audio 5 | inputs freq: 440, iphase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_gauss.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFGauss < Gen 4 | rates :control, :audio 5 | inputs duration: 1, width: 0.1, iphase: 0, loop: 1, done_action: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_noise0.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFNoise0 < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_noise1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFNoise1 < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_noise2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFNoise2 < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_par.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFPar < Gen 4 | rates :control, :audio 5 | inputs freq: 440, iphase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_pulse.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFPulse < Gen 4 | rates :control, :audio 5 | inputs freq: 440, iphase: 0, width: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_saw.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFSaw < Gen 4 | rates :control, :audio 5 | inputs freq: 440, iphase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lf_tri.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFTri < Gen 4 | rates :control, :audio 5 | inputs freq: 440, iphase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lfd_clip_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFDClipNoise < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lfd_noise0.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFDNoise0 < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lfd_noise1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFDNoise1 < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lfd_noise3.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LFDNoise3 < Gen 4 | rates :control, :audio 5 | inputs freq: 500 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/limiter.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Limiter < Gen 4 | rates :audio 5 | inputs input: 0, level: 1, dur: 0.01 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lin_cong_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LinCongC < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1.1, c: 0.13, m: 1, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lin_cong_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LinCongL < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1.1, c: 0.13, m: 1, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lin_cong_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LinCongN < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1.1, c: 0.13, m: 1, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lin_exp.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LinExp < Gen 4 | rates :control, :audio 5 | inputs input: 0, srclo: 0, srchi: 1, dstlo: 1, dsthi: 2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lin_pan2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LinPan2 < Gen 4 | rates :control, :audio 5 | inputs input: nil, pos: 0, level: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lin_rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LinRand < Gen 4 | rates nil 5 | inputs lo: 0, hi: 1, minmax: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lin_x_fade2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LinXFade2 < Gen 4 | rates :control, :audio 5 | inputs in_a: nil, in_b: 0, pan: 0, level: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/line.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Line < Gen 4 | rates :control, :audio 5 | inputs start: 0, finish: 1, dur: 1, done_action: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/linen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Linen < Gen 4 | rates :control 5 | inputs gate: 1, attack_time: 0.01, sus_level: 1, release_time: 1, 6 | done_action: 0 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/local_buf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LocalBuf < Gen 4 | rates nil 5 | inputs num_frames: 1, channel_count: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/local_in.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LocalIn < Gen 4 | rates :control, :audio 5 | attributes channel_count: 1 6 | 7 | inputs default: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/local_out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LocalOut < AbstractOut 4 | rates :control, :audio 5 | inputs channels_array: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/logistic.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Logistic < Gen 4 | rates :control, :audio 5 | inputs chaos_param: 3, freq: 1000, init: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lorenz_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LorenzL < Gen 4 | rates :audio 5 | inputs freq: 22_050, s: 10, r: 28, b: 2.667, h: 0.05, xi: 0.1, yi: 0, 6 | zi: 0 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/loudness.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Loudness < Gen 4 | rates :control 5 | inputs chain: nil, smask: 0.25, tmask: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lpf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LPF < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lpz1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LPZ1 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/lpz2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class LPZ2 < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mantissa_mask.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MantissaMask < Gen 4 | rates :control, :audio 5 | inputs input: 0, bits: 3 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/median.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Median < Gen 4 | rates :control, :audio 5 | inputs length: 3, input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mfcc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MFCC < Gen 4 | rates :control 5 | inputs chain: nil, numcoeff: 13 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mid_eq.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MidEQ < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, rq: 1, db: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mod_dif.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ModDif < Gen 4 | rates :control, :audio, :scalar 5 | inputs x: 0, y: 0, mod: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/moog_ff.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MoogFF < Gen 4 | rates :control, :audio 5 | inputs input: nil, freq: 100, gain: 2, reset: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/most_change.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MostChange < Gen 4 | rates :control, :audio 5 | inputs a: 0, b: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mouse_button.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MouseButton < Gen 4 | rates :control 5 | inputs minval: 0, maxval: 1, lag: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mouse_x.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MouseX < Gen 4 | rates :control 5 | inputs minval: 0, maxval: 1, warp: 0, lag: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mouse_y.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MouseY < Gen 4 | rates :control 5 | inputs minval: 0, maxval: 1, warp: 0, lag: 0.2 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/mul_add.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MulAdd < Gen 4 | rates :control, :audio 5 | inputs input: nil, mul: 1, add: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/multi_channel.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class MultiChannel 4 | include Equatable 5 | include Enumerable 6 | include Operations 7 | 8 | def initialize(ugens) 9 | @ugens = ugens.to_a 10 | end 11 | 12 | def each 13 | return enum_for(:each) unless block_given? 14 | @ugens.each { |u| yield u } 15 | end 16 | 17 | def rate 18 | index = ugens 19 | .map { |u| u.respond_to?(:rate) ? u.rate : :scalar } 20 | .map { |rate| Ugen::RATES.index(rate) }.max 21 | 22 | Ugen::RATES.fetch(index) 23 | end 24 | 25 | def zip(other) 26 | max_size = self.max_size(other) 27 | cycle.take(max_size).zip(other.cycle.take(max_size)) 28 | end 29 | 30 | def max_size(other) 31 | [ self, other ].max_by(&:size).size 32 | end 33 | 34 | def to_a 35 | @ugens.dup 36 | end 37 | 38 | def size 39 | @ugens.size 40 | end 41 | 42 | private 43 | 44 | attr_reader :ugens 45 | 46 | def cast(collection) 47 | self.class.new collection 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/scruby/ugen/n_rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NRand < Gen 4 | rates nil 5 | inputs lo: 0, hi: 1, n: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/node_id.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NodeID < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/normalizer.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Normalizer < Gen 4 | rates :audio 5 | inputs input: 0, level: 1, dur: 0.01 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/num_audio_buses.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NumAudioBuses < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/num_buffers.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NumBuffers < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/num_control_buses.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NumControlBuses < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/num_input_buses.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NumInputBuses < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/num_output_buses.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NumOutputBuses < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/num_running_synths.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class NumRunningSynths < Gen 4 | rates :control, :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/offset_out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class OffsetOut < AbstractOut 4 | rates :control, :audio 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/one_pole.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class OnePole < Gen 4 | rates :control, :audio 5 | inputs input: 0, coef: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/one_zero.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class OneZero < Gen 4 | rates :control, :audio 5 | inputs input: 0, coef: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/onsets.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Onsets < Gen 4 | rates :control 5 | inputs chain: nil, threshold: 0.5, odftype: "rcomplex", 6 | relaxtime: 1, floor: 0.1, mingap: 10, medianspan: 11, 7 | whtype: 1, rawodf: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/operation.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Operation < Base 4 | def special_index 5 | Operations.binary_indexes.fetch(operation) 6 | end 7 | 8 | def parameter_names 9 | [] 10 | end 11 | 12 | def print_name 13 | "#{operation.to_s.capitalize} (#{rate})" 14 | end 15 | 16 | class << self 17 | def inherited(base) 18 | base.rates Scruby::Ugen::RATES 19 | end 20 | 21 | def apply(*args) 22 | raise NotImplementedError 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/scruby/ugen/osc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Osc < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, freq: 440, phase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/osc_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class OscN < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, freq: 440, phase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Out < AbstractOut 4 | rates :control, :audio 5 | inputs bus: nil, channels_array: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/p_sin_grain.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PSinGrain < Gen 4 | rates :audio 5 | inputs freq: 440, dur: 0.2, amp: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pan2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Pan2 < Gen 4 | rates :control, :audio 5 | inputs input: nil, pos: 0, level: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pan4.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Pan4 < Gen 4 | rates :control, :audio 5 | inputs input: nil, xpos: 0, ypos: 0, level: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pan_az.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PanAz < Gen 4 | rates :control, :audio 5 | attributes channel_count: 1 6 | 7 | inputs input: nil, pos: 0, level: 1, width: 2, orientation: 0.5 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pan_b.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PanB < Gen 4 | rates :control, :audio 5 | inputs input: nil, azimuth: 0, elevation: 0, gain: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pan_b2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PanB2 < Gen 4 | rates :control, :audio 5 | inputs input: nil, azimuth: 0, gain: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/part_conv.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PartConv < Gen 4 | rates :audio 5 | inputs input: nil, fftsize: nil, irbufnum: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pause.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Pause < Gen 4 | rates :control 5 | inputs gate: nil, id: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pause_self.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PauseSelf < Gen 4 | rates :control 5 | inputs input: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pause_self_when_done.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PauseSelfWhenDone < Gen 4 | rates :control 5 | inputs src: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/peak.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Peak < Gen 4 | rates :control, :audio 5 | inputs input: 0, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/peak_follower.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PeakFollower < Gen 4 | rates :control, :audio 5 | inputs input: 0, decay: 0.999 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/phasor.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Phasor < Gen 4 | rates :control, :audio 5 | inputs trig: 0, playback_rate: 1, start: 0, finish: 1, reset_pos: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pink_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PinkNoise < Gen 4 | rates :control, :audio 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pitch.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Pitch < Gen 4 | rates :control 5 | inputs input: 0, init_freq: 440, min_freq: 60, max_freq: 4000, 6 | exec_freq: 100, max_bins_per_octave: 16, median: 1, 7 | amp_threshold: 0.01, peak_threshold: 0.5, down_sample: 1, 8 | clar: 0 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pitch_shift.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PitchShift < Gen 4 | rates :audio 5 | inputs input: 0, window_size: 0.2, pitch_ratio: 1, 6 | pitch_dispersion: 0, time_dispersion: 0 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/play_buf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PlayBuf < Gen 4 | rates :control, :audio 5 | attributes channel_count: 1 6 | 7 | inputs bufnum: 0, playback_rate: 1, trigger: 1, start_pos: 0, 8 | loop: 0, done_action: 0 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pluck.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Pluck < Gen 4 | rates :audio 5 | inputs input: 0, trig: 1, maxdelaytime: 0.2, delaytime: 0.2, 6 | decaytime: 1, coef: 0.5 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/poll.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Poll < Gen 4 | rates :control, :audio 5 | inputs trig: nil, input: nil, label: nil, trigid: -1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pulse.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Pulse < Gen 4 | rates :control, :audio 5 | inputs freq: 440, width: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pulse_count.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PulseCount < Gen 4 | rates :control, :audio 5 | inputs trig: 0, reset: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pulse_divider.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PulseDivider < Gen 4 | rates :control, :audio 5 | inputs trig: 0, div: 2, start: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_add.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVAdd < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_bin_scramble.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVBinScramble < Gen 4 | rates nil 5 | inputs buffer: nil, wipe: 0, width: 0.2, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_bin_shift.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVBinShift < Gen 4 | rates nil 5 | inputs buffer: nil, stretch: 1, shift: 0, interp: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_bin_wipe.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVBinWipe < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil, wipe: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_brick_wall.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVBrickWall < Gen 4 | rates nil 5 | inputs buffer: nil, wipe: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_chain_u_gen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVChainUGen < Gen 4 | rates nil 5 | inputs max_size: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_conformal_map.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVConformalMap < Gen 4 | rates nil 5 | inputs buffer: nil, areal: 0, aimag: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_conj.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVConj < Gen 4 | rates nil 5 | inputs buffer: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_copy.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVCopy < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_copy_phase.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVCopyPhase < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_diffuser.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVDiffuser < Gen 4 | rates nil 5 | inputs buffer: nil, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_div.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVDiv < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_hainsworth_foote.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVHainsworthFoote < Gen 4 | rates :audio 5 | inputs buffer: nil, proph: 0, propf: 0, threshold: 1, 6 | waittime: 0.04 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_jensen_andersen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVJensenAndersen < Gen 4 | rates :audio 5 | inputs buffer: nil, propsc: 0.25, prophfe: 0.25, prophfc: 0.25, 6 | propsf: 0.25, threshold: 1, waittime: 0.04 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_local_max.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVLocalMax < Gen 4 | rates nil 5 | inputs buffer: nil, threshold: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_above.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagAbove < Gen 4 | rates nil 5 | inputs buffer: nil, threshold: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_below.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagBelow < Gen 4 | rates nil 5 | inputs buffer: nil, threshold: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_clip.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagClip < Gen 4 | rates nil 5 | inputs buffer: nil, threshold: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_div.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagDiv < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil, zeroed: 0.0001 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_freeze.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagFreeze < Gen 4 | rates nil 5 | inputs buffer: nil, freeze: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_mul.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagMul < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagNoise < Gen 4 | rates nil 5 | inputs buffer: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_shift.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagShift < Gen 4 | rates nil 5 | inputs buffer: nil, stretch: 1, shift: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_smear.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagSmear < Gen 4 | rates nil 5 | inputs buffer: nil, bins: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mag_squared.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMagSquared < Gen 4 | rates nil 5 | inputs buffer: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_max.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMax < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_min.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMin < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_mul.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVMul < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_phase_shift.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVPhaseShift < Gen 4 | rates nil 5 | inputs buffer: nil, shift: nil, integrate: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_phase_shift270.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVPhaseShift270 < Gen 4 | rates nil 5 | inputs buffer: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_phase_shift90.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVPhaseShift90 < Gen 4 | rates nil 5 | inputs buffer: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_rand_comb.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVRandComb < Gen 4 | rates nil 5 | inputs buffer: nil, wipe: 0, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_rand_wipe.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVRandWipe < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil, wipe: 0, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_rect_comb.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVRectComb < Gen 4 | rates nil 5 | inputs buffer: nil, num_teeth: 0, phase: 0, width: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/pv_rect_comb2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class PVRectComb2 < Gen 4 | rates nil 5 | inputs buffer_a: nil, buffer_b: nil, num_teeth: 0, phase: 0, 6 | width: 0.5 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/quad_c.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class QuadC < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: -1, c: -0.75, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/quad_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class QuadL < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: -1, c: -0.75, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/quad_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class QuadN < Gen 4 | rates :audio 5 | inputs freq: 22_050, a: 1, b: -1, c: -0.75, xi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/radians_per_sample.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RadiansPerSample < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/ramp.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Ramp < Gen 4 | rates :control, :audio 5 | inputs input: 0, lag_time: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Rand < Gen 4 | rates nil 5 | inputs lo: 0, hi: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/rand_id.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RandID < Gen 4 | rates :control, :scalar 5 | inputs id: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/rand_seed.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RandSeed < Gen 4 | rates :control, :audio, :scalar 5 | inputs trig: 0, seed: 56_789 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/record_buf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RecordBuf < Gen 4 | rates :control, :audio 5 | inputs input_array: nil, bufnum: 0, offset: 0, rec_level: 1, 6 | pre_level: 0, run: 1, loop: 1, trigger: 1, done_action: 0 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/replace_out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ReplaceOut < AbstractOut 4 | rates :control, :audio 5 | inputs bus: nil, channels_array: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/resonz.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Resonz < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, bwr: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/rhpf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RHPF < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, rq: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/ringz.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Ringz < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, decaytime: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/rlpf.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RLPF < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, rq: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/rotate2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Rotate2 < Gen 4 | rates :control, :audio 5 | inputs x: nil, y: nil, pos: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/running_max.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RunningMax < Gen 4 | rates :control, :audio 5 | inputs input: 0, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/running_min.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RunningMin < Gen 4 | rates :control, :audio 5 | inputs input: 0, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/running_sum.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class RunningSum < Gen 4 | rates :control, :audio 5 | inputs input: nil, numsamp: 40 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sample_dur.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SampleDur < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sample_rate.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SampleRate < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sanitize.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Sanitize < Gen 4 | rates :control, :audio 5 | inputs input: 0, replace: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/saw.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Saw < Gen 4 | rates :control, :audio 5 | inputs freq: 440 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/schmidt.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Schmidt < Gen 4 | rates :control, :audio, :scalar 5 | inputs input: 0, lo: 0, hi: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/scope_out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ScopeOut < Gen 4 | rates :control, :audio 5 | inputs input_array: nil, bufnum: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/scope_out2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ScopeOut2 < Gen 4 | rates :control, :audio 5 | inputs input_array: nil, scope_num: 0, max_frames: 4096, 6 | scope_frames: nil 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/select.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Select < Gen 4 | rates :control, :audio 5 | inputs which: nil, array: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/send_trig.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SendTrig < Gen 4 | rates :control, :audio 5 | inputs input: 0, id: 0, value: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/set_reset_ff.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SetResetFF < Gen 4 | rates :control, :audio 5 | inputs trig: 0, reset: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/shaper.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Shaper < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sin_osc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SinOsc < Gen 4 | rates :control, :audio 5 | inputs freq: 440, phase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sin_osc_fb.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SinOscFB < Gen 4 | rates :control, :audio 5 | inputs freq: 440, feedback: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/slew.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Slew < Gen 4 | rates :control, :audio 5 | inputs input: 0, up: 1, dn: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/slope.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Slope < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sos.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SOS < Gen 4 | rates :control, :audio 5 | inputs input: 0, a0: 0, a1: 0, a2: 0, b1: 0, b2: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/spec_centroid.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SpecCentroid < Gen 4 | rates :control 5 | inputs buffer: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/spec_flatness.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SpecFlatness < Gen 4 | rates :control 5 | inputs buffer: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/spec_pcile.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SpecPcile < Gen 4 | rates :control 5 | inputs buffer: nil, fraction: 0.5, interpolate: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/spring.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Spring < Gen 4 | rates :control, :audio 5 | inputs input: 0, spring: 1, damp: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/standard_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class StandardL < Gen 4 | rates :audio 5 | inputs freq: 22_050, k: 1, xi: 0.5, yi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/standard_n.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class StandardN < Gen 4 | rates :audio 5 | inputs freq: 22_050, k: 1, xi: 0.5, yi: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/stepper.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Stepper < Gen 4 | rates :control, :audio 5 | inputs trig: 0, reset: 0, min: 0, max: 7, step: 1, resetval: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/stereo_convolution2_l.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class StereoConvolution2L < Gen 4 | rates :audio 5 | inputs input: nil, kernel_l: nil, kernel_r: nil, trigger: 0, 6 | framesize: 2048, crossfade: 1 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/scruby/ugen/subsample_offset.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SubsampleOffset < Gen 4 | rates :scalar 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sum3.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Sum3 < Gen 4 | rates nil 5 | inputs in0: nil, in1: nil, in2: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sum4.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Sum4 < Gen 4 | rates nil 5 | inputs in0: nil, in1: nil, in2: nil, in3: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sweep.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Sweep < Gen 4 | rates :control, :audio 5 | inputs trig: 0, playback_rate: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/sync_saw.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class SyncSaw < Gen 4 | rates :control, :audio 5 | inputs sync_freq: 440, saw_freq: 440 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t2_a.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class T2A < Gen 4 | rates :audio 5 | inputs input: 0, offset: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t2_k.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class T2K < Gen 4 | rates :control 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t_ball.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TBall < Gen 4 | rates :control, :audio 5 | inputs input: 0, g: 10, damp: 0, friction: 0.01 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t_delay.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TDelay < Gen 4 | rates :control, :audio 5 | inputs input: 0, dur: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t_duty.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TDuty < Gen 4 | rates :control, :audio 5 | inputs dur: 1, reset: 0, level: 1, done_action: 0, gap_first: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t_exp_rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TExpRand < Gen 4 | rates :control, :audio 5 | inputs lo: 0.01, hi: 1, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t_grains.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TGrains < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs trigger: 0, bufnum: 0, playback_rate: 1, center_pos: 0, 8 | dur: 0.1, pan: 0, amp: 0.1, interp: 4 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t_rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TRand < Gen 4 | rates :control, :audio 5 | inputs lo: 0, hi: 1, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/t_windex.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TWindex < Gen 4 | rates :control, :audio 5 | inputs input: nil, array: nil, normalize: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/ti_rand.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TIRand < Gen 4 | rates :control, :audio 5 | inputs lo: 0, hi: 127, trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/timer.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Timer < Gen 4 | rates :control, :audio 5 | inputs trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/toggle_ff.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ToggleFF < Gen 4 | rates :control, :audio 5 | inputs trig: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/trig.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Trig < Gen 4 | rates :control, :audio 5 | inputs input: 0, dur: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/trig1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Trig1 < Gen 4 | rates :control, :audio 5 | inputs input: 0, dur: 0.1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/trig_control.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TrigControl < Gen 4 | rates :control, :scalar 5 | inputs values: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/two_pole.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TwoPole < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, radius: 0.8 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/two_zero.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class TwoZero < Gen 4 | rates :control, :audio 5 | inputs input: 0, freq: 440, radius: 0.8 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/unary_op_ugen.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class UnaryOpUgen < Operation 4 | attributes operation: nil 5 | inputs operand: nil 6 | 7 | class << self 8 | def apply(operation, operand) 9 | UnaryOpUgen.new(operation, operand, rate: operand.rate) 10 | end 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/scruby/ugen/v_disk_in.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class VDiskIn < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs bufnum: nil, playback_rate: 1, loop: 0, send_id: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/v_osc.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class VOsc < Gen 4 | rates :control, :audio 5 | inputs bufpos: nil, freq: 440, phase: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/v_osc3.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class VOsc3 < Gen 4 | rates :control, :audio 5 | inputs bufpos: nil, freq1: 110, freq2: 220, freq3: 440 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/var_lag.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class VarLag < Gen 4 | rates :control, :audio 5 | inputs input: 0, time: 0.1, curvature: 0, warp: 5, start: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/var_saw.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class VarSaw < Gen 4 | rates :control, :audio 5 | inputs freq: 440, iphase: 0, width: 0.5 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/vibrato.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Vibrato < Gen 4 | rates :control, :audio 5 | inputs freq: 440, playback_rate: 6, depth: 0.02, delay: 0, onset: 0, 6 | rate_variation: 0.04, depth_variation: 0.1, iphase: 0, 7 | trig: 0 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/scruby/ugen/warp1.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Warp1 < Gen 4 | rates :audio 5 | attributes channel_count: 1 6 | 7 | inputs bufnum: 0, pointer: 0, freq_scale: 1, window_size: 0.2, 8 | envbufnum: -1, overlaps: 8, window_rand_ratio: 0, interp: 1 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/scruby/ugen/white_noise.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class WhiteNoise < Gen 4 | rates :control, :audio 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/scruby/ugen/wrap.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class Wrap < Gen 4 | rates :control, :audio, :scalar 5 | inputs input: 0, lo: 0, hi: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/wrap_index.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class WrapIndex < Gen 4 | rates :control, :audio 5 | inputs bufnum: nil, input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/x_fade2.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class XFade2 < Gen 4 | rates :control, :audio 5 | inputs in_a: nil, in_b: 0, pan: 0, level: 1 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/x_line.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class XLine < Gen 4 | rates :control, :audio 5 | inputs start: 1, finish: 2, dur: 1, done_action: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/x_out.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class XOut < AbstractOut 4 | rates :control, :audio 5 | inputs bus: nil, xfade: nil, channels_array: nil 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen/zero_crossing.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Ugen 3 | class ZeroCrossing < Gen 4 | rates :control, :audio 5 | inputs input: 0 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/scruby/ugen_graph/constant.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class UgenGraph 3 | class Constant 4 | include Equatable 5 | include PrettyInspectable 6 | 7 | attr_reader :value 8 | 9 | def initialize(value) 10 | @value = value.to_f 11 | end 12 | 13 | def input_specs(graph) 14 | [ -1, graph.constants.index(self) ] 15 | end 16 | 17 | def inspect 18 | super(value: value) 19 | end 20 | 21 | def print_name 22 | value.to_s 23 | end 24 | 25 | def inputs 26 | [] 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/scruby/ugen_graph/control.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class UgenGraph 3 | class ControlName 4 | include Equatable 5 | include PrettyInspectable 6 | include Encode 7 | 8 | RATES = %i(scalar control trigger) 9 | 10 | attr_reader :rate, :default, :name 11 | 12 | def initialize(default, rate = :control, name = nil) 13 | RATES.include?(rate) || 14 | raise(ArgumentError, 15 | "rate `#{rate}` is not one of `#{RATES}`") 16 | 17 | @rate = rate 18 | @default = default || 0 19 | @name = name 20 | end 21 | 22 | def name=(name) 23 | @name = name.to_sym 24 | end 25 | 26 | def encode_name(graph) 27 | [ encode_string(name), encode_int32(index(graph)) ] 28 | end 29 | 30 | def input_specs(graph) 31 | [ 0, index(graph) ] 32 | end 33 | 34 | def inspect 35 | super(name: name, default: default, rate: rate) 36 | end 37 | 38 | private 39 | 40 | def index(graph) 41 | graph.control_index(self) 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/scruby/ugen_graph/control_name.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | class UgenGraph 3 | class ControlName 4 | include Equatable 5 | include PrettyInspectable 6 | include Encode 7 | 8 | attr_reader :default, :rate, :name 9 | 10 | def initialize(default, rate = :control, name = nil) 11 | rates.include?(rate) || 12 | raise(ArgumentError, 13 | "rate `#{rate}` is not one of `#{rates}`") 14 | 15 | @rate = rate 16 | @default = default || 0 17 | self.name = name 18 | end 19 | 20 | def name=(name) 21 | @name = name&.to_sym 22 | end 23 | 24 | def rates 25 | Ugen::Control.rates 26 | end 27 | 28 | def rate_index 29 | E_RATES.index(rate) 30 | end 31 | 32 | def encode_name(graph) 33 | [ encode_string(name), encode_int32(index(graph)) ] 34 | end 35 | 36 | def input_specs(graph) 37 | [ 0, index(graph) ] 38 | end 39 | 40 | def inspect 41 | super(name: name, default: default, rate: rate) 42 | end 43 | 44 | private 45 | 46 | def index(graph) 47 | graph.control_index(self) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/scruby/utils/positional_keyword_args.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | module Utils 3 | module PositionalKeywordArgs 4 | private 5 | 6 | def positional_keyword_args(defaults, *args, **kwargs) 7 | if args.size > defaults.size 8 | raise ArgumentError, %W[ 9 | (wrong number of arguments (given #{args.size}, 10 | expected less than #{defaults.size})) 11 | ].join(" ") 12 | end 13 | 14 | extra_keys = kwargs.keys - defaults.keys 15 | if extra_keys.any? 16 | sust = "keyword#{ extra_keys.size > 1 ? 's' : '' }" 17 | keys = extra_keys.map(&:inspect).join(", ") 18 | raise ArgumentError, "(unknown #{sust}: #{keys})" 19 | end 20 | 21 | names = defaults.keys 22 | positional_args = names[0...args.size].zip(args) 23 | 24 | (defaults.to_a + positional_args + kwargs.to_a).to_h 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/scruby/version.rb: -------------------------------------------------------------------------------- 1 | module Scruby 2 | VERSION = "0.3" 3 | end 4 | -------------------------------------------------------------------------------- /scruby.gemspec: -------------------------------------------------------------------------------- 1 | lib = File.expand_path("lib", __dir__) 2 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 3 | require "scruby/version" 4 | 5 | Gem::Specification.new do |spec| 6 | spec.name = "scruby" 7 | spec.version = Scruby::VERSION 8 | spec.authors = [ "Macario" ] 9 | spec.email = [ "maca@aelita.io" ] 10 | spec.summary = "SuperCollider client for Ruby" 11 | spec.description = "SuperCollider client for Ruby" 12 | spec.homepage = "http://github.com/maca/scruby" 13 | spec.license = "MIT" 14 | 15 | spec.metadata["homepage_uri"] = spec.homepage 16 | spec.metadata["source_code_uri"] = spec.homepage 17 | 18 | # Specify which files should be added to the gem when it is 19 | # released. The `git ls-files -z` loads the files in the RubyGem 20 | # that have been added into git. 21 | spec.files = Dir.chdir(File.expand_path(__dir__)) do 22 | `git ls-files -z`.split("\x0") 23 | .reject { |f| f.match(%r{^(test|spec|features)/}) } 24 | end 25 | 26 | spec.bindir = "exe" 27 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 28 | spec.require_paths = [ "lib" ] 29 | 30 | spec.add_development_dependency "bundler" 31 | spec.add_development_dependency "byebug" 32 | spec.add_development_dependency "irb" 33 | spec.add_development_dependency "rspec" 34 | spec.add_development_dependency "rantly" 35 | spec.add_development_dependency "zeitwerk" 36 | spec.add_development_dependency "listen" 37 | spec.add_development_dependency "rubocop" 38 | spec.add_development_dependency "rdoc" 39 | spec.add_development_dependency "yard" 40 | 41 | spec.add_dependency "ruby-osc", "~> 1.0" 42 | spec.add_dependency "tty-which", "~> 0.4" 43 | spec.add_dependency "concurrent-ruby", "~> 1.1" 44 | spec.add_dependency "concurrent-ruby-edge", "~> 0.6.0" 45 | spec.add_dependency "facets", "~> 3.1" 46 | end 47 | -------------------------------------------------------------------------------- /spec/attributes_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Attributes do 2 | let(:extended_class) do 3 | Class.new do 4 | extend Attributes 5 | 6 | attributes do 7 | attribute :foo 8 | attribute :bar, nil 9 | attribute :baz, false 10 | attribute :qux, :hello 11 | end 12 | end 13 | end 14 | 15 | describe "initialize with no attributes" do 16 | subject(:instance) { extended_class.new } 17 | it { expect(instance.foo).to be nil } 18 | it { expect(instance.bar).to be nil } 19 | it { expect(instance.baz).to be false } 20 | it { expect(instance.qux).to be :hello } 21 | end 22 | 23 | describe "override attribute with falsy" do 24 | subject(:instance) do 25 | extended_class.new( 26 | foo: false, 27 | bar: false, 28 | baz: false, 29 | qux: false 30 | ) 31 | end 32 | 33 | it { expect(instance.foo).to be false } 34 | it { expect(instance.bar).to be false } 35 | it { expect(instance.baz).to be false } 36 | it { expect(instance.qux).to be false } 37 | end 38 | 39 | describe "initialize with unknown attribute" do 40 | it { expect { extended_class.new(foobar: :hi) } 41 | .to raise_exception(ArgumentError) } 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /spec/equatable_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Equatable do 2 | include Scruby 3 | 4 | let(:equatable_class) do 5 | Class.new do 6 | include Equatable 7 | 8 | def initialize(value) 9 | @value = value 10 | end 11 | end 12 | end 13 | 14 | describe "equality" do 15 | let(:value) { 440 } 16 | 17 | it { expect(equatable_class.new(value)) 18 | .to eq equatable_class.new(value) } 19 | 20 | it { expect(equatable_class.new(value)) 21 | .not_to eq equatable_class.new(value + 1) } 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/graph/decoder_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Scruby::Graph::Decoder do 2 | context "groups and synths" do 3 | # NODE TREE Group 0 4 | # 1 group 5 | # 1018 group 6 | # 1020 sin 7 | # freq: 300 amp: 0 8 | # 1019 sin 9 | # freq: 300 amp: 0 10 | # 1015 group 11 | # 1017 sin 12 | # freq: 300 amp: 0 13 | # 1016 sin 14 | # freq: 300 amp: 0 15 | let(:msg) do 16 | [ 1, 17 | 0, 1, 18 | 1, 2, 19 | 1018, 2, 20 | 1020, -1, "sin", 2, "freq", 300, "amp", 0, 21 | 1019, -1, "sin", 2, "freq", 300, "amp", 0, 22 | 1015, 2, 23 | 1017, -1, "sin", 2, "freq", 300, "amp", 0, 24 | 1016, -1, "sin", 2, "freq", 300, "amp", 0 25 | ] 26 | end 27 | 28 | 29 | subject(:nodes) { described_class.decode(msg) } 30 | 31 | 32 | shared_examples_for "is node" do |id| 33 | it { expect(node.id).to be id } 34 | it { expect(node.graph).to be nodes } 35 | it { expect(node.parent).to be parent } 36 | end 37 | 38 | 39 | it_behaves_like "is node", 0 do 40 | let(:parent) { nil } 41 | subject(:node) { nodes.first } 42 | end 43 | 44 | it_behaves_like "is node", 1 do 45 | let(:parent) { nodes.first } 46 | subject(:node) { nodes[1] } 47 | end 48 | 49 | it_behaves_like "is node", 1018 do 50 | let(:parent) { nodes[1] } 51 | subject(:node) { nodes[1018] } 52 | end 53 | 54 | it_behaves_like "is node", 1020 do 55 | let(:parent) { nodes[1018] } 56 | subject(:node) { nodes[1020] } 57 | 58 | it { expect(node.obj.name).to eq "sin" } 59 | it { expect(node.obj.params).to eq(freq: 300, amp: 0) } 60 | end 61 | 62 | it_behaves_like "is node", 1019 do 63 | let(:parent) { nodes[1018] } 64 | subject(:node) { nodes[1019] } 65 | 66 | it { expect(node.obj.name).to eq "sin" } 67 | it { expect(node.obj.params).to eq(freq: 300, amp: 0) } 68 | end 69 | 70 | it_behaves_like "is node", 1015 do 71 | let(:parent) { nodes[1] } 72 | subject(:node) { nodes[1015] } 73 | end 74 | 75 | it_behaves_like "is node", 1017 do 76 | let(:parent) { nodes[1015] } 77 | let(:node) { nodes[1017] } 78 | 79 | it { expect(node.obj.name).to eq "sin" } 80 | it { expect(node.obj.params).to eq(freq: 300, amp: 0) } 81 | end 82 | 83 | it_behaves_like "is node", 1016 do 84 | let(:parent) { nodes[1015] } 85 | let(:node) { nodes[1016] } 86 | 87 | it { expect(node.obj.name).to eq "sin" } 88 | it { expect(node.obj.params).to eq(freq: 300, amp: 0) } 89 | end 90 | end 91 | end 92 | -------------------------------------------------------------------------------- /spec/graph/node_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Scruby::Graph::Node do 2 | subject(:node) do 3 | described_class.new(:node_one, a: 1) 4 | end 5 | 6 | describe "graph" do 7 | let(:graph) { instance_double("Graph") } 8 | let(:children) { instance_double("Array") } 9 | 10 | before do 11 | node.graph = graph 12 | allow(graph).to receive(:children_for).with(node) { children } 13 | end 14 | 15 | it { expect(node.children).to eq children } 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/graph_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Scruby::Graph do 2 | let(:zero) { instance_double("Graph::Node", id: 0, parent: nil) } 3 | let(:one) { instance_double("Graph::Node", id: 1, parent: zero) } 4 | let(:two) { instance_double("Graph::Node", id: 2, parent: zero) } 5 | let(:three) { instance_double("Graph::Node", id: 3, parent: one) } 6 | let(:four) { instance_double("Graph::Node", id: 4, parent: one) } 7 | 8 | let(:nodes) do 9 | [ zero, one, two, three, four ] 10 | end 11 | 12 | before do 13 | nodes.each { |node| allow(node).to receive(:graph=) } 14 | end 15 | 16 | subject(:graph) { Graph.new(nodes) } 17 | 18 | describe "get node" do 19 | it { expect(graph[0]).to eq zero } 20 | it { expect(graph[1]).to eq one } 21 | it { expect(graph[2]).to eq two } 22 | it { expect(graph[3]).to eq three } 23 | it { expect(graph[4]).to eq four } 24 | end 25 | 26 | describe "children for node" do 27 | it { expect(graph.children_for(nil)).to eq [ zero ] } 28 | it { expect(graph.children_for(zero)).to eq [ one, two ] } 29 | it { expect(graph.children_for(one)).to eq [ three, four ] } 30 | it { expect(graph.children_for(two)).to eq [ ] } 31 | end 32 | 33 | describe "add node" do 34 | let(:five) { instance_double("Graph::Node", id: 5, parent: one) } 35 | 36 | before do 37 | expect(five).to receive(:graph=).with(graph) 38 | graph.add(five) 39 | end 40 | 41 | it { expect(graph[5]).to eq five } 42 | it { expect(graph.children_for(one)).to eq [ three, four, five ] } 43 | end 44 | 45 | describe "enumerable methods" do 46 | it { expect(graph.to_a).to eq nodes } 47 | it { expect(graph.each.to_a).to eq nodes } 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /spec/in_out_spec.rb: -------------------------------------------------------------------------------- 1 | # include Scruby 2 | # include Ugens 3 | 4 | # class SinOsc < Ugen 5 | # # not interested in muladd 6 | # def self.ar(freq = 440.0, phase = 0.0) 7 | # new :audio, freq, phase 8 | # end 9 | # end 10 | 11 | # class MockUgen < Ugen 12 | # class << self; public :new; end 13 | # end 14 | 15 | # RSpec.describe In do 16 | # before do 17 | # @sdef = double("ugen", children: []) 18 | # expect(Ugen).to receive(:synthdef).at_least(:once).and_return(@sdef) 19 | 20 | # @proxy = double("output proxy") 21 | # @proxies = (1..10).map{ @proxy } 22 | # allow(OutputProxy).to receive(:new).and_return(@proxy) 23 | 24 | # @ar = In.ar 3 25 | # end 26 | 27 | # it "respond to #kr and #ar" do 28 | # expect(In).to respond_to(:kr) 29 | # expect(In).to respond_to(:ar) 30 | # end 31 | 32 | # it "should spec #ar" do 33 | # expect(@ar).to be_instance_of(DelegatorArray) 34 | # expect(@ar.size).to eq(1) 35 | # expect(@ar.first).to eq(@proxy) 36 | # end 37 | 38 | # it "should have bus as input" do 39 | # expect(@sdef.children.first.inputs).to eq([ 3 ]) 40 | # end 41 | 42 | # it "should have ten channels" do 43 | # expect(In.ar(0, 10)).to eq(@proxies) 44 | # end 45 | 46 | # it "should describe passing arrays to initialize" 47 | 48 | # end 49 | 50 | 51 | # RSpec.describe Out do 52 | # shared_examples_for "Out" do 53 | # before do 54 | # @sdef = double "sdef", children: [], constants: [ 400, 0 ] 55 | # expect(Ugen).to receive(:synthdef).at_least(:once).and_return @sdef 56 | # end 57 | 58 | # it "should accept one ugen" do 59 | # @ugen1 = MockUgen.new :audio 60 | # expect(@class.kr(1, @ugen1)).to eq(0.0) 61 | # expect(@sdef.children.size).to eq(2) 62 | 63 | # out = @sdef.children.last 64 | # expect(out.rate).to eq(:control) 65 | # expect(out.inputs).to eq([ 1, @ugen1 ]) 66 | # expect(out.channels).to eq([]) 67 | # end 68 | 69 | # it "should accept several inputs from array" do 70 | # @ugen1 = MockUgen.new :audio 71 | # @ugen2 = MockUgen.new :audio 72 | # @ugen3 = MockUgen.new :audio 73 | 74 | # @class.kr 1, [ @ugen1, @ugen2, @ugen3 ] 75 | # expect(@sdef.children.size).to eq(4) 76 | 77 | # out = @sdef.children.last 78 | # expect(out.inputs).to eq([ 1, @ugen1, @ugen2, @ugen3 ]) 79 | # end 80 | 81 | # it "should accept several inputs" do 82 | # @ugen1 = MockUgen.new :audio 83 | # @ugen2 = MockUgen.new :audio 84 | # @ugen3 = MockUgen.new :audio 85 | 86 | # @class.kr 1, @ugen1, @ugen2, @ugen3 87 | # expect(@sdef.children.size).to eq(4) 88 | 89 | # out = @sdef.children.last 90 | # expect(out.inputs).to eq([ 1, @ugen1, @ugen2, @ugen3 ]) 91 | # end 92 | 93 | # it "should validate rate" 94 | # it "should substitute zero with silence" 95 | # it "should spec passing array on init" 96 | # end 97 | 98 | # describe Out do 99 | # before do 100 | # @class = Out 101 | # end 102 | # it_should_behave_like "Out" 103 | # end 104 | 105 | # describe ReplaceOut do 106 | # before do 107 | # @class = Out 108 | # end 109 | # it_should_behave_like "Out" 110 | # end 111 | # end 112 | -------------------------------------------------------------------------------- /spec/integration/operation_graph_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph do 2 | let(:server) { Server.new } 3 | 4 | before do 5 | allow(server).to receive(:send_msg) 6 | end 7 | 8 | describe "graph with float mult" do 9 | let(:graph) { UgenGraph.new(Out.ar(0, SinOsc.ar * 0.5), "mult") } 10 | 11 | it { expect(graph.nodes.map(&:name)) 12 | .to eq %w(SinOsc BinaryOpUGen Out) } 13 | 14 | it { expect(graph.constants.map(&:value)).to eq [ 440, 0, 0.5 ] } 15 | 16 | let(:expected) do 17 | [ 83, 67, 103, 102, 0, 0, 0, 2, 0, 1, 4, 109, 117, 108, 116, 0, 18 | 0, 0, 3, 67, -36, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 19 | 0, 0, 0, 0, 0, 0, 0, 3, 6, 83, 105, 110, 79, 115, 99, 2, 0, 0, 20 | 0, 2, 0, 0, 0, 1, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, 21 | -1, -1, 0, 0, 0, 1, 2, 12, 66, 105, 110, 97, 114, 121, 79, 22 | 112, 85, 71, 101, 110, 2, 0, 0, 0, 2, 0, 0, 0, 1, 0, 2, 0, 0, 23 | 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 2, 2, 3, 79, 117, 24 | 116, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 25 | 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ].pack("C*") 26 | end 27 | 28 | it "encodes graph" do 29 | expect(graph).to encode_as(expected) 30 | end 31 | 32 | it "sends graph" do 33 | expect(graph.send_to(server)).to eq(graph) 34 | expect(graph.send_to(server)).to eq(graph) 35 | end 36 | end 37 | 38 | 39 | describe "graph with sum" do 40 | let(:server) { Server.new } 41 | let(:graph) { UgenGraph.new(Out.ar(0, SinOsc.ar + Saw.ar), "sum") } 42 | 43 | it { expect(graph.nodes.map(&:name)) 44 | .to eq %w(SinOsc Saw BinaryOpUGen Out) } 45 | 46 | it { expect(graph.constants.map(&:value)).to eq [ 440, 0 ] } 47 | 48 | let(:expected) do 49 | [ 83, 67, 103, 102, 0, 0, 0, 2, 0, 1, 3, 115, 117, 109, 0, 0, 0, 50 | 2, 67, -36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51 | 4, 6, 83, 105, 110, 79, 115, 99, 2, 0, 0, 0, 2, 0, 0, 0, 1, 0, 52 | 0, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 1, 2, 53 | 3, 83, 97, 119, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1, -1, -1, 54 | -1, 0, 0, 0, 0, 2, 12, 66, 105, 110, 97, 114, 121, 79, 112, 55 | 85, 71, 101, 110, 2, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 56 | 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 3, 79, 117, 116, 2, 0, 57 | 0, 0, 2, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 1, 0, 0, 58 | 0, 2, 0, 0, 0, 0, 0, 0 ].pack("C*") 59 | end 60 | 61 | it "encodes graph" do 62 | expect(graph).to encode_as(expected) 63 | end 64 | 65 | it "sends graph" do 66 | expect(graph.send_to(server)).to eq(graph) 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /spec/server/nodes_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Server::Nodes do 2 | let(:server) { instance_double("Server") } 3 | 4 | subject(:node) { described_class.new(server) } 5 | end 6 | -------------------------------------------------------------------------------- /spec/server/options_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Scruby::Server::Options do 2 | subject(:options) { described_class.new } 3 | 4 | describe "some defaults" do 5 | it { expect(options.address).to eq "127.0.0.1" } 6 | it { expect(options.port).to be 57_110 } 7 | it { expect(options.protocol).to be :udp } 8 | it { expect(options.max_logins).to be 32 } 9 | it { expect(options.num_input_bus_channels).to be 2 } 10 | it { expect(options.num_output_bus_channels).to be 2 } 11 | end 12 | 13 | describe "flags" do 14 | let(:flags) do 15 | %w( 16 | -B 127.0.0.1 17 | -u 57110 18 | -a 1024 19 | -c 16384 20 | -i 2 21 | -o 2 22 | -b 1024 23 | -n 1024 24 | -d 1024 25 | -z 64 26 | -m 8192 27 | -r 64 28 | -w 64 29 | -V 0 30 | -R 0 31 | -l 32 32 | ).join(" ") 33 | end 34 | 35 | it { expect(options.flags).to eq flags } 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /spec/server_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Server do 2 | it "should have a lot more tests" 3 | 4 | describe "sends graph" do 5 | let(:graph) { instance_double("UgenGraph", encode: "encoded-graph") } 6 | let(:blob) { OSC::Blob.new("encoded-graph") } 7 | let(:server) { Server.new } 8 | 9 | context "no completion message is provided" do 10 | before do 11 | allow(server).to receive(:send_bundle) 12 | server.send_graph(graph) 13 | end 14 | 15 | let(:message) { OSC::Message.new("/d_recv", blob, 0) } 16 | 17 | it { expect(server).to have_received(:send_bundle).with(message) } 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | require "byebug" 3 | require "scruby" 4 | require "rantly" 5 | require "rantly/rspec_extensions" 6 | require "rantly/shrinks" 7 | 8 | 9 | Dir.glob(File.join(__dir__, "support/**/*.rb")).each { |f| load f } 10 | 11 | 12 | include Scruby::Helpers 13 | 14 | 15 | RSpec.configure do |config| 16 | # Enable flags like --only-failures and --next-failure 17 | config.example_status_persistence_file_path = ".rspec_status" 18 | 19 | # Disable RSpec exposing methods globally on `Module` and `main` 20 | config.disable_monkey_patching! 21 | 22 | config.expect_with :rspec do |c| 23 | c.syntax = :expect 24 | c.max_formatted_output_length = 1000 25 | end 26 | end 27 | 28 | Thread.abort_on_exception = true 29 | -------------------------------------------------------------------------------- /spec/support/buffer_examples.rb: -------------------------------------------------------------------------------- 1 | RSpec.shared_context "query buffer info" do 2 | let!(:info_response) do 3 | Concurrent::Promises.fulfilled_future(info_msg) 4 | end 5 | 6 | let!(:info_msg) do 7 | instance_double("OSC::Message", address: "/b_info", args: response) 8 | end 9 | 10 | before do 11 | allow(server).to receive(:receive).with("/b_info") { |&block| 12 | next info_response if block.call(info_msg) 13 | } 14 | end 15 | end 16 | 17 | 18 | RSpec.shared_context "sends allocation message" do 19 | let!(:action) { message.first } 20 | 21 | let!(:done_response) do 22 | Concurrent::Promises.fulfilled_future(done_msg) 23 | end 24 | 25 | let!(:done_msg) do 26 | instance_double("OSC::Message", 27 | to_a: [ "/done", action, buffer_id ]) 28 | end 29 | 30 | before do 31 | allow(server).to receive(:receive).with(no_args) { |&block| 32 | next done_response if block.call(done_msg) 33 | } 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /spec/support/done_action_examples.rb: -------------------------------------------------------------------------------- 1 | RSpec.shared_examples_for "has done action" do 2 | let(:ugen) { described_class.kr(done_action: :free) } 3 | it { expect(ugen.done_action).to be 2 } 4 | end 5 | -------------------------------------------------------------------------------- /spec/support/encode_matcher.rb: -------------------------------------------------------------------------------- 1 | RSpec::Matchers.define :encode_as do |expected| 2 | match do |actual| 3 | actual.encode == expected 4 | end 5 | 6 | failure_message do |actual| 7 | <<~MSG 8 | 9 | expected: #{diff(expected, actual.encode)} 10 | 11 | got: #{diff(actual.encode, expected)} 12 | MSG 13 | end 14 | 15 | def diff(str_a, str_b) 16 | str_a.each_char.zip(str_b.each_char).map do |a, b| 17 | str = a.inspect.gsub(/^"|"$/, "") 18 | a == b ? str : "\e[33m#{str}\e[31m" 19 | end.join 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/support/equality_examples.rb: -------------------------------------------------------------------------------- 1 | RSpec.shared_examples_for "is equatable" do 2 | it { expect(described_class.ancestors) 3 | .to include(Scruby::Equatable) } 4 | end 5 | -------------------------------------------------------------------------------- /spec/support/graph_node_examples.rb: -------------------------------------------------------------------------------- 1 | RSpec.shared_context "node with graph" do 2 | let(:graph) { instance_double("Scruby::UgenGraph") } 3 | 4 | before do 5 | allow(graph).to receive(:add) 6 | allow(graph).to receive(:add_constant) 7 | end 8 | end 9 | 10 | RSpec.shared_context "node with graph constants" do 11 | before do 12 | allow(graph).to receive(:constants) { constants } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/synth_def_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Scruby::SynthDef do 2 | describe "building a synth def" do 3 | context "synth def with no controls" do 4 | subject(:synth_def) do 5 | SynthDef.new(:simple) do 6 | Out.ar(0, SinOsc.ar(400) * 0.5) 7 | end 8 | end 9 | 10 | let(:graph) do 11 | UgenGraph.new(Out.ar(0, SinOsc.ar(400) * 0.5), :simple) 12 | end 13 | 14 | it { expect(synth_def.graph).to eq graph } 15 | end 16 | 17 | context "synth def with controls" do 18 | subject(:synth_def) do 19 | SynthDef.new(:simple) do |freq, amp = 0.5, phase| 20 | Out.ar(0, SinOsc.ar(freq, phase) * amp) 21 | end 22 | end 23 | 24 | let(:graph) do 25 | UgenGraph.new( 26 | Out.ar(0, SinOsc.ar(:freq, :phase) * :amp), :simple, 27 | freq: nil, amp: 0.5, phase: nil 28 | ) 29 | end 30 | 31 | it { expect(synth_def.graph).to eq graph } 32 | end 33 | 34 | context "synth def with scalar rate control" do 35 | subject(:synth_def) do 36 | SynthDef.new(:simple) do |freq, amp = scalar(0.5), phase| 37 | Out.ar(0, SinOsc.ar(freq, phase) * amp) 38 | end 39 | end 40 | 41 | let(:graph) do 42 | UgenGraph.new( 43 | Out.ar(0, SinOsc.ar(:freq, :phase) * :amp), :simple, 44 | freq: nil, amp: scalar(0.5), phase: nil 45 | ) 46 | end 47 | 48 | it { expect(synth_def.graph).to eq graph } 49 | end 50 | 51 | context "block does not return a ugen" do 52 | subject(:synth_def) do 53 | SynthDef.new(:simple) { } 54 | end 55 | 56 | it { expect{ synth_def }.to raise_exception(TypeError) } 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /spec/synth_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Synth do 2 | let(:server) { instance_double("Server", next_node_id: 16) } 3 | 4 | it_behaves_like "performs node actions" do 5 | let(:node) { Synth.new(server) } 6 | end 7 | 8 | before do 9 | allow(server).to receive(:node).with(1) do 10 | instance_double("Node", server: server, id: 1) 11 | end 12 | end 13 | 14 | describe "initialize with position" do 15 | let(:a_group) do 16 | instance_double("Group", id: 5555, server: server) 17 | end 18 | 19 | let(:a_node) do 20 | instance_double("Node", id: 2222, server: server, group: a_group) 21 | end 22 | 23 | shared_examples_for "initializes synth" do 24 | let(:node_node) { instance_double("Graph::Node") } 25 | let(:nodes) { instance_double("Nodes") } 26 | 27 | before do 28 | allow(nodes).to receive(:node).with(16) { node_node } 29 | allow(server).to receive(:nodes) { nodes } 30 | end 31 | 32 | it { expect(node).to be_a Synth } 33 | it { expect(node.server).to be server } 34 | it { expect(node.node).to eq node_node } 35 | end 36 | 37 | describe "head" do 38 | it_behaves_like "sent message to server" do 39 | subject!(:node) { Synth.head(a_group, :test, a: 1) } 40 | let(:msg) do 41 | [ "/s_new", :test, 16, 0, a_group.id, :a, 1 ] 42 | end 43 | 44 | it { expect(node.id).to be 16 } 45 | it_behaves_like "initializes synth" 46 | end 47 | end 48 | 49 | describe "tail" do 50 | it_behaves_like "sent message to server" do 51 | subject!(:node) { Synth.tail(a_group, :test, a: 1) } 52 | let(:msg) do 53 | [ "/s_new", :test, 16, 1, a_group.id, :a, 1 ] 54 | end 55 | 56 | it { expect(node.id).to be 16 } 57 | it_behaves_like "initializes synth" 58 | end 59 | end 60 | 61 | describe "before" do 62 | it_behaves_like "sent message to server" do 63 | subject!(:node) { Synth.before(a_node, :test, a: 1) } 64 | let(:msg) do 65 | [ "/s_new", :test, 16, 2, a_node.id, :a, 1 ] 66 | end 67 | 68 | it { expect(node.id).to be 16 } 69 | it_behaves_like "initializes synth" 70 | end 71 | end 72 | 73 | describe "after" do 74 | it_behaves_like "sent message to server" do 75 | subject!(:node) { Synth.after(a_node, :test, a: 1) } 76 | let(:msg) do 77 | [ "/s_new", :test, 16, 3, a_node.id, :a, 1 ] 78 | end 79 | 80 | it { expect(node.id).to be 16 } 81 | it_behaves_like "initializes synth" 82 | end 83 | end 84 | 85 | describe "replace" do 86 | it_behaves_like "sent message to server" do 87 | subject!(:node) { Synth.replace(a_node, :test, a: 1) } 88 | let(:msg) do 89 | [ "/s_new", :test, 16, 4, a_node.id, :a, 1 ] 90 | end 91 | 92 | it { expect(node.id).to be 16 } 93 | it_behaves_like "initializes synth" 94 | end 95 | end 96 | 97 | describe "create" do 98 | it_behaves_like "sent message to server" do 99 | subject!(:node) { Synth.create(:test, server, a: 1) } 100 | let(:msg) do 101 | [ "/s_new", :test, 16, 0, 1, :a, 1 ] 102 | end 103 | 104 | it { expect(node.id).to be 16 } 105 | it_behaves_like "initializes synth" 106 | end 107 | end 108 | end 109 | end 110 | -------------------------------------------------------------------------------- /spec/ugen/base_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::Base do 2 | describe "multichannel" do 3 | subject(:subclass) do 4 | Class.new(Ugen::Base) do 5 | rates :audio 6 | inputs ins: nil 7 | attributes colors: nil 8 | end 9 | end 10 | 11 | describe "to multichannel" do 12 | let(:instance) { subclass.new } 13 | 14 | it { expect(instance.channels(2)) 15 | .to eq MultiChannel.new([ instance ] * 2)} 16 | 17 | it { expect(instance.channels(3)) 18 | .to eq MultiChannel.new([ instance ] * 3)} 19 | end 20 | 21 | context "passing multichannel instance" do 22 | let(:instance) do 23 | subclass.new(ins: MultiChannel.new([subclass.new, subclass.new])) 24 | end 25 | 26 | it { expect(instance.ins).to eq [ subclass.new, subclass.new ] } 27 | end 28 | 29 | context "passing single channel multichannel instance" do 30 | let(:instance) do 31 | subclass.new(ins: MultiChannel.new([subclass.new])) 32 | end 33 | 34 | it { expect(instance.ins).to eq subclass.new } 35 | end 36 | 37 | context "passing single channel multichannel instance as attr" do 38 | let(:instance) do 39 | subclass.new(colors: MultiChannel.new([subclass.new])) 40 | end 41 | 42 | it { expect(instance.colors).to eq MultiChannel.new([subclass.new]) } 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /spec/ugen/demand_env_gen_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::DemandEnvGen do 2 | it_behaves_like "has done action" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen/env_gen_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::EnvGen do 2 | it_behaves_like "has done action" 3 | 4 | describe "EnvGen as graph node" do 5 | context "for default Env with defaults" do 6 | let(:ugen) { EnvGen.kr(Env.new) } 7 | 8 | include_context "node with graph" 9 | include_context "node with graph constants" do 10 | let(:constants) do 11 | [ UgenGraph::Constant.new(1), 12 | UgenGraph::Constant.new(0), 13 | UgenGraph::Constant.new(2), 14 | UgenGraph::Constant.new(-99) 15 | ] 16 | end 17 | end 18 | 19 | let(:expected) do 20 | [ 21 | 6, 69, 110, 118, 71, 101, 110, 1, 0, 0, 0, 17, 0, 0, 0, 1, 22 | 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 23 | 0, -1, -1, -1, -1, 0, 0, 0, 1, -1, -1, -1, -1, 0, 0, 0, 0, 24 | -1, -1, -1, -1, 0, 0, 0, 1, -1, -1, -1, -1, 0, 0, 0, 1, -1, 25 | -1, -1, -1, 0, 0, 0, 2, -1, -1, -1, -1, 0, 0, 0, 3, -1, -1, 26 | -1, -1, 0, 0, 0, 3, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, 27 | -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 28 | 0, 0, 0, 1, -1, -1, -1, -1, 0, 0, 0, 1, -1, -1, -1, -1, 0, 29 | 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 30 | 0, 1, 1 31 | ].pack("C*") 32 | end 33 | 34 | subject(:node) { UgenGraph::UgenNode.build(graph, ugen) } 35 | 36 | it { expect(node).to encode_as(expected) } 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /spec/ugen/graph/constant_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph::Constant do 2 | it_behaves_like "is equatable" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen/graph/control_name_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph::ControlName do 2 | include Scruby 3 | 4 | describe "building a graph" do 5 | let(:subject) { described_class.new(:a_control, 1) } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/ugen/graph/control_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph::ControlName do 2 | include Scruby 3 | 4 | describe "building a graph" do 5 | let(:subject) { described_class.new(:a_control, 1) } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/ugen/line_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::Line do 2 | it_behaves_like "has done action" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen/linen_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::Linen do 2 | it_behaves_like "has done action" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen/multi_channel_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::MultiChannel do 2 | it "compares max size" do 3 | property_of { [ range(1, 10), range(1, 10) ] }.check do |n1, n2| 4 | size = MultiChannel.new([1] * n1).max_size([1] * n2) 5 | expect(size).to eq([n1, n2].max) 6 | end 7 | end 8 | 9 | describe "enumerable methods" do 10 | it "converst to array" do 11 | property_of { range(1, 10).times.to_a }.check do |a| 12 | expect(MultiChannel.new(a).to_a).to eq a 13 | end 14 | end 15 | 16 | it "returns size" do 17 | property_of { range(1, 10).times.to_a }.check do |a| 18 | expect(MultiChannel.new(a).size).to eq a.size 19 | end 20 | end 21 | 22 | it "returns enumerator" do 23 | property_of { range(1, 10).times.to_a }.check do |a| 24 | expect(MultiChannel.new(a).each.to_a).to eq a.each.to_a 25 | end 26 | end 27 | 28 | it "maps" do 29 | property_of { range(1, 10).times.to_a }.check do |a| 30 | expect(MultiChannel.new(a).map(&:to_s)).to eq a.map(&:to_s) 31 | end 32 | end 33 | 34 | describe "zip" do 35 | it "it cycles first" do 36 | property_of { [ range(1, 10).times.to_a, 37 | range(1, 10).times.to_a ] } 38 | .check do |a1, a2| 39 | 40 | size = [a1, a2].max_by(&:size).size 41 | zipped = MultiChannel.new(a1).zip(a2) 42 | expect(zipped.map(&:first)).to eq(a1.cycle.take(size)) 43 | end 44 | end 45 | 46 | it "it cycles second" do 47 | property_of { [ range(1, 10).times.to_a, 48 | range(1, 10).times.to_a ] } 49 | .check do |a1, a2| 50 | 51 | size = [a1, a2].max_by(&:size).size 52 | zipped = MultiChannel.new(a1).zip(a2) 53 | expect(zipped.map(&:last)).to eq(a2.cycle.take(size)) 54 | end 55 | end 56 | end 57 | end 58 | 59 | describe "rate" do 60 | context "is audio" do 61 | let(:inputs) do 62 | Ugen::RATES[0..4].map { |r| instance_double("Gen", rate: r) } 63 | end 64 | 65 | it { expect(described_class.new(inputs).rate).to eq :audio } 66 | end 67 | 68 | context "is control" do 69 | let(:inputs) do 70 | Ugen::RATES[0..3].map { |r| instance_double("Gen", rate: r) } 71 | end 72 | 73 | it { expect(described_class.new(inputs).rate).to eq :control } 74 | end 75 | 76 | context "is demand" do 77 | let(:inputs) do 78 | Ugen::RATES[0..2].map { |r| instance_double("Gen", rate: r) } 79 | end 80 | 81 | it { expect(described_class.new(inputs).rate).to eq :demand } 82 | end 83 | 84 | context "is trigger" do 85 | let(:inputs) do 86 | Ugen::RATES[0..1].map { |r| instance_double("Gen", rate: r) } 87 | end 88 | 89 | it { expect(described_class.new(inputs).rate).to eq :trigger } 90 | end 91 | 92 | context "is scalar" do 93 | let(:inputs) do 94 | Ugen::RATES[0..0].map { |r| instance_double("Gen", rate: r) } 95 | end 96 | 97 | it { expect(described_class.new(inputs).rate).to eq :scalar } 98 | end 99 | end 100 | end 101 | -------------------------------------------------------------------------------- /spec/ugen/play_buf_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::PlayBuf do 2 | it_behaves_like "has done action" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen/record_buf_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::RecordBuf do 2 | it_behaves_like "has done action" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen/unary_op_ugen_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::UnaryOpUgen do 2 | describe "negate" do 3 | shared_examples_for "is neg unary op ugen" do 4 | it { expect(operation).to be_a UnaryOpUgen } 5 | it { expect(operation.rate).to eq :control } 6 | it { expect(operation.operand).to eq ugen } 7 | it { expect(operation.operation).to eq :neg } 8 | end 9 | 10 | describe "apply" do 11 | let(:ugen) { instance_double("SinOsc", rate: :control) } 12 | subject(:operation) { UnaryOpUgen.apply(:neg, ugen) } 13 | it_behaves_like "is neg unary op ugen" 14 | end 15 | 16 | describe "helper function" do 17 | let(:ugen) { instance_double("SinOsc", rate: :control) } 18 | subject(:operation) { neg(ugen) } 19 | it_behaves_like "is neg unary op ugen" 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/ugen/x_line_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Ugen::XLine do 2 | it_behaves_like "has done action" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen_graph/constant_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph::Constant do 2 | it_behaves_like "is equatable" 3 | end 4 | -------------------------------------------------------------------------------- /spec/ugen_graph/control_name_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph::ControlName do 2 | include Scruby 3 | 4 | describe "building a graph" do 5 | let(:subject) { described_class.new(:a_control, 1) } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/ugen_graph/control_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph::ControlName do 2 | include Scruby 3 | 4 | describe "building a graph" do 5 | let(:subject) { described_class.new(:a_control, 1) } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/ugen_graph/ugen_node_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe UgenGraph::UgenNode do 2 | include Scruby 3 | include Scruby::Ugen 4 | 5 | describe "inputs" do 6 | include_context "node with graph" 7 | 8 | let(:constants) { [ 440, -1 ] } 9 | let(:control_names) { %i(k_1 k_2) } 10 | let(:ugens) { [ Ugen::SinOsc.ar, Ugen::SinOsc.kr ] } 11 | let(:ugen) do 12 | instance_double("Ugen::Base", input_values: inputs) 13 | end 14 | 15 | let(:controls) do 16 | [ UgenGraph::ControlName.new(1, :control), 17 | UgenGraph::ControlName.new(2, :control) 18 | ] 19 | end 20 | 21 | subject(:node) { described_class.build(graph, ugen) } 22 | 23 | before do 24 | allow(graph).to receive(:control_name) 25 | .with(:k_1) { controls.first } 26 | 27 | allow(graph).to receive(:control_name) 28 | .with(:k_2) { controls.last } 29 | 30 | allow(graph).to receive(:add_control) 31 | .with(controls.first) { controls.first} 32 | 33 | allow(graph).to receive(:add_control) 34 | .with(controls.last) { controls.last} 35 | end 36 | 37 | let(:inputs) do 38 | all = [ constants.dup, control_names.dup, ugens.dup ] 39 | 40 | [].tap do |collection| 41 | while all.any?(&:any?) 42 | elem = all.sample.shift 43 | collection << elem if elem 44 | end 45 | end 46 | end 47 | 48 | it "sets constants" do 49 | expect(node.constants) 50 | .to eq constants.map { |c| UgenGraph::Constant.new(c) } 51 | end 52 | 53 | it "sets nodes" do 54 | expect(node.nodes) 55 | .to eq ugens.map { |u| UgenGraph::UgenNode.build(graph, u) } 56 | end 57 | 58 | it "sets controls" do 59 | expect(node.controls).to eq controls 60 | end 61 | end 62 | 63 | 64 | describe ".index" do 65 | let(:ugen) { instance_double("Ugen::Base", input_values: []) } 66 | let(:graph) { instance_double("Scruby::UgenGraph") } 67 | 68 | subject(:node) { described_class.build(graph, ugen) } 69 | 70 | before do 71 | allow(graph).to receive(:node_index) { 9 } 72 | end 73 | 74 | it { expect(node.index).to eq 9 } 75 | end 76 | 77 | 78 | describe ".encode" do 79 | context "control rate" do 80 | let(:ugen) { Ugen::SinOsc.kr } 81 | 82 | include_context "node with graph" 83 | include_context "node with graph constants" do 84 | let(:constants) do 85 | [ UgenGraph::Constant.new(440), 86 | UgenGraph::Constant.new(0) 87 | ] 88 | end 89 | end 90 | 91 | let(:expected) do 92 | [ 6, 83, 105, 110, 79, 115, 99, 1, 0, 0, 0, 2, 0, 0, 0, 1, 0, 93 | 0, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 1, 1 94 | ].pack("C*") 95 | end 96 | 97 | subject(:node) { described_class.build(graph, ugen) } 98 | 99 | it { expect(node).to encode_as(expected) } 100 | end 101 | end 102 | end 103 | -------------------------------------------------------------------------------- /spec/utils/positional_keyword_args_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe Utils::PositionalKeywordArgs do 2 | let(:klass) do 3 | Class.new do 4 | include Utils::PositionalKeywordArgs 5 | public :positional_keyword_args 6 | end 7 | end 8 | 9 | let(:instance) { klass.new } 10 | 11 | let(:defaults) do 12 | { a: 1, b: 2, c: 3, d: 4 } 13 | end 14 | 15 | let(:args) { [] } 16 | let(:kwargs) { {} } 17 | 18 | subject(:result) do 19 | instance.positional_keyword_args(defaults, *args, **kwargs) 20 | end 21 | 22 | 23 | describe "success" do 24 | context "default valuess" do 25 | it "returns defaults" do 26 | expect(result).to eq(a: 1, b: 2, c: 3, d: 4) 27 | end 28 | end 29 | 30 | context "some positional arguments given" do 31 | let(:args) { %i(x y z) } 32 | 33 | it "mixes defaults with positional arg values" do 34 | expect(result).to eq(a: :x, b: :y, c: :z, d: 4) 35 | end 36 | end 37 | 38 | context "passing keyword arguments" do 39 | let(:kwargs) { { b: :x, c: :y, d: :z } } 40 | 41 | it "mixes defaults with positional arg values" do 42 | expect(result).to eq(a: 1, b: :x, c: :y, d: :z) 43 | end 44 | end 45 | 46 | describe "keyword arguments override positional arguments" do 47 | let(:args) { %i(foo bar baz) } 48 | let(:kwargs) { { b: :x, d: :z } } 49 | 50 | it "mixes defaults with positional arg values" do 51 | expect(result).to eq(a: :foo, b: :x, c: :baz, d: :z) 52 | end 53 | end 54 | end 55 | 56 | 57 | describe "failure" do 58 | context "too many arguments given" do 59 | let(:args) { (1..5) } 60 | let(:msg) do 61 | "(wrong number of arguments (given 5, expected less than 4))" 62 | end 63 | 64 | it { expect { result }.to raise_error(ArgumentError, msg) } 65 | end 66 | 67 | context "too many arguments given" do 68 | let(:kwargs) { { baz: 1, hoge: 2 } } 69 | let(:msg) do 70 | "(unknown keywords: :baz, :hoge)" 71 | end 72 | 73 | it { expect { result }.to raise_error(ArgumentError, msg) } 74 | end 75 | end 76 | end 77 | --------------------------------------------------------------------------------