Skip to content

Ruby binding gem to the csound sound software compiler API using FFI

License

Notifications You must be signed in to change notification settings

nicb/csoundAPI-ruby

Repository files navigation

Ruby bindings to the Csound API

Join the chat at https://gitter.im/nicb/csoundAPI-ruby Build Status Code Climate Test Coverage Issue Count

This is a Ruby binding gem to the csound sound software compiler API using FFI.

I wish somebody else had done it, so that I did not have to do it. However, so far nobody has undertaken this task, so I'll give it a try.

Requirements

Some applications are required to compile the csound library:

Instructions for Users

Installation

Add this line to your application's Gemfile:

gem 'csoundAPI-ruby', :git => 'https://github.com/nicb/csoundAPI-ruby.git'

And then execute:

cd csoundAPI-ruby
git submodule update --init --recursive
bundle install

After you have installed the csoundAPI-ruby gem, you have to run the following command:

$ bundle exec rake csound:build

which will compile the csound library for you.

Usage

We already got the basic command line working. You can write something like:

#!/usr/bin/env ruby
#
# csound_low_cli.rb: this is a command-line interface command that replicates
# the regular 'C' +csound+ command line.
#
require 'bundler/setup'
require 'csoundAPI_ruby'
require 'FFI/utilities'

include CsoundAPIRuby::Lib::Functions

cs = csoundCreate(nil)
argv = [$0] + ARGV # ARGV does not have argv[0] as in C, so we need to add it in front
res = csoundCompile(cs, argv.size, FFI::Utilities.set_argv(argv))
csoundPerform(cs)
csoundCleanup(cs)
csoundDestroy(cs)

exit(res)

(you can find this snippet here). Then you can run from a terminal:

$ ./share/doc/examples/csound_low_cli.rb -dWo ./test.wav spec/fixtures/csound/simple.csd

and this will produce the same result as if you called csound from the usual C command.

Details about the parts of the API already implemented may be found on the following pages:

Instructions for Developers

Help Wanted

HELP WANTED and most welcome.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/csoundAPI-ruby/fork )
  2. Clone it (git clone --recursive https://github.com/[my-github-username]/csoundAPI-ruby.git)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

PLEASE NOTE: since we're using a submodule to pull in the csound library, you need to add the --recursive flag whenever you git clone or you want to update the csound repo, as in:

  git clone --recursive https://github.com/[my-github-username]/csoundAPI-ruby.git

or

  cd csoundAPI-ruby
  git submodule update --init --recursive

(I found these latter instructions here).

License

CsoundAPI-ruby Copyright (C) 2015 Nicola Bernardini Licensed under the terms of the GNU GPL version 2 License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

About

Ruby binding gem to the csound sound software compiler API using FFI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published