.. _stdlib_strudel_samples: ================================== Sample bank and audio file loading ================================== .. das:module:: strudel_samples Module strudel_samples ++++++++++ Structures ++++++++++ .. _struct-strudel_samples-Sample: .. das:attribute:: Sample :Fields: * **data** : array - Interleaved PCM float samples (left, right, left, right, ...). * **channels** : int = 1 - Channel count (1 = mono, 2 = stereo). * **sample_rate** : int = 48000 - Native sample rate of the decoded audio in Hz. .. _struct-strudel_samples-SampleBank: .. das:attribute:: SampleBank :Fields: * **sounds** : table`>> - Map from lowercase sound name to its indexed variations (bd:0, bd:1, ...). +++++++ Loading +++++++ * :ref:`load_audio_file (path: string) : Sample ` * :ref:`load_audio_memory (data: array\) : Sample ` * :ref:`load_sound (path: string; name: string; var bank: SampleBank) ` * :ref:`load_sound_memory (data: array\; name: string; var bank: SampleBank) ` .. _function-strudel_samples_load_audio_file_string: .. das:function:: load_audio_file(path: string) : Sample Decode a single audio file (WAV/MP3/FLAC/OGG) from disk into a Sample. Keeps the native channel count (mono or stereo); returns an empty Sample on failure. :Arguments: * **path** : string .. _function-strudel_samples_load_audio_memory_array_ls_uint8_gr_: .. das:function:: load_audio_memory(data: array) : Sample Decode audio bytes (WAV/MP3/FLAC/OGG) from memory into a Sample. Uses miniaudio's memory decoder with explicit error checking; returns an empty Sample on failure. :Arguments: * **data** : array .. _function-strudel_samples_load_sound_string_string_SampleBank: .. das:function:: load_sound(path: string; name: string; bank: SampleBank) Load a single named sound from a directory of audio files into the bank. Files are sorted alphabetically so index :0, :1, ... matches strudel's sample indexing. :Arguments: * **path** : string * **name** : string * **bank** : :ref:`SampleBank ` .. _function-strudel_samples_load_sound_memory_array_ls_uint8_gr__string_SampleBank: .. das:function:: load_sound_memory(data: array; name: string; bank: SampleBank) Decode audio bytes and add the result as a single-variation sound in the bank. :Arguments: * **data** : array * **name** : string * **bank** : :ref:`SampleBank ` +++++++++ Rendering +++++++++ * :ref:`render_sample (bank: SampleBank; name: string; variation: int; speed: float; begin: float = 0f; end_pos: float = 1f) : array\ ` .. _function-strudel_samples_render_sample_SampleBank_string_int_float_float_float: .. das:function:: render_sample(bank: SampleBank; name: string; variation: int; speed: float; begin: float = 0f; end_pos: float = 1f) : array Render a sample slice at the given playback speed as interleaved stereo. begin/end_pos are normalized [0.0..1.0] slice bounds used by striate/chop/loop_at; speed resamples via miniaudio and mono input is upmixed to stereo. No gain/pan applied. :Arguments: * **bank** : :ref:`SampleBank ` * **name** : string * **variation** : int * **speed** : float * **begin** : float * **end_pos** : float