📄 digi.inc
字号:
{* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Digital sound routines.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*}
{$IFDEF ALLEGRO_INTERFACE}
const
DIGI_VOICES = 64; // Theoretical maximums:
// actual drivers may not be
// able to handle this many
type
P_SAMPLE = ^SAMPLE;
SAMPLE = record // a sample
bits : sint32; // 8 or 16
stereo : sint32; // sample type flag
freq : sint32; // sample frequency
priority : sint32; // 0-255
len : uint32; // length (in samples)
loop_start : uint32; // loop start position
loop_end : uint32; // loop finish position
param : uint32; // for internal use by the driver
data : Pointer; // sample data
end;
const
DIGI_AUTODETECT = -1; // for passing to install_sound()
DIGI_NONE = 0;
type
P_DIGI_DRIVER = ^DIGI_DRIVER;
DIGI_DRIVER = record // driver for playing digital sfx
id : sint32; // driver ID code
name : PChar; // driver name
desc : PChar; // description string
ascii_name : PChar; // ASCII format name string
voices : sint32; // available voices
basevoice : sint32; // voice number offset
max_voices : sint32; // maximum voices we can support
def_voices : sint32; // default number of voices to use
// setup routines
detect : function(input: sint32): sint32; cdecl;
init : function(input, voices: sint32): sint32; cdecl;
exit : procedure(input: sint32); cdecl;
mixer_volume : function(volume: sint32): sint32; cdecl;
// for use by the audiostream functions
lock_voice : function(voice, start, ends: sint32): Pointer; cdecl;
unlock_voice : procedure(voice: sint32); cdecl;
buffer_size : function: sint32; cdecl;
// voice control functions
init_voice : procedure(voice: sint32; const sample: P_SAMPLE); cdecl;
release_voice : procedure(voice: sint32); cdecl;
start_voice : procedure(voice: sint32); cdecl;
stop_voice : procedure(voice: sint32); cdecl;
loop_voice : procedure(voice, playmode: sint32); cdecl;
// position control functions
get_position : function(voice: sint32): sint32; cdecl;
set_position : procedure(voice, position: sint32); cdecl;
// volume control functions
get_volume : function(voice: sint32): sint32; cdecl;
set_volume : procedure(voice, volume: sint32); cdecl;
ramp_volume : procedure(voice, types, endvol: sint32); cdecl;
stop_volume_ramp : procedure(voice: sint32); cdecl;
// pitch control functions
get_frequency : function(voice: sint32): sint32; cdecl;
set_frequency : procedure(voice, frequency: sint32); cdecl;
sweep_frequency : procedure(voice, types, endfreq: sint32); cdecl;
stop_frequency_sweep : procedure(voice: sint32); cdecl;
// pan control functions
get_pan : function(voice: sint32): sint32; cdecl;
set_pan : procedure(voice, pan: sint32); cdecl;
sweep_pan : procedure(voice, types, endpan: sint32); cdecl;
stop_pan_sweep : procedure(voice: sint32); cdecl;
// effect control functions
set_echo : procedure(voice, strength, delay: sint32); cdecl;
set_tremolo : procedure(voice, rate, depth: sint32); cdecl;
set_vibrato : procedure(voice, rate, depth: sint32); cdecl;
// input functions
rec_cap_bits : sint32;
rec_cap_stereo : sint32;
rec_cap_rate : function(bits, stereo: sint32): sint32; cdecl;
rec_cap_parm : function(rate, bits, stereo: sint32): sint32; cdecl;
rec_source : function(source: sint32): sint32; cdecl;
rec_start : function(rate, bits, stereo: sint32): sint32; cdecl;
rec_stop : procedure; cdecl;
rec_read : function(buf: Pointer): sint32; cdecl;
end;
var
_digi_driver_list : P_DRIVER_INFO;
the_digi_driver : ^P_DIGI_DRIVER;
digi_input_driver : ^P_DIGI_DRIVER;
digi_card : p_sint32;
digi_input_card : p_sint32;
detect_digi_driver : function(driver_id: sint32): sint32; cdecl;
load_sample : function(const filename: PChar): P_SAMPLE; cdecl;
load_wav : function(const filename: PChar): P_SAMPLE; cdecl;
load_wav_pf : function(f: P_PACKFILE): P_SAMPLE; cdecl;
load_voc : function(const filename: PChar): P_SAMPLE; cdecl;
load_voc_pf : function(f: P_PACKFILE): P_SAMPLE; cdecl;
save_sample : function(const filename: PChar; spl: P_SAMPLE): sint32; cdecl;
create_sample : function(bits, stereo, freq, len: sint32): P_SAMPLE; cdecl;
destroy_sample : procedure(spl: P_SAMPLE); cdecl;
play_sample : function(const spl: P_SAMPLE; vol, pan, freq, loop: sint32): sint32; cdecl;
stop_sample : procedure(const spl: P_SAMPLE); cdecl;
adjust_sample : procedure(const spl: P_SAMPLE; vol, pan, freq, loop: sint32); cdecl;
allocate_voice : function(const spl: P_SAMPLE): sint32; cdecl;
deallocate_voice : procedure(voice: sint32); cdecl;
reallocate_voice : procedure(voice: sint32; const spl: P_SAMPLE); cdecl;
release_voice : procedure(voice: sint32); cdecl;
voice_start : procedure(voice: sint32); cdecl;
voice_stop : procedure(voice: sint32); cdecl;
voice_set_priority : procedure(voice, priority: sint32); cdecl;
voice_check : function(voice: sint32): P_SAMPLE; cdecl;
const
PLAYMODE_PLAY = 0;
PLAYMODE_LOOP = 1;
PLAYMODE_FORWARD = 0;
PLAYMODE_BACKWARD = 2;
PLAYMODE_BIDIR = 4;
var
voice_set_playmode: procedure(voice, playmode: sint32); cdecl;
voice_get_position: function(voice: sint32): sint32; cdecl;
voice_set_position: procedure(voice, position: sint32); cdecl;
voice_get_volume: function(voice: sint32): sint32; cdecl;
voice_set_volume: procedure(voice, volume: sint32); cdecl;
voice_ramp_volume: procedure(voice, types, endvol: sint32); cdecl;
voice_stop_volumeramp: procedure(voice: sint32); cdecl;
voice_get_frequency: function(voice: sint32): sint32; cdecl;
voice_set_frequency: procedure(voice, frequency: sint32); cdecl;
voice_sweep_frequency: procedure(voice, types, endfreq: sint32); cdecl;
voice_stop_frequency_sweep: procedure(voice: sint32); cdecl;
voice_get_pan: function(voice: sint32): sint32; cdecl;
voice_set_pan: procedure(voice, pan: sint32); cdecl;
voice_sweep_pan: procedure(voice, types, endpan: sint32); cdecl;
voice_stop_pan_sweep: procedure(voice: sint32); cdecl;
voice_set_echo: procedure(voice, strength, delay: sint32); cdecl;
voice_set_tremolo: procedure(voice, rate, depth: sint32); cdecl;
voice_set_vibrato: procedure(voice, rate, depth: sint32); cdecl;
get_sound_input_cap_bits: function: sint32; cdecl;
get_sound_input_cap_stereo: function: sint32; cdecl;
get_sound_input_cap_rate: function(bits, stereo: sint32): sint32; cdecl;
get_sound_input_cap_parm: function(rate, bits, stereo: sint32): sint32; cdecl;
set_sound_input_source: function(source: sint32): sint32; cdecl;
start_sound_input: function(rate, bits, stereo: sint32): sint32; cdecl;
stop_sound_input: procedure; cdecl;
read_sound_input: function(buffer: Pointer): sint32; cdecl;
digi_recorder: ^proc_ptr;
lock_sample: procedure(spl: P_SAMPLE); cdecl;
type
loadsample_ptr = function(const filename: PChar): P_SAMPLE; cdecl;
savesample_ptr = function(const filename: PChar; spl: P_SAMPLE): sint32; cdecl;
var
register_sample_file_type: procedure(const ext: PChar; load: loadsample_ptr;
save: savesample_ptr); cdecl;
{$ENDIF ALLEGRO_INTERFACE}
{$IFDEF ALLEGRO_IMPLEMENTATION}
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
_digi_driver_list := LoadDLL('_digi_driver_list');
the_digi_driver := LoadDLL('digi_driver');
digi_input_driver := LoadDLL('digi_input_driver');
digi_card := LoadDLL('digi_card');
digi_input_card := LoadDLL('digi_input_card');
detect_digi_driver := LoadDLL('detect_digi_driver');
load_sample := LoadDLL('load_sample');
load_wav := LoadDLL('load_wav');
load_wav_pf := LoadDLL('load_wav_pf');
load_voc := LoadDLL('load_voc');
load_voc_pf := LoadDLL('load_voc_pf');
save_sample := LoadDLL('save_sample');
create_sample := LoadDLL('create_sample');
destroy_sample := LoadDLL('destroy_sample');
play_sample := LoadDLL('play_sample');
stop_sample := LoadDLL('stop_sample');
adjust_sample := LoadDLL('adjust_sample');
allocate_voice := LoadDLL('allocate_voice');
deallocate_voice := LoadDLL('deallocate_voice');
reallocate_voice := LoadDLL('reallocate_voice');
release_voice := LoadDLL('release_voice');
voice_start := LoadDLL('voice_start');
voice_stop := LoadDLL('voice_stop');
voice_set_priority := LoadDLL('voice_set_priority');
voice_check := LoadDLL('voice_check');
voice_set_playmode := LoadDLL('voice_set_playmode');
voice_get_position := LoadDLL('voice_get_position');
voice_set_position := LoadDLL('voice_set_position');
voice_get_volume := LoadDLL('voice_get_volume');
voice_set_volume := LoadDLL('voice_set_volume');
voice_ramp_volume := LoadDLL('voice_ramp_volume');
voice_stop_volumeramp := LoadDLL('voice_stop_volumeramp');
voice_get_frequency := LoadDLL('voice_get_frequency');
voice_set_frequency := LoadDLL('voice_set_frequency');
voice_sweep_frequency := LoadDLL('voice_sweep_frequency');
voice_stop_frequency_sweep := LoadDLL('voice_stop_frequency_sweep');
voice_get_pan := LoadDLL('voice_get_pan');
voice_set_pan := LoadDLL('voice_set_pan');
voice_sweep_pan := LoadDLL('voice_sweep_pan');
voice_stop_pan_sweep := LoadDLL('voice_stop_pan_sweep');
voice_set_echo := LoadDLL('voice_set_echo');
voice_set_tremolo := LoadDLL('voice_set_tremolo');
voice_set_vibrato := LoadDLL('voice_set_vibrato');
get_sound_input_cap_bits := LoadDLL('get_sound_input_cap_bits');
get_sound_input_cap_stereo := LoadDLL('get_sound_input_cap_stereo');
get_sound_input_cap_rate := LoadDLL('get_sound_input_cap_rate');
get_sound_input_cap_parm := LoadDLL('get_sound_input_cap_parm');
set_sound_input_source := LoadDLL('set_sound_input_source');
start_sound_input := LoadDLL('start_sound_input');
stop_sound_input := LoadDLL('stop_sound_input');
read_sound_input := LoadDLL('read_sound_input');
digi_recorder := LoadDLL('digi_recorder');
lock_sample := LoadDLL('lock_sample');
register_sample_file_type := LoadDLL('register_sample_file_type');
{$ENDIF ALLEGRO_LOADVARIABLE}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -