csound 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/csound.rb +66 -1
  3. metadata +23 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8d1eccd6d24dd57acf2dac59b06ffbc9e1ed4dbe69bce2fa1ffddc5c172206f
4
- data.tar.gz: 98855f8130235cb7fd37889d4fc80300c8b415b729a99705af605469cd1faa26
3
+ metadata.gz: 9199a8cabc449c5a81ad92ec0a7b6e808bc870810bb7664fca9069520dbb2b3f
4
+ data.tar.gz: f67749f699b7abdb7dac61b76a418ce98721ad45287adacd5c1627bfe4865111
5
5
  SHA512:
6
- metadata.gz: '09f1f16780eda1e289226f855f07de63a03c916e59df856d939372e6764a0595692ecce48bb927e7afc5bcadd51b7fafbe776fcde9cd8a07699ada22ae7d4193'
7
- data.tar.gz: 6d3ae7730a612b6145aaa7dccb1c1e03be46abecef1df4175fe3a63d28be69d546e23481096de8b67d44510178812e1351d482f05bc9905d8e5d85d2eba4e692
6
+ metadata.gz: e56c6a4ca66a5b9048d4d29d6b84a28a1b2e476d20111559e6db41f61926b3d9c2c57685a77f22f8cb15f75c805ff5874ca24e27d167352e26aa9bc34483f901
7
+ data.tar.gz: 1bc25ea163fbb24a75fd8344d143364ed4528fc86c6aa7cd9a85ced24bdab13907f59d5a61b900e7089c24d85572a41022d5f56cc46bf3522baceed1a196a332
data/lib/csound.rb CHANGED
@@ -3,6 +3,16 @@ require "bundler/inline"
3
3
  gemfile do
4
4
  source "https://rubygems.org"
5
5
  gem "ffi", require: true
6
+ gem "os", require: true
7
+ end
8
+
9
+ def convert_to_binary(integer)
10
+ binary = []
11
+ while integer > 0
12
+ binary << integer % 2
13
+ integer /= 2
14
+ end
15
+ binary.reverse.join
6
16
  end
7
17
 
8
18
  module ControlChannelType
@@ -42,9 +52,36 @@ class ControlChannelInfo_t < FFI::Struct
42
52
  :hints, ControlChannelHints_t
43
53
  end
44
54
 
55
+ class CS_TYPE < FFI::Struct
56
+ layout :varTypeName,:string,
57
+ :varDescription,:string,
58
+ :argtype,:int,
59
+ :createVariable,:pointer,
60
+ :copyValue,:pointer,
61
+ :unionTypes,:pointer,
62
+ :freeVariableMemory,:pointer
63
+
64
+ end
65
+
66
+ def get_possible_paths
67
+ if(OS.linux?) then
68
+ return ["libcsound64.so",
69
+ "/usr/local/lib/libcsound64.so",
70
+ "/usr/lib/libcsound64.so"]
71
+ elsif(OS.mac?) then
72
+ return ["CsoundLib64",
73
+ "/Library/Frameworks/CsoundLib64.framework/Versions/6.0/CsoundLib64"]
74
+ elsif(OS.windows) then
75
+ return ["csound64", "csound64.dll",
76
+ "C:/Program Files/Csound6_x64/csound64.dll",
77
+ "C:/Program Files/Csound6_x64/lib/csound64.dll",
78
+ "C:/Program Files/Csound6_x64/bin/csound64.dll" ]
79
+ end
80
+ end
81
+
45
82
  module CsoundModule
46
83
  extend FFI::Library
47
- ffi_lib '/usr/local/lib/libcsound64.so'
84
+ ffi_lib get_possible_paths
48
85
 
49
86
  attach_function :csoundCreate,[:pointer],:pointer
50
87
  attach_function :csoundInitialize,[:int],:int
@@ -170,6 +207,12 @@ module CsoundModule
170
207
 
171
208
  #Handwritten
172
209
  attach_function :csoundSetControlChannel,[:pointer,:string,:double],:void
210
+ attach_function :csoundGetControlChannel,[:pointer,:string,:pointer],:double
211
+
212
+ callback :channel_callback_t,[:pointer,:string,:pointer,:pointer],:void
213
+ attach_function :csoundSetInputChannelCallback,[:pointer,:channel_callback_t],:void
214
+ attach_function :csoundSetOutputChannelCallback,[:pointer,:channel_callback_t],:void
215
+
173
216
 
174
217
  attach_function :csoundGetFirstMessage,[:pointer],:string
175
218
 
@@ -692,6 +735,28 @@ class Csound
692
735
  CsoundModule.csoundSetControlChannel(@csound, channel_name, value)
693
736
  end
694
737
 
738
+ def GetControlChannel(channel_name)
739
+ return CsoundModule.csoundGetControlChannel(@csound, channel_name, nil)
740
+ end
741
+
742
+ def SetOutputChannelCallback(cbk)
743
+ # Is this function destroyed someday ?
744
+ c_cbk = FFI::Function.new(:void, [:pointer,:string,:pointer,CS_TYPE.by_ref]) do |csound,channel_name,valueptr, channel_type|
745
+ if(channel_type[:varTypeName] == "k") then
746
+ cbk(channel_name, valueptr.read(FFI::Type::DOUBLE), channel_type[:varTypeName])
747
+ elsif(channel_type[:varTypeName] == "S") then
748
+ cbk(channel_name, valueptr.read_string, channel_type[:varTypeName])
749
+ end
750
+ end
751
+ CsoundModule.csoundSetOutputChannelCallback(@csound, c_cbk)
752
+ end
753
+
754
+ def SetInputChannelCallback(cbk)
755
+ c_cbk = FFI::Function.new(:void, [:pointer,:string,:pointer,CS_TYPE.by_ref]) do |csound,channel_name,valueptr, channel_type|
756
+ end
757
+ CsoundModule.csoundSetInputChannelCallback(@csound, c_cbk)
758
+ end
759
+
695
760
  def GetFirstMessage()
696
761
  return CsoundModule.csoundGetFirstMessage(@csound)
697
762
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csound
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johann Philippe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-31 00:00:00.000000000 Z
11
+ date: 2023-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,26 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: os
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.1.4
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.1'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.1.4
41
61
  description: Csound for Ruby, through FFI
42
62
  email: johannphilippe@lilo.org
43
63
  executables: []
@@ -65,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
85
  - !ruby/object:Gem::Version
66
86
  version: '0'
67
87
  requirements: []
68
- rubyforge_project:
69
- rubygems_version: 2.7.6
88
+ rubygems_version: 3.3.7
70
89
  signing_key:
71
90
  specification_version: 4
72
91
  summary: Csound Gem for Ruby