Core API Reference | Channel

7. Core API Reference | Channel

A source of audio signal that connects to the ChannelGroup mixing hierarchy.

Create with System::playSound or System::playDSP.

Playback control:

Information:

The following APIs are inherited from ChannelControl:

Playback:

Volume levels:

Spatialization:

Panning and level adjustment:

Filtering:

DSP chain configuration:

Sample accurate scheduling:

General:

Channel::getChannelGroup

Retrieves the ChannelGroup this object outputs to.

C
C++
C#
JS

FMOD_RESULT Channel::getChannelGroup(
  ChannelGroup **channelgroup
);
channelgroup Out
Output group. (ChannelGroup)

See Also: Channel::setChannelGroup

Channel::getCurrentSound

Retrieves the currently playing Sound.

C
C++
C#
JS

FMOD_RESULT Channel::getCurrentSound(
  Sound **sound
);
sound Out
Currently playing sound. (Sound)

May return NULL or equivalent if no Sound is playing.

See Also: System::playSound

Channel::getFrequency

Retrieves the playback frequency or playback rate.

C
C++
C#
JS

FMOD_RESULT Channel::getFrequency(
  float *frequency
);
frequency Out

Playback frequency.

  • Units: Hertz

See Also: Channel::setFrequency

Channel::getIndex

Retrieves the index of this object in the System Channel pool.

C
C++
C#
JS

FMOD_RESULT Channel::getIndex(
  int *index
);
index Out

Index within the System Channel pool.

See Also: System::getChannel

Channel::getLoopCount

Retrieves the number of times to loop before stopping.

C
C++
C#
JS

FMOD_RESULT Channel::getLoopCount(
  int *loopcount
);
loopcount Out
Times to loop before stopping where 0 represents "oneshot", 1 represents "loop once then stop" and -1 represents "loop forever".

This is the current loop countdown value that will decrement as it plays until reaching 0. Reset with Channel::setLoopCount.

Channel::getLoopPoints

Retrieves the loop start and end points.

C
C++
C#
JS

FMOD_RESULT Channel::getLoopPoints(
  unsigned int *loopstart,
  FMOD_TIMEUNIT loopstarttype,
  unsigned int *loopend,
  FMOD_TIMEUNIT loopendtype
);
loopstart OutOpt

Loop start point.

loopstarttype
Time units for loopstart. (FMOD_TIMEUNIT)
loopend OutOpt

Loop end point.

loopendtype
Time units for loopend. (FMOD_TIMEUNIT)

Valid FMOD_TIMEUNIT types are FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_MS, FMOD_TIMEUNIT_PCMBYTES. Any other time units return FMOD_ERR_FORMAT.
If FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCMBYTES are used, the value is internally converted from FMOD_TIMEUNIT_PCM, so the retrieved value may not exactly match the set value.

See Also: Channel::setLoopPoints

Channel::getPosition

Retrieves the current playback position.

C
C++
C#
JS

FMOD_RESULT Channel::getPosition(
  unsigned int *position,
  FMOD_TIMEUNIT postype
);
position Out
Playback position.
postype
Time units for position. (FMOD_TIMEUNIT)

Certain FMOD_TIMEUNIT types are always available: FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_PCMBYTES and FMOD_TIMEUNIT_MS. The others are format specific such as FMOD_TIMEUNIT_MODORDER / FMOD_TIMEUNIT_MODROW / FMOD_TIMEUNIT_MODPATTERN which is specific to files of type MOD / S3M / XM / IT.

If FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCMBYTES are used, the value is internally converted from FMOD_TIMEUNIT_PCM, so the retrieved value may not exactly match the set value.

See Also: Channel::setPosition

Channel::getPriority

Retrieves the priority used for virtual Channel ordering.

C
C++
C#
JS

FMOD_RESULT Channel::getPriority(
  int *priority
);
priority Out

Priority where 0 represents most important and 256 represents least important.

  • Range: [0, 256]
  • Default: 128

Priority is used as a coarse grain control for the virtual Channel system, lower priority Channels will always be stolen before higher. For channels of equal priority, those with the quietest ChannelControl::getAudibility value will be stolen first.

See the Virtual Voices guide for more information.

See Also: Channel::setPriority

Channel::isVirtual

Retrieves whether the Channel is being emulated by the virtual Channel system.

C
C++
C#
JS

FMOD_RESULT Channel::isVirtual(
  bool *isvirtual
);
isvirtual Out

Virtual state. True = silent / emulated. False = audible / real.

  • Units: Boolean

See the Virtual Voices guide for more information.

See Also: ChannelControl::getAudibility

Channel::setChannelGroup

Sets the ChannelGroup this object outputs to.

C
C++
C#
JS

FMOD_RESULT Channel::setChannelGroup(
  ChannelGroup *channelgroup
);
channelgroup
Output group. (ChannelGroup)

A ChannelGroup may contain many Channels.

Channels may only output to a single ChannelGroup. This operation will remove it from the previous group first.

See Also: Channel::getChannelGroup

Channel::setFrequency

Sets the frequency or playback rate.

C
C++
C#
JS

FMOD_RESULT Channel::setFrequency(
  float frequency
);
frequency

Playback rate.

  • Units: Hertz

Default frequency is determined by the audio format of the Sound or DSP.

Sounds opened as FMOD_CREATESAMPLE (not FMOD_CREATESTREAM or FMOD_CREATECOMPRESSEDSAMPLE) can be played backwards by giving a negative frequency.

See Also: Channel::getFrequency, Sound::setDefaults

Channel::setLoopCount

Sets the number of times to loop before stopping.

C
C++
C#
JS

FMOD_RESULT Channel::setLoopCount(
  int loopcount
);
loopcount
Times to loop before stopping where 0 represents "oneshot", 1 represents "loop once then stop" and -1 represents "loop forever".

The 'mode' of the Sound or Channel must be FMOD_LOOP_NORMAL or FMOD_LOOP_BIDI for this function to work.

See Also: Streaming Issues, Channel::getLoopCount, ChannelControl::setMode, Sound::setMode, System::createSound

Channel::setLoopPoints

Sets the loop start and end points.

C
C++
C#
JS

FMOD_RESULT Channel::setLoopPoints(
  unsigned int loopstart,
  FMOD_TIMEUNIT loopstarttype,
  unsigned int loopend,
  FMOD_TIMEUNIT loopendtype
);
loopstart

Loop start point.

loopstarttype
Time units for loopstart. (FMOD_TIMEUNIT)
loopend

Loop end point.

loopendtype
Time units for loopend. (FMOD_TIMEUNIT)

Loop points may only be set on a Channel playing a Sound, not a Channel playing a DSP (See System::playDSP).

Valid FMOD_TIMEUNIT types are FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_MS, FMOD_TIMEUNIT_PCMBYTES. Any other time units return FMOD_ERR_FORMAT.
If FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCMBYTES, the value is internally converted to FMOD_TIMEUNIT_PCM.

See Also: Streaming Issues, Channel::getLoopPoints

Channel::setPosition

Sets the current playback position.

C
C++
C#
JS

FMOD_RESULT Channel::setPosition(
  unsigned int position,
  FMOD_TIMEUNIT postype
);
position
Playback position.
postype
Time units for position. (FMOD_TIMEUNIT)

Certain FMOD_TIMEUNIT types are always available: FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_PCMBYTES and FMOD_TIMEUNIT_MS. The others are format specific such as FMOD_TIMEUNIT_MODORDER / FMOD_TIMEUNIT_MODROW / FMOD_TIMEUNIT_MODPATTERN which is specific to files of type MOD / S3M / XM / IT.

If playing a Sound created with System::createStream or FMOD_CREATESTREAM changing the position may cause a slow reflush operation while the file seek and decode occurs. You can avoid this by creating the stream with FMOD_NONBLOCKING. This will cause the stream to go into FMOD_OPENSTATE_SETPOSITION state (see Sound::getOpenState) and Sound commands will return FMOD_ERR_NOTREADY. Channel::getPosition will also not update until this non-blocking set position operation has completed.

Using a VBR source that does not have an associated seek table or seek information (such as MP3 or MOD/S3M/XM/IT) may cause inaccurate seeking if you specify FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCM. If you want FMOD to create a PCM vs bytes seek table so that seeking is accurate, you will have to specify FMOD_ACCURATETIME when loading or opening the sound. This means there is a slight delay as FMOD scans the whole file when loading the sound to create this table.

See Also: Channel::getPosition

Channel::setPriority

Sets the priority used for virtual Channel ordering.

C
C++
C#
JS

FMOD_RESULT Channel::setPriority(
  int priority
);
priority

Priority where 0 represents most important and 256 represents least important.

  • Range: [0, 256]
  • Default: 128

Priority is used as a coarse grain control for the virtual Channel system, lower priority Channels will always be stolen before higher. For channels of equal priority, those with the quietest ChannelControl::getAudibility value will be stolen first.

See the Virtual Voices guide for more information.

See Also: Channel::getPriority