natiny_audio_create_source

C
NatinyAudioSource natiny_audio_create_source(NatinyClip clip);

Creates a stopped sound-source entity that plays a clip.

Parameters

Name Type Description
clip NatinyClip Clip whose samples this source plays

Returns

Type Description
NatinyAudioSource Source handle, also usable as a NatinyEntity; 0 on failure

Example

C
NatinyAudioSource source = natiny_audio_create_source(clip);

Notes

  • The source does not own the clip or its decoded samples. Multiple sources can share one clip; destroying the source leaves the clip intact.
  • Each source owns one playback voice. At most 256 sources can exist at once.
  • A source starts stopped, spatial, non-looping, at volume and pitch 1.0f. Its attenuation defaults to NATINY_AUDIO_ATTENUATION_INVERSE, distances 1.0f and 100.0f, and rolloff 1.0f.
  • The handle can be moved or parented with natiny_entity_*.
  • A source whose clip is destroyed plays nothing; it is not an error.
  • An invalid clip handle also creates a silent source.
  • Returns 0 when the voice limit is exhausted or allocation fails.