[][src]Enum csound::StrChannel

pub enum StrChannel {
    ctype,
}

A string channel identifier

Variants

ctype

Trait Implementations

impl<'a> GetChannel<'a, StrChannel> for Csound[src]

fn get_input_channel(
    &'a self,
    name: &str,
    _: StrChannel
) -> Result<ChannelPtr<'a, StrChannel, Writable>, Status>
[src]

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
    1. with control channels use __sync_fetch_and_add() or __sync_fetch_and_or() gcc atomic builtins to get or set a channel, if available.
    2. 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,
    _: StrChannel
) -> Result<ChannelPtr<'a, StrChannel, Readable>, Status>
[src]

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
    1. with control channels use __sync_fetch_and_add() or __sync_fetch_and_or() gcc atomic builtins to get or set a channel, if available.
    2. 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<StrChannel> for StrChannel[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Debug for StrChannel[src]

Auto Trait Implementations

impl Unpin for StrChannel

impl Sync for StrChannel

impl Send for StrChannel

impl UnwindSafe for StrChannel

impl RefUnwindSafe for StrChannel

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]