synthdef 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/Guardfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +55 -0
- data/Rakefile +10 -0
- data/lib/synthdef.rb +61 -0
- data/lib/synthdef/version.rb +5 -0
- data/spec/data/recorder.scsyndef +0 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/synthdef_spec.rb +12 -0
- data/synthdef.gemspec +31 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 606df2662e08ada182088202a35eac3d4371288f
|
4
|
+
data.tar.gz: 7e0639b1b86fe4f9555081db52fb7d691f78097c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 178481c0bde1bda955b256fb5d57f0b8d87517d909c13009fb36f941c84ec0438eb6f35c0c4396db5217971fcf90986fef51f8e2f12770eb3b0f584d083c91fa
|
7
|
+
data.tar.gz: 0867d1e926b801e40c21fe2bb03814955ab724e0e69d30c7fe226b1da0e1ea0daf5eaa337cface9942017ef46263eb43738e9e35b0393f30d77a72795daf195c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Xavier Riley
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Synthdef
|
2
|
+
|
3
|
+
## pre-Alpha
|
4
|
+
|
5
|
+
A gem to work with SuperCollider's binary synthdef format. This uses the excellent [`bindata`](https://github.com/dmendel/bindata) gem to define the spec in a very readable way. The implementation is less than 60 lines of code.
|
6
|
+
|
7
|
+
Inspiration for the spec was taken from the following links:
|
8
|
+
|
9
|
+
- [Clojure - Overtone - synthdef.clj](https://github.com/overtone/overtone/blob/master/src/overtone/sc/machinery/synthdef.clj)
|
10
|
+
|
11
|
+
This handles the synthdef format in Overtone, using Jeff Rose's [byte-spec](https://github.com/overtone/byte-spec) library.
|
12
|
+
|
13
|
+
- [Haskell - synthdef.ipynb](https://gist.github.com/miguel-negrao/8d71807afb513412d780)
|
14
|
+
|
15
|
+
Code by @miguel-negrao to parse synthdefs in Haskell.
|
16
|
+
|
17
|
+
Other libraries and langs I haven't checked out yet:
|
18
|
+
|
19
|
+
- [Go - scgolang](https://github.com/scgolang/sc/blob/master/synthdef.go)
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
gem 'synthdef'
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install synthdef
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
Take a binary scsyndef file (you can find an example in `spec/data/recorder.scsyndef`)
|
38
|
+
|
39
|
+
```
|
40
|
+
$ bundle exec irb
|
41
|
+
|
42
|
+
>> require 'synthdef'
|
43
|
+
=> true
|
44
|
+
>> raw = open("spec/data/recorder.scsyndef").read
|
45
|
+
>> Synthdef.read(raw)
|
46
|
+
=> {:file_type_id=>"SCgf", :file_version=>1, :no_of_synthdefs=>1, :synthdefs=>[{:name=>"sonic-pi-recorder", :no_of_constants=>0, :constants=>[], :no_of_params=>2, :params=>[0.0, 0.0], :no_of_param_names=>2, :param_names=>[{:param_name=>"out-buf", :param_index=>0}, {:param_name=>"in_bus", :param_index=>1}], :no_of_ugens=>3, :ugens=>[{:ugen_name=>"Control", :rate=>1, :no_of_inputs=>0, :no_of_outputs=>2, :special=>0, :inputs=>[], :outputs=>[1, 1]}, {:ugen_name=>"InFeedback", :rate=>2, :no_of_inputs=>1, :no_of_outputs=>2, :special=>0, :inputs=>[{:src=>0, :input_index=>1}], :outputs=>[2, 2]}, {:ugen_name=>"DiskOut", :rate=>2, :no_of_inputs=>3, :no_of_outputs=>1, :special=>0, :inputs=>[{:src=>0, :input_index=>0}, {:src=>1, :input_index=>0}, {:src=>1, :input_index=>1}], :outputs=>[2]}], :no_of_variants=>0, :variants=>[]}]}
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it ( http://github.com/xavriley/synthdef/fork )
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'nested']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
data/lib/synthdef.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "synthdef/version"
|
2
|
+
require 'bindata'
|
3
|
+
|
4
|
+
class PascalString < BinData::Primitive
|
5
|
+
uint8 :len, :value => lambda { data.length }
|
6
|
+
string :data, :read_length => :len
|
7
|
+
|
8
|
+
def get; self.data; end
|
9
|
+
def set(v) self.data = v; end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Synthdef < BinData::Record
|
13
|
+
endian :big
|
14
|
+
|
15
|
+
string :file_type_id, read_length: 4
|
16
|
+
uint32 :file_version
|
17
|
+
uint16 :no_of_synthdefs
|
18
|
+
|
19
|
+
array :synthdefs, initial_length: lambda { no_of_synthdefs } do
|
20
|
+
pascal_string :name
|
21
|
+
|
22
|
+
int16 :no_of_constants
|
23
|
+
array :constants, initial_length: lambda { no_of_constants } do
|
24
|
+
float :constant
|
25
|
+
end
|
26
|
+
|
27
|
+
int16 :no_of_params
|
28
|
+
array :params, initial_length: lambda { no_of_params } do
|
29
|
+
float :initial_parameter_value
|
30
|
+
end
|
31
|
+
|
32
|
+
int16 :no_of_param_names
|
33
|
+
array :param_names, initial_length: lambda { no_of_param_names } do
|
34
|
+
pascal_string :param_name
|
35
|
+
int16 :param_index
|
36
|
+
end
|
37
|
+
|
38
|
+
int16 :no_of_ugens
|
39
|
+
array :ugens, initial_length: lambda { no_of_ugens } do
|
40
|
+
pascal_string :ugen_name
|
41
|
+
int8 :rate
|
42
|
+
int16 :no_of_inputs
|
43
|
+
int16 :no_of_outputs
|
44
|
+
int16 :special, initial_value: 0
|
45
|
+
array :inputs, initial_length: lambda { no_of_inputs } do
|
46
|
+
int16 :src
|
47
|
+
int16 :input_index
|
48
|
+
end
|
49
|
+
array :outputs, initial_length: lambda { no_of_outputs } do
|
50
|
+
int8 :calculation_rate
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
int16 :no_of_variants, initial_value: 0
|
55
|
+
array :variants, initial_length: lambda { no_of_variants } do
|
56
|
+
pascal_string :variant_name
|
57
|
+
float :variant_param
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Synthdef do
|
4
|
+
let(:synthdef_binary) { IO.read(File.expand_path("../data/recorder.scsyndef", __FILE__)) }
|
5
|
+
|
6
|
+
it 'reads a basic synthdef' do
|
7
|
+
parsed_synthdef = Synthdef.read(synthdef_binary).snapshot
|
8
|
+
|
9
|
+
expect(parsed_synthdef).to be_a(Hash)
|
10
|
+
expect(parsed_synthdef).not_to be_empty
|
11
|
+
end
|
12
|
+
end
|
data/synthdef.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'synthdef/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "synthdef"
|
8
|
+
spec.version = Synthdef::VERSION
|
9
|
+
spec.authors = ["Xavier Riley"]
|
10
|
+
spec.email = ["xavriley@hotmail.com"]
|
11
|
+
spec.summary = %q{Work with SuperCollider's binary synthdef format}
|
12
|
+
spec.description = %q{Use the power of Ruby to convert, edit and save synthdefs for SuperCollider}
|
13
|
+
spec.homepage = "https://github.com/xavriley/synthdef"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "bindata"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-rspec"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
spec.add_development_dependency "pry-remote"
|
30
|
+
spec.add_development_dependency "pry-nav"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: synthdef
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Xavier Riley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bindata
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-remote
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-nav
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Use the power of Ruby to convert, edit and save synthdefs for SuperCollider
|
140
|
+
email:
|
141
|
+
- xavriley@hotmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- Gemfile
|
148
|
+
- Guardfile
|
149
|
+
- LICENSE.txt
|
150
|
+
- README.md
|
151
|
+
- Rakefile
|
152
|
+
- lib/synthdef.rb
|
153
|
+
- lib/synthdef/version.rb
|
154
|
+
- spec/data/recorder.scsyndef
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- spec/synthdef_spec.rb
|
157
|
+
- synthdef.gemspec
|
158
|
+
homepage: https://github.com/xavriley/synthdef
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
metadata: {}
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 2.4.6
|
179
|
+
signing_key:
|
180
|
+
specification_version: 4
|
181
|
+
summary: Work with SuperCollider's binary synthdef format
|
182
|
+
test_files:
|
183
|
+
- spec/data/recorder.scsyndef
|
184
|
+
- spec/spec_helper.rb
|
185
|
+
- spec/synthdef_spec.rb
|
186
|
+
has_rdoc:
|