Class: Scruby::Buffer
Instance Attribute Summary collapse
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#frames ⇒ Object
Returns the value of attribute frames.
-
#path ⇒ Object
Returns the value of attribute path.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#server ⇒ Object
readonly
readNoUpdate loadCollection sendCollection streamCollection loadToFloatArray getToFloatArray set setn get getn fill normalize gen sine1 …
Class Method Summary collapse
- .alloc_consecutive(buffers, server, frames = -1,, channels = 1, &message) ⇒ Object
- .allocate(server, frames = -1,, channels = 1, &message) ⇒ Object
- .cue_sound_file(server, path, start, channels = 2, buff_size = 32768, &message) ⇒ Object
-
.read(server, path, start = 0, frames = -1,, &message) ⇒ Object
Allocate a buffer and immediately read a soundfile into it.
- .read_channel(server, path, start = 0, frames = -1,, channels = [], &message) ⇒ Object
Instance Method Summary collapse
- #allocate(&message) ⇒ Object
-
#allocate_and_read(path, start, frames, &message) ⇒ Object
:nodoc:.
- #allocate_read_channel(path, start, frames, channels, &message) ⇒ Object
- #buffnum ⇒ Object (also: #as_ugen_input, #index)
- #close(&message) ⇒ Object
- #cue_sound_file(path, start = 0, &message) ⇒ Object
-
#free(&message) ⇒ Object
alias :as_control_input :buffnum.
-
#initialize(server, frames = -1,, channels = 1) ⇒ Buffer
constructor
A new instance of Buffer.
- #read(path, file_start = 0, frames = -1,, buff_start = 0, leave_open = false, &message) ⇒ Object
- #read_channel(path, file_start = 0, frames = -1,, buff_start = 0, leave_open = false, channels = [], &message) ⇒ Object
- #write(path = nil, format = 'aiff', sample_format = 'int24', frames = -1,, start = 0, leave_open = false, &message) ⇒ Object
- #zero(&message) ⇒ Object
Constructor Details
#initialize(server, frames = -1,, channels = 1) ⇒ Buffer
Returns a new instance of Buffer.
74 75 76 |
# File 'lib/scruby/buffer.rb', line 74 def initialize server, frames = -1, channels = 1 @server, @frames, @channels = server, frames, channels end |
Instance Attribute Details
#channels ⇒ Object
Returns the value of attribute channels.
34 35 36 |
# File 'lib/scruby/buffer.rb', line 34 def channels @channels end |
#frames ⇒ Object
Returns the value of attribute frames.
34 35 36 |
# File 'lib/scruby/buffer.rb', line 34 def frames @frames end |
#path ⇒ Object
Returns the value of attribute path.
34 35 36 |
# File 'lib/scruby/buffer.rb', line 34 def path @path end |
#rate ⇒ Object
Returns the value of attribute rate.
34 35 36 |
# File 'lib/scruby/buffer.rb', line 34 def rate @rate end |
#server ⇒ Object (readonly)
readNoUpdate loadCollection sendCollection streamCollection loadToFloatArray getToFloatArray set setn get getn fill normalize gen sine1 … copy copyData query updateInfo queryDone printOn play duration asBufWithValues
33 34 35 |
# File 'lib/scruby/buffer.rb', line 33 def server @server end |
Class Method Details
.alloc_consecutive(buffers, server, frames = -1,, channels = 1, &message) ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/scruby/buffer.rb', line 135 def alloc_consecutive buffers, server, frames = -1, channels = 1, & buffers = Array.new(buffers){ new server, frames, channels } server.allocate :buffers, buffers ||= 0 buffers.each do |buff| server.send '/b_alloc', buff.buffnum, frames, channels, .value(buff) end end |
.allocate(server, frames = -1,, channels = 1, &message) ⇒ Object
114 115 116 |
# File 'lib/scruby/buffer.rb', line 114 def allocate server, frames = -1, channels = 1, & new(server, frames, channels).allocate & end |
.cue_sound_file(server, path, start, channels = 2, buff_size = 32768, &message) ⇒ Object
118 119 120 121 122 123 |
# File 'lib/scruby/buffer.rb', line 118 def cue_sound_file server, path, start, channels = 2, buff_size = 32768, & allocate server, buff_size, channels do |buffer| ||= 0 ['/b_read', buffer.buffnum, (path), start, buff_size, 0, true, .value(buffer)] end end |
.read(server, path, start = 0, frames = -1,, &message) ⇒ Object
Allocate a buffer and immediately read a soundfile into it.
126 127 128 129 |
# File 'lib/scruby/buffer.rb', line 126 def read server, path, start = 0, frames = -1, & buffer = new server, & buffer.allocate_and_read (path), start, frames end |
.read_channel(server, path, start = 0, frames = -1,, channels = [], &message) ⇒ Object
131 132 133 |
# File 'lib/scruby/buffer.rb', line 131 def read_channel server, path, start = 0, frames = -1, channels = [], & new(server, frames, channels).allocate_read_channel (path), start, frames, channels, & end |
Instance Method Details
#allocate(&message) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/scruby/buffer.rb', line 78 def allocate & ||= 0 @server.allocate :buffers, self @server.send '/b_alloc', buffnum, frames, channels, .value(self) self end |
#allocate_and_read(path, start, frames, &message) ⇒ Object
:nodoc:
99 100 101 102 103 104 |
# File 'lib/scruby/buffer.rb', line 99 def allocate_and_read path, start, frames, & @server.allocate :buffers, self ||= ["/b_query", buffnum] @server.send "/b_allocRead", buffnum, @path = (path), start, frames, .value(self) self end |
#allocate_read_channel(path, start, frames, channels, &message) ⇒ Object
106 107 108 109 110 111 |
# File 'lib/scruby/buffer.rb', line 106 def allocate_read_channel path, start, frames, channels, & @server.allocate :buffers, self ||= ["/b_query", buffnum] @server.send *(["/b_allocReadChannel", buffnum, (path), start, frames] + channels << .value(self)) self end |
#buffnum ⇒ Object Also known as: as_ugen_input, index
85 86 87 |
# File 'lib/scruby/buffer.rb', line 85 def buffnum @server.buffers.index self end |
#close(&message) ⇒ Object
49 50 51 52 53 |
# File 'lib/scruby/buffer.rb', line 49 def close & ||= 0 @server.send '/b_close', buffnum, .value(self) self end |
#cue_sound_file(path, start = 0, &message) ⇒ Object
61 62 63 64 65 |
# File 'lib/scruby/buffer.rb', line 61 def cue_sound_file path, start = 0, & ||= 0 @server.send "/b_read", buffnum, (path), start, @frames, 0, 1, .value(self) self end |
#free(&message) ⇒ Object
alias :as_control_input :buffnum
92 93 94 95 96 |
# File 'lib/scruby/buffer.rb', line 92 def free & ||= 0 @server.send "/b_free", buffnum, .value(self) @server.buffers.delete self end |
#read(path, file_start = 0, frames = -1,, buff_start = 0, leave_open = false, &message) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/scruby/buffer.rb', line 36 def read path, file_start = 0, frames = -1, buff_start = 0, leave_open = false, & # @on_info = message ||= ["/b_query", buffnum] @server.send "/b_read", buffnum, (path), file_start, frames, buff_start, leave_open, .value(self) self end |
#read_channel(path, file_start = 0, frames = -1,, buff_start = 0, leave_open = false, channels = [], &message) ⇒ Object
43 44 45 46 47 |
# File 'lib/scruby/buffer.rb', line 43 def read_channel path, file_start = 0, frames = -1, buff_start = 0, leave_open = false, channels = [], & ||= 0 @server.send *(["/b_ReadChannel", buffnum, (path), start, frames, buff_start, leave_open] + channels << .value(self)) self end |
#write(path = nil, format = 'aiff', sample_format = 'int24', frames = -1,, start = 0, leave_open = false, &message) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/scruby/buffer.rb', line 67 def write path = nil, format = 'aiff', sample_format = 'int24', frames = -1, start = 0, leave_open = false, & ||= 0 path ||= "#{ DateTime.now }.#{ format }" @server.send "/b_write", buffnum, (path), format, sample_format, frames, start, leave_open, .value(self) self end |
#zero(&message) ⇒ Object
55 56 57 58 59 |
# File 'lib/scruby/buffer.rb', line 55 def zero & ||= 0 @server.send '/b_zero', buffnum, .value(self) self end |