[−][src]Enum csound::AudioChannel
An audio channel identifier
Variants
ctype
Trait Implementations
impl<'a> GetChannel<'a, AudioChannel> for Csound
[src]
fn get_input_channel(
&'a self,
name: &str,
_: AudioChannel
) -> Result<ChannelPtr<'a, AudioChannel, Writable>, Status>
[src]
&'a self,
name: &str,
_: AudioChannel
) -> Result<ChannelPtr<'a, AudioChannel, Writable>, Status>
Return a ChannelPtr
which represent a csound's input channel ptr.
creating the channel first if it does not exist yet.
Arguments
name
The channel name.channel_type
must be any of the following values:
- ControlChannel::ctype control data (one MYFLT value)
- AudioChannel::ctype audio data (get_ksmps() f64 values)
- StrChannel::ctype string data (u8 values with enough space to store get_channel_data_size() characters, including the NULL character at the end of the string) If the channel already exists, it must match the data type (control, audio, or string)
Note
Audio and String channels can only be created after calling compile(), because the storage size is not known until then.
Returns
A Writable ChannelPtr on success or a Status code, "Not enough memory for allocating the channel" (CS_MEMORY) "The specified name or type is invalid" (CS_ERROR) or, if a channel with the same name but incompatible type already exists, the type of the existing channel.
- Note: to find out the type of a channel without actually
creating or changing it, set 'channel_type' argument to CSOUND_UNKNOWN_CHANNEL, so that the error
value will be either the type of the channel, or CSOUND_ERROR
if it does not exist.
Operations on the channel pointer are not thread-safe by default. The host is
required to take care of threadsafety by
- with control channels use __sync_fetch_and_add() or __sync_fetch_and_or() gcc atomic builtins to get or set a channel, if available.
- For string and audio channels (and controls if option 1 is not available), retrieve the channel lock with ChannelLock() and use SpinLock() and SpinUnLock() to protect access to the channel. See Top/threadsafe.c in the Csound library sources for examples. Optionally, use the channel get/set functions which are threadsafe by default.
Example
// Creates a Csound instance let csound = Csound::new(); csound.compile_csd(csd_filename).unwrap(); csound.start(); // Request a csound's input control channel let control_channel = csound.get_input_channel("myChannel", ControlChannel::ctype ).unwrap(); // Writes some data to the channel control_channel.write(10.25); // Request a csound's input audio channel let audio_channel = csound.get_input_channel("myAudioChannel", AudioChannel::ctype).unwrap(); // Request a csound's input string channel let string_channel = csound.get_input_channel("myStringChannel", StrChannel::ctype).unwrap();
fn get_output_channel(
&'a self,
name: &str,
_: AudioChannel
) -> Result<ChannelPtr<'a, AudioChannel, Readable>, Status>
[src]
&'a self,
name: &str,
_: AudioChannel
) -> Result<ChannelPtr<'a, AudioChannel, Readable>, Status>
Return a ChannelPtr
which represent a csound's output channel ptr.
creating the channel first if it does not exist yet.
Arguments
name
The channel name.channel_type
must be any of the following values:
- ControlChannel::ctype control data (one MYFLT value)
- AudioChannel::ctype audio data (get_ksmps() f64 values)
- StrChannel::ctype string data (u8 values with enough space to store get_channel_data_size() characters, including the NULL character at the end of the string) If the channel already exists, it must match the data type (control, audio, or string)
Note
Audio and String channels can only be created after calling compile(), because the storage size is not known until then.
Returns
A Readable ChannelPtr on success or a Status code, "Not enough memory for allocating the channel" (CS_MEMORY) "The specified name or type is invalid" (CS_ERROR) or, if a channel with the same name but incompatible type already exists, the type of the existing channel.
- Note: to find out the type of a channel without actually
creating or changing it, set 'channel_type' argument to CSOUND_UNKNOWN_CHANNEL, so that the error
value will be either the type of the channel, or CSOUND_ERROR
if it does not exist.
Operations on the channel pointer are not thread-safe by default. The host is
required to take care of threadsafety by
- with control channels use __sync_fetch_and_add() or __sync_fetch_and_or() gcc atomic builtins to get or set a channel, if available.
- For string and audio channels (and controls if option 1 is not available), retrieve the channel lock with ChannelLock() and use SpinLock() and SpinUnLock() to protect access to the channel. See Top/threadsafe.c in the Csound library sources for examples. Optionally, use the channel get/set functions which are threadsafe by default.
Example
// Creates a Csound instance let csound = Csound::new(); csound.compile_csd(csd_filename).unwrap(); csound.start(); // Request a csound's output control channel let control_channel = csound.get_output_channel("myChannel", ControlChannel::ctype ).unwrap(); // Writes some data to the channel println!("channel value {}", constrol_channel.read()); // Request a csound's output audio channel let audio_channel = csound.get_output_channel("myAudioChannel", AudioChannel::ctype).unwrap(); println!("audio channel samples {:?}", audio_channel.read() ); // Request a csound's output string channel let string_channel = csound.get_output_channel("myStringChannel", StrChannel::ctype).unwrap();
impl PartialEq<AudioChannel> for AudioChannel
[src]
fn eq(&self, other: &AudioChannel) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Debug for AudioChannel
[src]
Auto Trait Implementations
impl Unpin for AudioChannel
impl Sync for AudioChannel
impl Send for AudioChannel
impl UnwindSafe for AudioChannel
impl RefUnwindSafe for AudioChannel
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,