wavegraph 0.1.2-aarch64-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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +26 -0
- data/LICENSE-APACHE +201 -0
- data/LICENSE-MIT +22 -0
- data/README.md +209 -0
- data/examples/acid.rb +45 -0
- data/lib/wavegraph/host.rb +99 -0
- data/lib/wavegraph/native/libwavegraph.so +0 -0
- data/lib/wavegraph/native.rb +51 -0
- data/lib/wavegraph/patch.rb +41 -0
- data/lib/wavegraph/performance.rb +47 -0
- data/lib/wavegraph/version.rb +5 -0
- data/lib/wavegraph.rb +33 -0
- data/licenses/COPYRIGHT-library.html +29630 -0
- data/licenses/alsa-0.11.0/LICENSE-APACHE +177 -0
- data/licenses/alsa-0.11.0/LICENSE-MIT +21 -0
- data/licenses/alsa-sys-0.4.0/LICENSE +21 -0
- data/licenses/audio-codec-algorithms-0.8.1/LICENSE-0BSD +14 -0
- data/licenses/audio-codec-algorithms-0.8.1/LICENSE-APACHE +176 -0
- data/licenses/audioadapter-5.0.0/LICENSE-APACHE +201 -0
- data/licenses/audioadapter-5.0.0/LICENSE-MIT +19 -0
- data/licenses/audioadapter-5.0.0/LICENSE.txt +6 -0
- data/licenses/audioadapter-buffers-5.2.0/LICENSE-APACHE +201 -0
- data/licenses/audioadapter-buffers-5.2.0/LICENSE-MIT +19 -0
- data/licenses/audioadapter-buffers-5.2.0/LICENSE.txt +6 -0
- data/licenses/audioadapter-sample-5.2.0/LICENSE-APACHE +201 -0
- data/licenses/audioadapter-sample-5.2.0/LICENSE-MIT +19 -0
- data/licenses/audioadapter-sample-5.2.0/LICENSE.txt +6 -0
- data/licenses/bitflags-2.13.2/LICENSE-APACHE +201 -0
- data/licenses/bitflags-2.13.2/LICENSE-MIT +25 -0
- data/licenses/byteorder-1.5.0/COPYING +3 -0
- data/licenses/byteorder-1.5.0/LICENSE-MIT +21 -0
- data/licenses/byteorder-1.5.0/UNLICENSE +24 -0
- data/licenses/bytes-1.12.2/LICENSE +25 -0
- data/licenses/cfg-if-1.0.5/LICENSE-APACHE +201 -0
- data/licenses/cfg-if-1.0.5/LICENSE-MIT +25 -0
- data/licenses/cpal-0.18.2/LICENSE +201 -0
- data/licenses/dasp_sample-0.11.0/dasp_sample-MIT +21 -0
- data/licenses/hash32-0.3.1/LICENSE-APACHE +201 -0
- data/licenses/hash32-0.3.1/LICENSE-MIT +25 -0
- data/licenses/heapless-0.9.4/LICENSE-APACHE +201 -0
- data/licenses/heapless-0.9.4/LICENSE-MIT +25 -0
- data/licenses/libc-0.2.191/LICENSE-APACHE +176 -0
- data/licenses/libc-0.2.191/LICENSE-MIT +25 -0
- data/licenses/libm-0.2.16/LICENSE.txt +258 -0
- data/licenses/micromath-2.2.0/LICENSE-APACHE +202 -0
- data/licenses/micromath-2.2.0/LICENSE-MIT +21 -0
- data/licenses/mio-1.2.5/LICENSE +19 -0
- data/licenses/num-integer-0.1.47/LICENSE-APACHE +201 -0
- data/licenses/num-integer-0.1.47/LICENSE-MIT +25 -0
- data/licenses/num-traits-0.2.19/LICENSE-APACHE +201 -0
- data/licenses/num-traits-0.2.19/LICENSE-MIT +25 -0
- data/licenses/once_cell-1.21.4/LICENSE-APACHE +201 -0
- data/licenses/once_cell-1.21.4/LICENSE-MIT +23 -0
- data/licenses/peg-0.8.6/LICENSE +25 -0
- data/licenses/peg-runtime-0.8.6/LICENSE +25 -0
- data/licenses/pin-project-lite-0.2.19/LICENSE-APACHE +177 -0
- data/licenses/pin-project-lite-0.2.19/LICENSE-MIT +23 -0
- data/licenses/rtrb-0.3.6/LICENSE-APACHE +201 -0
- data/licenses/rtrb-0.3.6/LICENSE-MIT +23 -0
- data/licenses/rubato-5.1.0/LICENSE-APACHE +201 -0
- data/licenses/rubato-5.1.0/LICENSE-MIT +19 -0
- data/licenses/rubato-5.1.0/LICENSE.txt +6 -0
- data/licenses/socket2-0.6.5/LICENSE-APACHE +201 -0
- data/licenses/socket2-0.6.5/LICENSE-MIT +25 -0
- data/licenses/stable_deref_trait-1.2.1/LICENSE-APACHE +201 -0
- data/licenses/stable_deref_trait-1.2.1/LICENSE-MIT +25 -0
- data/licenses/tokio-1.54.1/LICENSE +21 -0
- data/licenses/tracing-0.1.44/LICENSE +25 -0
- data/licenses/tracing-core-0.1.36/LICENSE +25 -0
- data/licenses/wavegraph-0.1.3/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-0.1.3/LICENSE-MIT +22 -0
- data/licenses/wavegraph-303-0.1.2/LICENSE +21 -0
- data/licenses/wavegraph-808-0.1.0/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-808-0.1.0/LICENSE-MIT +22 -0
- data/licenses/wavegraph-909-0.1.0/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-909-0.1.0/LICENSE-CC0 +102 -0
- data/licenses/wavegraph-909-0.1.0/LICENSE-MIT +21 -0
- data/licenses/wavegraph-909-0.1.0/README.md +25 -0
- data/licenses/wavegraph-adsr-0.1.0/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-adsr-0.1.0/LICENSE-MIT +22 -0
- data/licenses/wavegraph-audio-0.1.1/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-audio-0.1.1/LICENSE-MIT +21 -0
- data/licenses/wavegraph-compiler-0.1.0/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-compiler-0.1.0/LICENSE-MIT +22 -0
- data/licenses/wavegraph-core-0.1.0/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-core-0.1.0/LICENSE-MIT +22 -0
- data/licenses/wavegraph-dsp-0.1.1/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-dsp-0.1.1/LICENSE-MIT +21 -0
- data/licenses/wavegraph-fx-0.1.1/LICENSE-APACHE +202 -0
- data/licenses/wavegraph-fx-0.1.1/LICENSE-MIT +22 -0
- data/licenses/wavegraph-lfo-0.1.0/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-lfo-0.1.0/LICENSE-MIT +22 -0
- data/licenses/wavegraph-remote-0.1.2/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-remote-0.1.2/LICENSE-MIT +21 -0
- data/licenses/wavegraph-sample-0.1.1/LICENSE-APACHE +216 -0
- data/licenses/wavegraph-sample-0.1.1/LICENSE-MIT +22 -0
- data/licenses/wavegraph-sampler-0.1.0/LICENSE-APACHE +201 -0
- data/licenses/wavegraph-sampler-0.1.0/LICENSE-MIT +21 -0
- data/licenses/windowfunctions-0.1.1/LICENSE.txt +19 -0
- 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
|
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"
|