The (undocumented) class CollStream imitates the File interface, while keeping data in memory. (This makes it possible to write code that can print to the post window or write text to a disk file or collect text in a String, using the file streaming interface.)
SoundFileStream is the counterpart for SoundFile.
Create a new instance.
collection |
Data to be read. If omitted, the object will be empty (ready for -writeData). This should be a FloatArray or a subclass (most likely Signal). |
Get audio data from the stream.
floatArray |
A FloatArray or Signal, initialized by ArrayedCollection: *newClear to the number of samples you want to read. See SoundFile: -readData. |
Write data from a FloatArray or Signal into the stream.
seek
does not apply to writing.floatArray |
The data to add to the end. |
Move the read position to a given number of sample frames, relative to origin
.
frames |
How many (integer) frames to move relative to the origin. |
origin |
0 = measure from the start of the data; 1 = measure from the current position; 2 = measure from the end of the data. |
There is no real necessity to close an in-memory collection; however, this method resets the position to the beginning. This is convenient when, for instance, filling a SoundFileStream by -writeData, and then resetting to read from the same object.
The complete data collection.
Properties are "fake," in a sense -- there is no sound file header for an in-memory collection. But, for programming interface compatibility, the following methods are provided.
How many channels are represented (interleaved).
Ignored.
Largely ignored, although it does affect -duration.
Calculated from the size of the collection divided by numChannels.
Calculated from numFrames / sampleRate.
Ignored.
See WavetablePrep for a more interesting usage example.