csound 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/csound.rb +126 -2
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9199a8cabc449c5a81ad92ec0a7b6e808bc870810bb7664fca9069520dbb2b3f
|
4
|
+
data.tar.gz: f67749f699b7abdb7dac61b76a418ce98721ad45287adacd5c1627bfe4865111
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
|
@@ -183,6 +226,22 @@ module CsoundModule
|
|
183
226
|
attach_function :csoundClearSpin,[:pointer],:void
|
184
227
|
attach_function :csoundAddSpinSample,[:pointer,:int,:int,:double],:double
|
185
228
|
attach_function :csoundSetSpinSample,[:pointer,:int,:int,:double],:void
|
229
|
+
|
230
|
+
|
231
|
+
attach_function :csoundGetEnv,[:pointer,:string],:string
|
232
|
+
attach_function :csoundCreateGlobalVariable,[:pointer,:string,:size_t],:int
|
233
|
+
|
234
|
+
attach_function :csoundQueryGlobalVariable,[:pointer,:string],:pointer
|
235
|
+
attach_function :csoundQueryGlobalVariableNoCheck,[:pointer,:string],:pointer
|
236
|
+
|
237
|
+
attach_function :csoundRunUtility,[:pointer,:string,:int,:pointer],:int
|
238
|
+
attach_function :csoundListUtilities,[:pointer],:pointer
|
239
|
+
attach_function :csoundGetUtilityDescription,[:pointer,:string],:string
|
240
|
+
|
241
|
+
attach_function :csoundCreateCircularBuffer,[:pointer,:int,:int],:pointer
|
242
|
+
attach_function :csoundReadCircularBuffer,[:pointer,:pointer,:pointer,:int],:int
|
243
|
+
attach_function :csoundPeekCircularBuffer,[:pointer,:pointer,:pointer,:int],:int
|
244
|
+
attach_function :csoundWriteCircularBuffer,[:pointer,:pointer,:pointer,:int],:int
|
186
245
|
#Missing
|
187
246
|
#csoundSetMessageCallback
|
188
247
|
#csoundSetMessageStringCallback
|
@@ -676,6 +735,28 @@ class Csound
|
|
676
735
|
CsoundModule.csoundSetControlChannel(@csound, channel_name, value)
|
677
736
|
end
|
678
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
|
+
|
679
760
|
def GetFirstMessage()
|
680
761
|
return CsoundModule.csoundGetFirstMessage(@csound)
|
681
762
|
end
|
@@ -707,5 +788,48 @@ class Csound
|
|
707
788
|
def SetSpinSample(frame, channel, sample)
|
708
789
|
CsoundModule.csoundSetSpinSample(@csound, frame, channel, sample)
|
709
790
|
end
|
710
|
-
end
|
711
791
|
|
792
|
+
def GetEnv(name)
|
793
|
+
return CsoundModule.csoundGetEnv(@csound,name)
|
794
|
+
end
|
795
|
+
|
796
|
+
def CreateGlobalVariable(name, nbytes)
|
797
|
+
return CsoundModule.csoundCreateGlobalVariable(@csound, name, nbytes)
|
798
|
+
end
|
799
|
+
|
800
|
+
def QueryGlobalVariable(name)
|
801
|
+
return CsoundModule.csoundQueryGlobalVariable(@csound, name)
|
802
|
+
end
|
803
|
+
|
804
|
+
def QueryGlobalVariableNoCheck(name)
|
805
|
+
return CsoundModule.csoundQueryGlobalVariableNoCheck(@csound, name)
|
806
|
+
end
|
807
|
+
|
808
|
+
def RunUtility(name, argc, argv)
|
809
|
+
return CsoundModule.csoundRunUtility(@csound, argc, argv)
|
810
|
+
end
|
811
|
+
|
812
|
+
def ListUtilities
|
813
|
+
return CsoundModule.csoundListUtilities(@csound)
|
814
|
+
end
|
815
|
+
|
816
|
+
def GetUtilityDescription(name)
|
817
|
+
return CsoundModule.csoundGetUtilityDescription(@csound,name)
|
818
|
+
end
|
819
|
+
|
820
|
+
def CreateCircularBuffer(numelem, elemsize)
|
821
|
+
return CsoundModule.csoundCreateCircularBuffer(@csound,numelem,elemsize)
|
822
|
+
end
|
823
|
+
|
824
|
+
def ReadCircularBuffer(buffer, out, items)
|
825
|
+
return CsoundModule.csoundReadCircularBuffer(@csound,buffer,out,items)
|
826
|
+
end
|
827
|
+
|
828
|
+
def PeekCircularBuffer(buffer, out, items)
|
829
|
+
return CsoundModule.csoundPeekCircularBuffer(@csound, buffer, out, items)
|
830
|
+
end
|
831
|
+
|
832
|
+
def WriteCirularBuffer(p,inp,items)
|
833
|
+
return CsoundModule.csoundWriteCircularBuffer(@csound,p,inp,items)
|
834
|
+
end
|
835
|
+
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
|
+
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:
|
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
|
-
|
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
|