wavegraph 0.1.2-x86_64-linux-gnu

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 (101) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +26 -0
  3. data/LICENSE-APACHE +201 -0
  4. data/LICENSE-MIT +22 -0
  5. data/README.md +209 -0
  6. data/examples/acid.rb +45 -0
  7. data/lib/wavegraph/host.rb +99 -0
  8. data/lib/wavegraph/native/libwavegraph.so +0 -0
  9. data/lib/wavegraph/native.rb +51 -0
  10. data/lib/wavegraph/patch.rb +41 -0
  11. data/lib/wavegraph/performance.rb +47 -0
  12. data/lib/wavegraph/version.rb +5 -0
  13. data/lib/wavegraph.rb +33 -0
  14. data/licenses/COPYRIGHT-library.html +29630 -0
  15. data/licenses/alsa-0.11.0/LICENSE-APACHE +177 -0
  16. data/licenses/alsa-0.11.0/LICENSE-MIT +21 -0
  17. data/licenses/alsa-sys-0.4.0/LICENSE +21 -0
  18. data/licenses/audio-codec-algorithms-0.8.1/LICENSE-0BSD +14 -0
  19. data/licenses/audio-codec-algorithms-0.8.1/LICENSE-APACHE +176 -0
  20. data/licenses/audioadapter-5.0.0/LICENSE-APACHE +201 -0
  21. data/licenses/audioadapter-5.0.0/LICENSE-MIT +19 -0
  22. data/licenses/audioadapter-5.0.0/LICENSE.txt +6 -0
  23. data/licenses/audioadapter-buffers-5.2.0/LICENSE-APACHE +201 -0
  24. data/licenses/audioadapter-buffers-5.2.0/LICENSE-MIT +19 -0
  25. data/licenses/audioadapter-buffers-5.2.0/LICENSE.txt +6 -0
  26. data/licenses/audioadapter-sample-5.2.0/LICENSE-APACHE +201 -0
  27. data/licenses/audioadapter-sample-5.2.0/LICENSE-MIT +19 -0
  28. data/licenses/audioadapter-sample-5.2.0/LICENSE.txt +6 -0
  29. data/licenses/bitflags-2.13.2/LICENSE-APACHE +201 -0
  30. data/licenses/bitflags-2.13.2/LICENSE-MIT +25 -0
  31. data/licenses/byteorder-1.5.0/COPYING +3 -0
  32. data/licenses/byteorder-1.5.0/LICENSE-MIT +21 -0
  33. data/licenses/byteorder-1.5.0/UNLICENSE +24 -0
  34. data/licenses/bytes-1.12.2/LICENSE +25 -0
  35. data/licenses/cfg-if-1.0.5/LICENSE-APACHE +201 -0
  36. data/licenses/cfg-if-1.0.5/LICENSE-MIT +25 -0
  37. data/licenses/cpal-0.18.2/LICENSE +201 -0
  38. data/licenses/dasp_sample-0.11.0/dasp_sample-MIT +21 -0
  39. data/licenses/hash32-0.3.1/LICENSE-APACHE +201 -0
  40. data/licenses/hash32-0.3.1/LICENSE-MIT +25 -0
  41. data/licenses/heapless-0.9.4/LICENSE-APACHE +201 -0
  42. data/licenses/heapless-0.9.4/LICENSE-MIT +25 -0
  43. data/licenses/libc-0.2.191/LICENSE-APACHE +176 -0
  44. data/licenses/libc-0.2.191/LICENSE-MIT +25 -0
  45. data/licenses/libm-0.2.16/LICENSE.txt +258 -0
  46. data/licenses/micromath-2.2.0/LICENSE-APACHE +202 -0
  47. data/licenses/micromath-2.2.0/LICENSE-MIT +21 -0
  48. data/licenses/mio-1.2.5/LICENSE +19 -0
  49. data/licenses/num-integer-0.1.47/LICENSE-APACHE +201 -0
  50. data/licenses/num-integer-0.1.47/LICENSE-MIT +25 -0
  51. data/licenses/num-traits-0.2.19/LICENSE-APACHE +201 -0
  52. data/licenses/num-traits-0.2.19/LICENSE-MIT +25 -0
  53. data/licenses/once_cell-1.21.4/LICENSE-APACHE +201 -0
  54. data/licenses/once_cell-1.21.4/LICENSE-MIT +23 -0
  55. data/licenses/peg-0.8.6/LICENSE +25 -0
  56. data/licenses/peg-runtime-0.8.6/LICENSE +25 -0
  57. data/licenses/pin-project-lite-0.2.19/LICENSE-APACHE +177 -0
  58. data/licenses/pin-project-lite-0.2.19/LICENSE-MIT +23 -0
  59. data/licenses/rtrb-0.3.6/LICENSE-APACHE +201 -0
  60. data/licenses/rtrb-0.3.6/LICENSE-MIT +23 -0
  61. data/licenses/rubato-5.1.0/LICENSE-APACHE +201 -0
  62. data/licenses/rubato-5.1.0/LICENSE-MIT +19 -0
  63. data/licenses/rubato-5.1.0/LICENSE.txt +6 -0
  64. data/licenses/socket2-0.6.5/LICENSE-APACHE +201 -0
  65. data/licenses/socket2-0.6.5/LICENSE-MIT +25 -0
  66. data/licenses/stable_deref_trait-1.2.1/LICENSE-APACHE +201 -0
  67. data/licenses/stable_deref_trait-1.2.1/LICENSE-MIT +25 -0
  68. data/licenses/tokio-1.54.1/LICENSE +21 -0
  69. data/licenses/tracing-0.1.44/LICENSE +25 -0
  70. data/licenses/tracing-core-0.1.36/LICENSE +25 -0
  71. data/licenses/wavegraph-0.1.3/LICENSE-APACHE +201 -0
  72. data/licenses/wavegraph-0.1.3/LICENSE-MIT +22 -0
  73. data/licenses/wavegraph-303-0.1.2/LICENSE +21 -0
  74. data/licenses/wavegraph-808-0.1.0/LICENSE-APACHE +201 -0
  75. data/licenses/wavegraph-808-0.1.0/LICENSE-MIT +22 -0
  76. data/licenses/wavegraph-909-0.1.0/LICENSE-APACHE +201 -0
  77. data/licenses/wavegraph-909-0.1.0/LICENSE-CC0 +102 -0
  78. data/licenses/wavegraph-909-0.1.0/LICENSE-MIT +21 -0
  79. data/licenses/wavegraph-909-0.1.0/README.md +25 -0
  80. data/licenses/wavegraph-adsr-0.1.0/LICENSE-APACHE +201 -0
  81. data/licenses/wavegraph-adsr-0.1.0/LICENSE-MIT +22 -0
  82. data/licenses/wavegraph-audio-0.1.1/LICENSE-APACHE +201 -0
  83. data/licenses/wavegraph-audio-0.1.1/LICENSE-MIT +21 -0
  84. data/licenses/wavegraph-compiler-0.1.0/LICENSE-APACHE +201 -0
  85. data/licenses/wavegraph-compiler-0.1.0/LICENSE-MIT +22 -0
  86. data/licenses/wavegraph-core-0.1.0/LICENSE-APACHE +201 -0
  87. data/licenses/wavegraph-core-0.1.0/LICENSE-MIT +22 -0
  88. data/licenses/wavegraph-dsp-0.1.1/LICENSE-APACHE +201 -0
  89. data/licenses/wavegraph-dsp-0.1.1/LICENSE-MIT +21 -0
  90. data/licenses/wavegraph-fx-0.1.1/LICENSE-APACHE +202 -0
  91. data/licenses/wavegraph-fx-0.1.1/LICENSE-MIT +22 -0
  92. data/licenses/wavegraph-lfo-0.1.0/LICENSE-APACHE +201 -0
  93. data/licenses/wavegraph-lfo-0.1.0/LICENSE-MIT +22 -0
  94. data/licenses/wavegraph-remote-0.1.2/LICENSE-APACHE +201 -0
  95. data/licenses/wavegraph-remote-0.1.2/LICENSE-MIT +21 -0
  96. data/licenses/wavegraph-sample-0.1.1/LICENSE-APACHE +216 -0
  97. data/licenses/wavegraph-sample-0.1.1/LICENSE-MIT +22 -0
  98. data/licenses/wavegraph-sampler-0.1.0/LICENSE-APACHE +201 -0
  99. data/licenses/wavegraph-sampler-0.1.0/LICENSE-MIT +21 -0
  100. data/licenses/windowfunctions-0.1.1/LICENSE.txt +19 -0
  101. metadata +172 -0
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WaveGraph
4
+ class Patch
5
+ def self.compile(source)
6
+ new(source)
7
+ end
8
+
9
+ private_class_method :new
10
+
11
+ def initialize(source)
12
+ @lock = Mutex.new
13
+ out = FFI::MemoryPointer.new(:pointer)
14
+ # Don't abandon the pointer between native allocation and transfer to Ruby.
15
+ Thread.handle_interrupt(Object => :never) do
16
+ Native.with_source(source) { |buffer, length| Native.check(Native.compile(buffer, length, out)) }
17
+ @pointer = FFI::AutoPointer.new(out.read_pointer, Native.method(:patch_free))
18
+ end
19
+ end
20
+
21
+ def close
22
+ @lock.synchronize do
23
+ Thread.handle_interrupt(Object => :never) { @pointer.free }
24
+ end
25
+ nil
26
+ end
27
+
28
+ def closed?
29
+ @lock.synchronize { !@pointer.autorelease? }
30
+ end
31
+
32
+ private
33
+
34
+ def with_pointer
35
+ @lock.synchronize do
36
+ raise ClosedError, "compiled patch is closed" unless @pointer.autorelease?
37
+ yield @pointer
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WaveGraph
4
+ # Performance commands use MIDI on the host's WaveGraph Remote socket.
5
+ module Performance
6
+ # Start the sequencer at step one.
7
+ def play
8
+ write_midi(0xfa)
9
+ end
10
+
11
+ # Stop the sequencer. Live MIDI and the audio engine stay available.
12
+ def stop
13
+ write_midi(0xfc)
14
+ end
15
+
16
+ def note_on(note, velocity: 100, channel: 1)
17
+ write_midi(0x90 | channel_index(channel),
18
+ midi_value(:note, note), midi_value(:velocity, velocity, 1..127))
19
+ end
20
+
21
+ def note_off(note, channel: 1)
22
+ write_midi(0x80 | channel_index(channel), midi_value(:note, note), 64)
23
+ end
24
+
25
+ def cc(controller, value, channel: 1)
26
+ write_midi(0xb0 | channel_index(channel),
27
+ midi_value(:controller, controller), midi_value(:value, value))
28
+ end
29
+
30
+ private
31
+
32
+ def channel_index(channel)
33
+ midi_value(:channel, channel, 1..16) - 1
34
+ end
35
+
36
+ def midi_value(name, value, range = 0..127)
37
+ return value if value.is_a?(Integer) && range.cover?(value)
38
+
39
+ raise ArgumentError, "#{name} must be an integer in #{range}"
40
+ end
41
+
42
+ def write_midi(*bytes)
43
+ socket.write([bytes.length, *bytes].pack("C*"))
44
+ self
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WaveGraph
4
+ VERSION = "0.1.2"
5
+ end
data/lib/wavegraph.rb ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "wavegraph/version"
4
+
5
+ # Embed the WaveGraph audio engine in a Ruby process.
6
+ module WaveGraph
7
+ class Error < StandardError; end
8
+ class InvalidPatch < Error; end
9
+ class ClosedError < Error; end
10
+
11
+ # :call-seq:
12
+ # WaveGraph.open(source = nil, bpm: 122, headless: false) { |host| ... } -> object
13
+ #
14
+ # Play the factory 3389 rack, a string of .wg source, or a compiled
15
+ # WaveGraph::Patch. Yields a WaveGraph::Host and returns the block's value.
16
+ # The host shuts down even if the block raises. Set +headless+ to +true+
17
+ # to run the patch without opening an audio device.
18
+ def self.open(...)
19
+ Host.open(...)
20
+ end
21
+
22
+ # Compile UTF-8 .wg source into a WaveGraph::Patch for reuse across hosts.
23
+ # Call WaveGraph::Patch#close when finished with the patch. Invalid source
24
+ # raises WaveGraph::InvalidPatch with the compiler's diagnostic.
25
+ def self.compile(source)
26
+ Patch.compile(source)
27
+ end
28
+ end
29
+
30
+ require_relative "wavegraph/native"
31
+ require_relative "wavegraph/patch"
32
+ require_relative "wavegraph/performance"
33
+ require_relative "wavegraph/host"