Search the Community
Showing results for tags 'audio'.
-
Suggestion to add sound devices In DU you can present visuals using html, svg, widgets, but when it comes to audio, things are not so bright. Sound is important if you want players to be able to make games. Sound can play role in interfaces, used for alarms and, of cource, playing music! So I propose adding to the game lua-controlled "SPUs"/"sound devices"/"sound units", that will allow players to do all kinds of stuff - from simply playing sound on notification in theyr programs to implementing sound effects in the game, or even creating sound trackers and sequencers (to then create music in it). sound device: -has sound memory consisting of, say 44100*8 bytes (number depends on sound device tier), which that can be read as integers using get_sample, set_sample. -has 8 channels (also depends on sound device tier). each channel can be set to play samples from area in audio memory or use oscillator. Each channel can have 1 siimple filter on it. sound device api: sound memory manipulation functions: samples_count(sample_depth) - returns how much integer values of size sample_depth in bytes sound memory can hold get_sample(sample_depth, sample_index) - interpreting sound memory as array of signed integer numbers consisting of sample_depth bytes return sample_index'th integer number from this array. sample_depth can have value 1, 2, 4, 8. On any other value get_sample returns nil sample_index wraps around if higher than number of integers in array set_sample(sample_depth, sample_index, new_value) - interpreting sound memory as array of signed integer numbers consisting of sample_depth bytes set sample_index'th integer number to new_value. getNSamples(sample_depth, sample_index, N) - same as get_sample, but instead of getting 1 integer value it returns table consisting of N values from audio memory starting from position sample_index. Can be merged with get_sample setNSamples(sample_depth, sample_index, new_value) - same as set_sample, but instead of setting 1 integer value, it sets #new_value samples to values from new_value table starting at position sample_index channel control fuctions: channels_count() -returns number of channels sound device has channel_set_sound_source_memory(channel_num, sample_depth, sample_rate, start, end, loop) -set channel to play sound from sound memory channel_set_sound_source_osc(channel_num, type, frequency, osc_param) -type is string - "noise", "sin", "tri", "square". triangular and rectangular waveforms take 1 more paramenter for rate channel_set_volume(channel_num, new_volume, time, delay) - sets channel volume to new_volume. If time arg is provided, volume will be changed gradually in time milliseonds (if not interrupted by another set_volume command). If delay arg is provided, volume change start will start in delay milliseconds after this command called. channel_set_pan(channel_num, new_pan, time, delay) - sets channel pan to new_pan. 0 is left, 1 is rigth, 0.5 is center channel_set_pitch(channel_num, new_pitch, time, delay) channel_start_note(channel_num, delay) - starts note on channel. start is delayed for delay milliseonds, if delay parameter provided. If other note was playing on this channel, it ends. channel_end_note(channel_num, delay) channel_set_filter_type(channel_num, type, delay) - filter types are "none", "highpass", "lowpass", "comb", "bandpass" channel_set_filter_base_frequency(channel_num, freq, time, delay) channel_set_filter_gain(channel_num, gain, time, delay) - in dB, if applicable to filter channel_set_filter_param(channel_num, param_num, param_amount, time, delay) - filter-specific params, such as resonance for "highpass" or "lowpass", bandwidth for "bandpass"