synthdef 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9c8588c67ed85ad21a8d99a8137c050943f0c2d
4
- data.tar.gz: 89e2c2d3bd2cabcafa5b18c02200cbb0d7705b61
3
+ metadata.gz: d37a515d073dae65541a0d175d2c86332b10d96e
4
+ data.tar.gz: 18aa402610ceccb1bdb67ee77fbd0aecfaec3d31
5
5
  SHA512:
6
- metadata.gz: 6c8aa4387cb4868107d233ff0773df514603c7ac1019a894526bf2c116a08955c3af04393f6bc6bad0841ba52d076d7aa400bb0354097ad6cb78b69e4ceac93a
7
- data.tar.gz: 1aa642d35abdef185c5dfc1a5499a03d6d40e3e82c55e62b64ce57d6abe1a7c252659329c525ddf1d1c1755ad388622c409786e0a90a3300e44f24c228081731
6
+ metadata.gz: ce0d99d8bf7bc43949fff5581495c43b6007f4c3bab2c24d24d0d41551fb26887334811a9d62646a7f8dab78be4a1fe57136503b849a41f8da9b76bf3fe5d332
7
+ data.tar.gz: 31bdd62ce2a628cab2cf52996dc4e335c479c65f65edd678ce1e282552d4142f1c6d0e69c46f2d480fde03db08d8033071c968fff35e664aa7cf31f659db018b
data/README.md CHANGED
@@ -44,6 +44,13 @@ The gem ships with a command line tool to print the contents of a synthdef file
44
44
 
45
45
  ```
46
46
  $ gem install synthdef
47
+ $ synthdef -v
48
+ synthdef gem version 0.0.5
49
+ Manipulate SuperCollider synthdef files from the command line
50
+ Usage: synthdef [options] [path]
51
+ -c, --convert [VERSION] Specify synthdef version of output
52
+ -f, --format [FORMAT] Specify output format: json, raw
53
+ -v, --version Show version
47
54
  $ synthdef /path/to/synthdefs/foo.scsyndef
48
55
  => {
49
56
  "file_type_id": "SCgf",
@@ -56,6 +63,18 @@ $ synthdef /path/to/synthdefs/foo.scsyndef
56
63
  "constants": [
57
64
  0.0,
58
65
  ...
66
+ $ synthdef --convert 2 /path/to/synthdefs/foo.scsyndef
67
+ => {
68
+ "file_type_id": "SCgf",
69
+ "file_version": 2,
70
+ "no_of_synthdefs": 1,
71
+ "synthdefs": [
72
+ {
73
+ "name": "sonic-pi-pretty_bell",
74
+ "no_of_constants": 15,
75
+ "constants": [
76
+ 0.0,
77
+ ...
59
78
  ```
60
79
 
61
80
  ## Usage
@@ -2,6 +2,7 @@
2
2
  require 'synthdef'
3
3
  require 'json'
4
4
  require 'optparse'
5
+ require 'pp'
5
6
 
6
7
  ARGV << '-h' if ARGV.empty?
7
8
 
@@ -13,7 +14,7 @@ OptionParser.new do |opts|
13
14
  options[:convert] = c
14
15
  end
15
16
 
16
- opts.on("-f", "--format [FORMAT]", ["json", "raw"], "Specify output format: json, raw") do |f|
17
+ opts.on("-f", "--format [FORMAT]", ["json", "ruby", "raw"], "Specify output format: json, ruby, raw") do |f|
17
18
  options[:format] = f
18
19
  end
19
20
 
@@ -42,6 +43,8 @@ options[:format] ||= "json"
42
43
  case options[:format]
43
44
  when "json"
44
45
  puts JSON.pretty_generate(sdef.snapshot)
46
+ when "ruby"
47
+ pp sdef.snapshot
45
48
  when "raw"
46
49
  puts sdef.to_binary_s
47
50
  else
@@ -9,6 +9,15 @@ class PascalString < BinData::Primitive
9
9
  def set(v) self.data = v; end
10
10
  end
11
11
 
12
+ class SynthInt < BinData::Choice
13
+ endian :big
14
+ default_parameter :selection => :check_version
15
+ default_parameter :copy_on_change => true
16
+
17
+ int16 0
18
+ int32 1
19
+ end
20
+
12
21
  class Synthdef < BinData::Record
13
22
  def check_version
14
23
  # Returns zero based index for choices
@@ -24,35 +33,35 @@ class Synthdef < BinData::Record
24
33
  array :synthdefs, initial_length: lambda { no_of_synthdefs } do
25
34
  pascal_string :name
26
35
 
27
- choice :no_of_constants, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
36
+ synth_int :no_of_constants
28
37
  array :constants, initial_length: lambda { no_of_constants } do
29
38
  float :constant
30
39
  end
31
40
 
32
- choice :no_of_params, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
41
+ synth_int :no_of_params
33
42
  array :params, initial_length: lambda { no_of_params } do
34
43
  float :initial_parameter_value
35
44
  end
36
45
 
37
- choice :no_of_param_names, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
46
+ synth_int :no_of_param_names
38
47
  array :param_names, initial_length: lambda { no_of_param_names } do
39
48
  pascal_string :param_name
40
- choice :param_index, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
49
+ synth_int :param_index
41
50
  end
42
51
 
43
- choice :no_of_ugens, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
52
+ synth_int :no_of_ugens
44
53
  array :ugens, initial_length: lambda { no_of_ugens } do
45
54
  pascal_string :ugen_name
46
55
  int8 :rate
47
- choice :no_of_inputs, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
48
- choice :no_of_outputs, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
56
+ synth_int :no_of_inputs
57
+ synth_int :no_of_outputs
49
58
  int16 :special, initial_value: 0
50
59
  array :inputs, initial_length: lambda { no_of_inputs } do
51
- choice :src, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
60
+ synth_int :src
52
61
  if lambda { src == -1 }
53
- choice :input_constant_index, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
62
+ synth_int :input_constant_index
54
63
  else
55
- choice :input_ugen_index, :selection => :check_version, :copy_on_change => true, :choices => {0 => :int16, 1 => :int32}
64
+ synth_int :input_ugen_index
56
65
  end
57
66
  end
58
67
  array :outputs, initial_length: lambda { no_of_outputs } do
@@ -1,5 +1,5 @@
1
1
  require 'bindata'
2
2
 
3
3
  class Synthdef < BinData::Record
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synthdef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-21 00:00:00.000000000 Z
11
+ date: 2017-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.4.6
140
+ rubygems_version: 2.6.7
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Work with SuperCollider's binary synthdef format