Initial Commit

This commit is contained in:
Godzil
2019-09-01 21:43:40 +01:00
commit 56b69d2281
176 changed files with 41262 additions and 0 deletions

288
seal-hack/include/audio.bas Normal file
View File

@@ -0,0 +1,288 @@
Attribute VB_Name = "Audio"
'
' $Id: audio.h 1.17 1996/09/25 17:13:02 chasan released $
'
' SEAL Synthetic Audio Library API Interface
'
' Copyright (C) 1995, 1996, 1997, 1998, 1999 Carlos Hasan
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License as published
' by the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.
'
' MICROSOFT VISUAL BASIC INTERFACE FOR WINDOWS 95/NT
'
Option Explicit
' audio system version number
Public Const AUDIO_SYSTEM_VERSION = &H101
' audio capabilities bit fields definitions
Public Const AUDIO_FORMAT_1M08 = &H1
Public Const AUDIO_FORMAT_1S08 = &H2
Public Const AUDIO_FORMAT_1M16 = &H4
Public Const AUDIO_FORMAT_1S16 = &H8
Public Const AUDIO_FORMAT_2M08 = &H10
Public Const AUDIO_FORMAT_2S08 = &H20
Public Const AUDIO_FORMAT_2M16 = &H40
Public Const AUDIO_FORMAT_2S16 = &H80
Public Const AUDIO_FORMAT_4M08 = &H100
Public Const AUDIO_FORMAT_4S08 = &H200
Public Const AUDIO_FORMAT_4M16 = &H400
Public Const AUDIO_FORMAT_4S16 = &H800
' audio format bit fields defines for devices and waveforms
Public Const AUDIO_FORMAT_8BITS = &H0
Public Const AUDIO_FORMAT_16BITS = &H1
Public Const AUDIO_FORMAT_LOOP = &H10
Public Const AUDIO_FORMAT_BIDILOOP = &H20
Public Const AUDIO_FORMAT_REVERSE = &H80
Public Const AUDIO_FORMAT_MONO = &H0
Public Const AUDIO_FORMAT_STEREO = &H100
Public Const AUDIO_FORMAT_FILTER = &H8000
' audio resource limits defines
Public Const AUDIO_MAX_VOICES = 32
Public Const AUDIO_MAX_SAMPLES = 16
Public Const AUDIO_MAX_PATCHES = 128
Public Const AUDIO_MAX_PATTERNS = 256
Public Const AUDIO_MAX_ORDERS = 256
Public Const AUDIO_MAX_NOTES = 96
Public Const AUDIO_MAX_POINTS = 12
Public Const AUDIO_MIN_PERIOD = 1
Public Const AUDIO_MAX_PERIOD = 31999
Public Const AUDIO_MIN_VOLUME = 0
Public Const AUDIO_MAX_VOLUME = 64
Public Const AUDIO_MIN_PANNING = 0
Public Const AUDIO_MAX_PANNING = 255
Public Const AUDIO_MIN_POSITION = 0
Public Const AUDIO_MAX_POSITION = 1048576
Public Const AUDIO_MIN_FREQUENCY = 512
Public Const AUDIO_MAX_FREQUENCY = 524288
' audio error code defines
Public Const AUDIO_ERROR_NONE = 0
Public Const AUDIO_ERROR_INVALHANDLE = 1
Public Const AUDIO_ERROR_INVALPARAM = 2
Public Const AUDIO_ERROR_NOTSUPPORTED = 3
Public Const AUDIO_ERROR_BADDEVICEID = 4
Public Const AUDIO_ERROR_NODEVICE = 5
Public Const AUDIO_ERROR_DEVICEBUSY = 6
Public Const AUDIO_ERROR_BADFORMAT = 7
Public Const AUDIO_ERROR_NOMEMORY = 8
Public Const AUDIO_ERROR_NODRAMMEMORY = 9
Public Const AUDIO_ERROR_FILENOTFOUND = 10
Public Const AUDIO_ERROR_BADFILEFORMAT = 11
Public Const AUDIO_LAST_ERROR = 11
' audio device identifiers
Public Const AUDIO_DEVICE_NONE = 0
Public Const AUDIO_DEVICE_MAPPER = 65535
' audio product identifiers
Public Const AUDIO_PRODUCT_NONE = 0
Public Const AUDIO_PRODUCT_SB = 1
Public Const AUDIO_PRODUCT_SB15 = 2
Public Const AUDIO_PRODUCT_SB20 = 3
Public Const AUDIO_PRODUCT_SBPRO = 4
Public Const AUDIO_PRODUCT_SB16 = 5
Public Const AUDIO_PRODUCT_AWE32 = 6
Public Const AUDIO_PRODUCT_WSS = 7
Public Const AUDIO_PRODUCT_ESS = 8
Public Const AUDIO_PRODUCT_GUS = 9
Public Const AUDIO_PRODUCT_GUSDB = 10
Public Const AUDIO_PRODUCT_GUSMAX = 11
Public Const AUDIO_PRODUCT_IWAVE = 12
Public Const AUDIO_PRODUCT_PAS = 13
Public Const AUDIO_PRODUCT_PAS16 = 14
Public Const AUDIO_PRODUCT_ARIA = 15
Public Const AUDIO_PRODUCT_WINDOWS = 256
Public Const AUDIO_PRODUCT_LINUX = 257
Public Const AUDIO_PRODUCT_SPARC = 258
Public Const AUDIO_PRODUCT_SGI = 259
Public Const AUDIO_PRODUCT_DSOUND = 260
' audio envelope bit fields
Public Const AUDIO_ENVELOPE_ON = &H1
Public Const AUDIO_ENVELOPE_SUSTAIN = &H2
Public Const AUDIO_ENVELOPE_LOOP = &H4
' audio pattern bit fields
Public Const AUDIO_PATTERN_PACKED = &H80
Public Const AUDIO_PATTERN_NOTE = &H1
Public Const AUDIO_PATTERN_SAMPLE = &H2
Public Const AUDIO_PATTERN_VOLUME = &H4
Public Const AUDIO_PATTERN_COMMAND = &H8
Public Const AUDIO_PATTERN_PARAMS = &H10
' audio module bit fields
Public Const AUDIO_MODULE_AMIGA = &H0
Public Const AUDIO_MODULE_LINEAR = &H1
Public Const AUDIO_MODULE_PANNING = &H8000
' FIXME: structures should be byte aligned
' audio capabilities structure
Public Type AudioCaps
wProductId As Integer ' product identifier
szProductName As String * 30 ' product name
dwFormats As Long ' formats supported
End Type
' audio format structure
Public Type AudioInfo
nDeviceId As Long ' device identifier
wFormat As Integer ' playback format
nSampleRate As Integer ' sampling frequency
End Type
' audio waveform structure
Public Type AudioWave
lpData As Long ' data pointer
dwHandle As Long ' waveform handle
dwLength As Long ' waveform length
dwLoopStart As Long ' loop start point
dwLoopEnd As Long ' loop end point
nSampleRate As Integer ' sampling rate
wFormat As Integer ' format bits
End Type
' audio envelope point structure
Public Type AudioPoint
nFrame As Integer ' envelope frame
nValue As Integer ' envelope value
End Type
' audio envelope structure
Public Type AudioEnvelope
aEnvelope(0 To 11) As AudioPoint ' envelope points
nPoints As Byte ' number of points
nSustain As Byte ' sustain point
nLoopStart As Byte ' loop start point
nLoopEnd As Byte ' loop end point
wFlags As Integer ' envelope flags
nSpeed As Integer ' envelope speed
End Type
' audio sample structure
Public Type AudioSample
szSampleName As String * 32 ' sample name
nVolume As Byte ' default volume
nPanning As Byte ' default panning
nRelativeNote As Byte ' relative note
nFinetune As Byte ' finetune
Wave As AudioWave ' waveform handle
End Type
' audio patch structure
Public Type AudioPatch
szPatchName As String * 32 ' patch name
aSampleNumber(0 To 95) As Byte ' multi-sample table
nSamples As Integer ' number of samples
nVibratoType As Byte ' vibrato type
nVibratoSweep As Byte ' vibrato sweep
nVibratoDepth As Byte ' vibrato depth
nVibratoRate As Byte ' vibrato rate
nVolumeFadeout As Integer ' volume fadeout
Volume As AudioEnvelope ' volume envelope
Panning As AudioEnvelope ' panning envelope
aSampleTable As Long ' sample table (pointer)
End Type
' audio pattern structure
Public Type AudioPattern
nPacking As Integer ' packing type
nTracks As Integer ' number of tracks
nRows As Integer ' number of rows
nSize As Integer ' data size
lpData As Long ' data pointer
End Type
' audio module structure
Public Type AudioModule
szModuleName As String * 32 ' module name
wFlags As Integer ' module flags
nOrders As Integer ' number of orders
nRestart As Integer ' restart position
nTracks As Integer ' number of tracks
nPatterns As Integer ' number of patterns
nPatches As Integer ' number of patches
nTempo As Integer ' initial tempo
nBPM As Integer ' initial BPM
aOrderTable(0 To 255) As Byte ' order table
aPanningTable(0 To 31) As Byte ' panning table
aPatternTable As Long ' pattern table (pointer)
aPatchTable As Long ' patch table (pointer)
End Type
' FIXME: how do I define callback functions?
'typedef VOID (AIAPI* LPFNAUDIOWAVE)(LPBYTE, UINT);
'typedef VOID (AIAPI* LPFNAUDIOTIMER)(VOID);
'typedef VOID (AIAPI* LPFNAUDIOCALLBACK)(BYTE, UINT, UINT);
' audio interface API prototypes
Public Declare Function AInitialize Lib "AudioW32" () As Long
Public Declare Function AGetVersion Lib "AudioW32" () As Long
Public Declare Function AGetAudioNumDevs Lib "AudioW32" () As Long
Public Declare Function AGetAudioDevCaps Lib "AudioW32" (ByVal nDeviceId As Long, ByRef lpCaps As AudioCaps) As Long
Public Declare Function AGetErrorText Lib "AudioW32" (ByVal nErrorCode As Long, ByVal lpszText As String, ByVal nSize As Long) As Long
Public Declare Function APingAudio Lib "AudioW32" (ByRef lpnDeviceId As Long) As Long
Public Declare Function AOpenAudio Lib "AudioW32" (ByRef lpInfo As AudioInfo) As Long
Public Declare Function ACloseAudio Lib "AudioW32" () As Long
Public Declare Function AUpdateAudio Lib "AudioW32" () As Long
Public Declare Function AOpenVoices Lib "AudioW32" (ByVal nVoices As Long) As Long
Public Declare Function ACloseVoices Lib "AudioW32" () As Long
Public Declare Function ASetAudioCallback Lib "AudioW32" (ByVal lpfnAudioWave As Long) As Long
Public Declare Function ASetAudioTimerProc Lib "AudioW32" (ByVal lpfnAudioTimer As Long) As Long
Public Declare Function ASetAudioTimerRate Lib "AudioW32" (ByVal nTimerRate As Long) As Long
Public Declare Function AGetAudioDataAvail Lib "AudioW32" () As Long
Public Declare Function ACreateAudioData Lib "AudioW32" (ByRef lpWave As AudioWave) As Long
Public Declare Function ADestroyAudioData Lib "AudioW32" (ByRef lpWave As AudioWave) As Long
Public Declare Function AWriteAudioData Lib "AudioW32" (ByRef lpWave As AudioWave, ByVal dwOffset As Long, ByVal nCount As Long) As Long
Public Declare Function ACreateAudioVoice Lib "AudioW32" (ByRef lphVoice As Long) As Long
Public Declare Function ADestroyAudioVoice Lib "AudioW32" (ByVal hVoice As Long) As Long
Public Declare Function APlayVoice Lib "AudioW32" (ByVal hVoice As Long, ByVal lpWave As Long) As Long
Public Declare Function APrimeVoice Lib "AudioW32" (ByVal hVoice As Long, ByVal lpWave As Long) As Long
Public Declare Function AStartVoice Lib "AudioW32" (ByVal hVoice As Long) As Long
Public Declare Function AStopVoice Lib "AudioW32" (ByVal hVoice As Long) As Long
Public Declare Function ASetVoicePosition Lib "AudioW32" (ByVal hVoice As Long, ByVal dwPosition As Long) As Long
Public Declare Function ASetVoiceFrequency Lib "AudioW32" (ByVal hVoice As Long, ByVal dwFrequency As Long) As Long
Public Declare Function ASetVoiceVolume Lib "AudioW32" (ByVal hVoice As Long, ByVal nVolume As Long) As Long
Public Declare Function ASetVoicePanning Lib "AudioW32" (ByVal hVoice As Long, ByVal nPanning As Long) As Long
Public Declare Function AGetVoicePosition Lib "AudioW32" (ByVal hVoice As Long, ByRef lpdwPosition As Long) As Long
Public Declare Function AGetVoiceFrequency Lib "AudioW32" (ByVal hVoice As Long, ByRef lpdwFrequency As Long) As Long
Public Declare Function AGetVoiceVolume Lib "AudioW32" (ByVal hVoice As Long, ByRef lpnVolume As Long) As Long
Public Declare Function AGetVoicePanning Lib "AudioW32" (ByVal hVoice As Long, ByRef lpnPanning As Long) As Long
Public Declare Function AGetVoiceStatus Lib "AudioW32" (ByVal hVoice As Long, ByRef lpnStatus As Long) As Long
Public Declare Function APlayModule Lib "AudioW32" (ByVal lpModule As Long) As Long
Public Declare Function AStopModule Lib "AudioW32" () As Long
Public Declare Function APauseModule Lib "AudioW32" () As Long
Public Declare Function AResumeModule Lib "AudioW32" () As Long
Public Declare Function ASetModuleVolume Lib "AudioW32" (ByVal nVolume As Long) As Long
Public Declare Function ASetModulePosition Lib "AudioW32" (ByVal nOrder As Long, ByVal nRow As Long) As Long
Public Declare Function AGetModuleVolume Lib "AudioW32" (ByVal lpnVolume As Long) As Long
Public Declare Function AGetModulePosition Lib "AudioW32" (ByRef pnOrder As Long, ByRef lpnRow As Long) As Long
Public Declare Function AGetModuleStatus Lib "AudioW32" (ByRef lpnStatus As Long) As Long
Public Declare Function ASetModuleCallback Lib "AudioW32" (ByVal lpfnAudioCallback As Long) As Long
' FIXME: how do I define pointers to AudioModule and AudioWave?
Public Declare Function ALoadModuleFile Lib "AudioW32" (ByVal lpszFileName As String, ByRef lplpModule As Long, ByVal dwFileOffset As Long) As Long
Public Declare Function AFreeModuleFile Lib "AudioW32" (ByVal lpModule As Long) As Long
Public Declare Function ALoadWaveFile Lib "AudioW32" (ByVal lpszFileName As String, ByRef lplpWave As Long, ByVal dwFileOffset As Long) As Long
Public Declare Function AFreeWaveFile Lib "AudioW32" (ByVal lpWave As Long) As Long

377
seal-hack/include/audio.h Normal file
View File

@@ -0,0 +1,377 @@
/*
* $Id: audio.h 1.17 1996/09/25 17:13:02 chasan released $
* 1.18 1998/10/12 23:54:08 chasan released
* 1.19 1998/10/24 18:20:52 chasan released
* 1.20 1999/06/27 17:49:49 chasan released
*
* SEAL Synthetic Audio Library API Interface
*
* Copyright (C) 1995, 1996, 1997, 1998, 1999 Carlos Hasan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef __AUDIO_H
#define __AUDIO_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WIN32
#define AIAPI
#else
#define AIAPI __stdcall
#endif
#ifndef WINAPI
/* atomic data types definitions */
typedef void VOID;
typedef char CHAR;
typedef int INT;
typedef long LONG;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int UINT;
typedef unsigned long DWORD;
typedef VOID* LPVOID;
typedef CHAR* LPCHAR;
typedef INT* LPINT;
typedef LONG* LPLONG;
typedef BOOL* LPBOOL;
typedef BYTE* LPBYTE;
typedef WORD* LPWORD;
typedef UINT* LPUINT;
typedef DWORD* LPDWORD;
typedef CHAR* LPSTR;
typedef DWORD HANDLE;
/* helper macros */
#define LOBYTE(s) ((BYTE)(s))
#define HIBYTE(s) ((BYTE)((WORD)(s)>>8))
#define LOWORD(l) ((WORD)(l))
#define HIWORD(l) ((WORD)((DWORD)(l)>>16))
#define MAKEWORD(l,h) ((WORD)(((BYTE)(l))|(((WORD)((BYTE)(h)))<<8)))
#define MAKELONG(l,h) ((DWORD)(((WORD)(l))|(((DWORD)((WORD)(h)))<<16)))
#endif
/* audio system version number */
#define AUDIO_SYSTEM_VERSION 0x0106
/* audio capabilities bit fields definitions */
#define AUDIO_FORMAT_1M08 0x00000001
#define AUDIO_FORMAT_1S08 0x00000002
#define AUDIO_FORMAT_1M16 0x00000004
#define AUDIO_FORMAT_1S16 0x00000008
#define AUDIO_FORMAT_2M08 0x00000010
#define AUDIO_FORMAT_2S08 0x00000020
#define AUDIO_FORMAT_2M16 0x00000040
#define AUDIO_FORMAT_2S16 0x00000080
#define AUDIO_FORMAT_4M08 0x00000100
#define AUDIO_FORMAT_4S08 0x00000200
#define AUDIO_FORMAT_4M16 0x00000400
#define AUDIO_FORMAT_4S16 0x00000800
/* audio format bit fields defines for devices and waveforms */
#define AUDIO_FORMAT_8BITS 0x0000
#define AUDIO_FORMAT_16BITS 0x0001
#define AUDIO_FORMAT_LOOP 0x0010
#define AUDIO_FORMAT_BIDILOOP 0x0020
#define AUDIO_FORMAT_REVERSE 0x0080
#define AUDIO_FORMAT_MONO 0x0000
#define AUDIO_FORMAT_STEREO 0x0100
#define AUDIO_FORMAT_FILTER 0x8000
/* audio resource limits defines */
#define AUDIO_MAX_VOICES 32
#define AUDIO_MAX_SAMPLES 16
#define AUDIO_MAX_PATCHES 128
#define AUDIO_MAX_PATTERNS 256
#define AUDIO_MAX_ORDERS 256
#define AUDIO_MAX_NOTES 96
#define AUDIO_MAX_POINTS 12
#define AUDIO_MIN_PERIOD 1
#define AUDIO_MAX_PERIOD 31999
#define AUDIO_MIN_VOLUME 0x00
#define AUDIO_MAX_VOLUME 0x40
#define AUDIO_MIN_PANNING 0x00
#define AUDIO_MAX_PANNING 0xFF
#define AUDIO_MIN_POSITION 0x00000000L
#define AUDIO_MAX_POSITION 0x00100000L
#define AUDIO_MIN_FREQUENCY 0x00000200L
#define AUDIO_MAX_FREQUENCY 0x00080000L
/* audio error code defines */
#define AUDIO_ERROR_NONE 0x0000
#define AUDIO_ERROR_INVALHANDLE 0x0001
#define AUDIO_ERROR_INVALPARAM 0x0002
#define AUDIO_ERROR_NOTSUPPORTED 0x0003
#define AUDIO_ERROR_BADDEVICEID 0x0004
#define AUDIO_ERROR_NODEVICE 0x0005
#define AUDIO_ERROR_DEVICEBUSY 0x0006
#define AUDIO_ERROR_BADFORMAT 0x0007
#define AUDIO_ERROR_NOMEMORY 0x0008
#define AUDIO_ERROR_NODRAMMEMORY 0x0009
#define AUDIO_ERROR_FILENOTFOUND 0x000A
#define AUDIO_ERROR_BADFILEFORMAT 0x000B
#define AUDIO_LAST_ERROR 0x000B
/* audio device identifiers */
#define AUDIO_DEVICE_NONE 0x0000
#define AUDIO_DEVICE_MAPPER 0xFFFF
/* audio product identifiers */
#define AUDIO_PRODUCT_NONE 0x0000
#define AUDIO_PRODUCT_SB 0x0001
#define AUDIO_PRODUCT_SB15 0x0002
#define AUDIO_PRODUCT_SB20 0x0003
#define AUDIO_PRODUCT_SBPRO 0x0004
#define AUDIO_PRODUCT_SB16 0x0005
#define AUDIO_PRODUCT_AWE32 0x0006
#define AUDIO_PRODUCT_WSS 0x0007
#define AUDIO_PRODUCT_ESS 0x0008
#define AUDIO_PRODUCT_GUS 0x0009
#define AUDIO_PRODUCT_GUSDB 0x000A
#define AUDIO_PRODUCT_GUSMAX 0x000B
#define AUDIO_PRODUCT_IWAVE 0x000C
#define AUDIO_PRODUCT_PAS 0x000D
#define AUDIO_PRODUCT_PAS16 0x000E
#define AUDIO_PRODUCT_ARIA 0x000F
#define AUDIO_PRODUCT_WINDOWS 0x0100
#define AUDIO_PRODUCT_LINUX 0x0101
#define AUDIO_PRODUCT_SPARC 0x0102
#define AUDIO_PRODUCT_SGI 0x0103
#define AUDIO_PRODUCT_DSOUND 0x0104
#define AUDIO_PRODUCT_OS2MMPM 0x0105
#define AUDIO_PRODUCT_OS2DART 0x0106
#define AUDIO_PRODUCT_BEOSR3 0x0107
#define AUDIO_PRODUCT_BEOS 0x0108
#define AUDIO_PRODUCT_QNX 0x0109
/* audio mixer channels */
#define AUDIO_MIXER_MASTER_VOLUME 0x0001
#define AUDIO_MIXER_TREBLE 0x0002
#define AUDIO_MIXER_BASS 0x0003
#define AUDIO_MIXER_CHORUS 0x0004
#define AUDIO_MIXER_REVERB 0x0005
/* audio envelope bit fields */
#define AUDIO_ENVELOPE_ON 0x0001
#define AUDIO_ENVELOPE_SUSTAIN 0x0002
#define AUDIO_ENVELOPE_LOOP 0x0004
/* audio pattern bit fields */
#define AUDIO_PATTERN_PACKED 0x0080
#define AUDIO_PATTERN_NOTE 0x0001
#define AUDIO_PATTERN_SAMPLE 0x0002
#define AUDIO_PATTERN_VOLUME 0x0004
#define AUDIO_PATTERN_COMMAND 0x0008
#define AUDIO_PATTERN_PARAMS 0x0010
/* audio module bit fields */
#define AUDIO_MODULE_AMIGA 0x0000
#define AUDIO_MODULE_LINEAR 0x0001
#define AUDIO_MODULE_PANNING 0x8000
#pragma pack(1)
/* audio capabilities structure */
typedef struct {
WORD wProductId; /* product identifier */
CHAR szProductName[30]; /* product name */
DWORD dwFormats; /* formats supported */
} AUDIOCAPS, *LPAUDIOCAPS;
/* audio format structure */
typedef struct {
UINT nDeviceId; /* device identifier */
WORD wFormat; /* playback format */
WORD nSampleRate; /* sampling frequency */
} AUDIOINFO, *LPAUDIOINFO;
/* audio waveform structure */
typedef struct {
LPBYTE lpData; /* data pointer */
DWORD dwHandle; /* waveform handle */
DWORD dwLength; /* waveform length */
DWORD dwLoopStart; /* loop start point */
DWORD dwLoopEnd; /* loop end point */
WORD nSampleRate; /* sampling rate */
WORD wFormat; /* format bits */
} AUDIOWAVE, *LPAUDIOWAVE;
/* audio envelope point structure */
typedef struct {
WORD nFrame; /* envelope frame */
WORD nValue; /* envelope value */
} AUDIOPOINT, *LPAUDIOPOINT;
/* audio envelope structure */
typedef struct {
AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS]; /* envelope points */
BYTE nPoints; /* number of points */
BYTE nSustain; /* sustain point */
BYTE nLoopStart; /* loop start point */
BYTE nLoopEnd; /* loop end point */
WORD wFlags; /* envelope flags */
WORD nSpeed; /* envelope speed */
} AUDIOENVELOPE, *LPAUDIOENVELOPE;
/* audio sample structure */
typedef struct {
CHAR szSampleName[32]; /* sample name */
BYTE nVolume; /* default volume */
BYTE nPanning; /* default panning */
BYTE nRelativeNote; /* relative note */
BYTE nFinetune; /* finetune */
AUDIOWAVE Wave; /* waveform handle */
} AUDIOSAMPLE, *LPAUDIOSAMPLE;
/* audio patch structure */
typedef struct {
CHAR szPatchName[32]; /* patch name */
BYTE aSampleNumber[AUDIO_MAX_NOTES]; /* multi-sample table */
WORD nSamples; /* number of samples */
BYTE nVibratoType; /* vibrato type */
BYTE nVibratoSweep; /* vibrato sweep */
BYTE nVibratoDepth; /* vibrato depth */
BYTE nVibratoRate; /* vibrato rate */
WORD nVolumeFadeout; /* volume fadeout */
AUDIOENVELOPE Volume; /* volume envelope */
AUDIOENVELOPE Panning; /* panning envelope */
LPAUDIOSAMPLE aSampleTable; /* sample table */
} AUDIOPATCH, *LPAUDIOPATCH;
/* audio pattern structure */
typedef struct {
WORD nPacking; /* packing type */
WORD nTracks; /* number of tracks */
WORD nRows; /* number of rows */
WORD nSize; /* data size */
LPBYTE lpData; /* data pointer */
} AUDIOPATTERN, *LPAUDIOPATTERN;
/* audio module structure */
typedef struct {
CHAR szModuleName[32]; /* module name */
WORD wFlags; /* module flags */
WORD nOrders; /* number of orders */
WORD nRestart; /* restart position */
WORD nTracks; /* number of tracks */
WORD nPatterns; /* number of patterns */
WORD nPatches; /* number of patches */
WORD nTempo; /* initial tempo */
WORD nBPM; /* initial BPM */
BYTE aOrderTable[AUDIO_MAX_ORDERS]; /* order table */
BYTE aPanningTable[AUDIO_MAX_VOICES]; /* panning table */
LPAUDIOPATTERN aPatternTable; /* pattern table */
LPAUDIOPATCH aPatchTable; /* patch table */
} AUDIOMODULE, *LPAUDIOMODULE;
/* audio music track structure */
typedef struct {
BYTE nNote; /* note index */
BYTE nPatch; /* patch number */
BYTE nSample; /* sample number */
BYTE nCommand; /* effect command */
BYTE bParams; /* effect params */
BYTE nVolumeCmd; /* volume command */
BYTE nVolume; /* volume level */
BYTE nPanning; /* stereo panning */
LONG dwFrequency; /* note frequency */
WORD wPeriod; /* note period */
} AUDIOTRACK, *LPAUDIOTRACK;
/* audio callback function defines */
typedef VOID (AIAPI* LPFNAUDIOWAVE)(LPBYTE, UINT);
typedef VOID (AIAPI* LPFNAUDIOTIMER)();
typedef VOID (AIAPI* LPFNAUDIOCALLBACK)(BYTE, UINT, UINT);
/* audio handle defines */
typedef HANDLE HAC;
typedef HAC* LPHAC;
#pragma pack()
/* audio interface API prototypes */
UINT AIAPI AInitialize();
UINT AIAPI AGetVersion();
UINT AIAPI AGetAudioNumDevs();
UINT AIAPI AGetAudioDevCaps(UINT nDeviceId, LPAUDIOCAPS lpCaps);
UINT AIAPI AGetErrorText(UINT nErrorCode, LPSTR lpText, UINT nSize);
UINT AIAPI APingAudio(LPUINT lpnDeviceId);
UINT AIAPI AOpenAudio(LPAUDIOINFO lpInfo);
UINT AIAPI ACloseAudio();
UINT AIAPI AUpdateAudio();
UINT AIAPI AUpdateAudioEx(UINT nFrames);
UINT AIAPI ASetAudioMixerValue(UINT nChannel, UINT nValue);
UINT AIAPI AOpenVoices(UINT nVoices);
UINT AIAPI ACloseVoices();
UINT AIAPI ASetAudioCallback(LPFNAUDIOWAVE lpfnAudioWave);
UINT AIAPI ASetAudioTimerProc(LPFNAUDIOTIMER lpfnAudioTimer);
UINT AIAPI ASetAudioTimerRate(UINT nTimerRate);
LONG AIAPI AGetAudioDataAvail();
UINT AIAPI ACreateAudioData(LPAUDIOWAVE lpWave);
UINT AIAPI ADestroyAudioData(LPAUDIOWAVE lpWave);
UINT AIAPI AWriteAudioData(LPAUDIOWAVE lpWave, DWORD dwOffset, UINT nCount);
UINT AIAPI ACreateAudioVoice(LPHAC lphVoice);
UINT AIAPI ADestroyAudioVoice(HAC hVoice);
UINT AIAPI APlayVoice(HAC hVoice, LPAUDIOWAVE lpWave);
UINT AIAPI APrimeVoice(HAC hVoice, LPAUDIOWAVE lpWave);
UINT AIAPI AStartVoice(HAC hVoice);
UINT AIAPI AStopVoice(HAC hVoice);
UINT AIAPI ASetVoicePosition(HAC hVoice, LONG dwPosition);
UINT AIAPI ASetVoiceFrequency(HAC hVoice, LONG dwFrequency);
UINT AIAPI ASetVoiceVolume(HAC hVoice, UINT nVolume);
UINT AIAPI ASetVoicePanning(HAC hVoice, UINT nPanning);
UINT AIAPI AGetVoicePosition(HAC hVoice, LPLONG lpdwPosition);
UINT AIAPI AGetVoiceFrequency(HAC hVoice, LPLONG lpdwFrequency);
UINT AIAPI AGetVoiceVolume(HAC hVoice, LPUINT lpnVolume);
UINT AIAPI AGetVoicePanning(HAC hVoice, LPUINT lpnPanning);
UINT AIAPI AGetVoiceStatus(HAC hVoice, LPBOOL lpnStatus);
UINT AIAPI APlayModule(LPAUDIOMODULE lpModule);
UINT AIAPI AStopModule();
UINT AIAPI APauseModule();
UINT AIAPI AResumeModule();
UINT AIAPI ASetModuleVolume(UINT nVolume);
UINT AIAPI ASetModulePosition(UINT nOrder, UINT nRow);
UINT AIAPI AGetModuleVolume(LPUINT lpnVolume);
UINT AIAPI AGetModulePosition(LPUINT pnOrder, LPUINT lpnRow);
UINT AIAPI AGetModuleStatus(LPBOOL lpnStatus);
UINT AIAPI ASetModuleCallback(LPFNAUDIOCALLBACK lpfnAudioCallback);
UINT AIAPI ALoadModuleFile(LPSTR lpszFileName,
LPAUDIOMODULE* lplpModule, DWORD dwFileOffset);
UINT AIAPI AFreeModuleFile(LPAUDIOMODULE lpModule);
UINT AIAPI ALoadWaveFile(LPSTR lpszFileName,
LPAUDIOWAVE* lplpWave, DWORD dwFileOffset);
UINT AIAPI AFreeWaveFile(LPAUDIOWAVE lpWave);
UINT AIAPI AGetModuleTrack(UINT nTrack, LPAUDIOTRACK lpTrack);
#ifdef __cplusplus
};
#endif
#endif

950
seal-hack/include/audio.pas Normal file
View File

@@ -0,0 +1,950 @@
{*
* $Id: audio.h 1.16 1996/09/25 13:09:09 chasan released $
*
* SEAL Synthetic Audio Library API Interface
*
* Copyright (C) 1995-1999 Carlos Hasan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*}
unit Audio;
interface
uses
SysUtils, Windows;
const
{ audio system version number }
AUDIO_SYSTEM_VERSION = $0101;
{ audio capabilities bit fields definitions }
AUDIO_FORMAT_1M08 = $00000001;
AUDIO_FORMAT_1S08 = $00000002;
AUDIO_FORMAT_1M16 = $00000004;
AUDIO_FORMAT_1S16 = $00000008;
AUDIO_FORMAT_2M08 = $00000010;
AUDIO_FORMAT_2S08 = $00000020;
AUDIO_FORMAT_2M16 = $00000040;
AUDIO_FORMAT_2S16 = $00000080;
AUDIO_FORMAT_4M08 = $00000100;
AUDIO_FORMAT_4S08 = $00000200;
AUDIO_FORMAT_4M16 = $00000400;
AUDIO_FORMAT_4S16 = $00000800;
{ audio format bit fields defines for devices and waveforms }
AUDIO_FORMAT_8BITS = $0000;
AUDIO_FORMAT_16BITS = $0001;
AUDIO_FORMAT_LOOP = $0010;
AUDIO_FORMAT_BIDILOOP = $0020;
AUDIO_FORMAT_REVERSE = $0080;
AUDIO_FORMAT_MONO = $0000;
AUDIO_FORMAT_STEREO = $0100;
AUDIO_FORMAT_FILTER = $8000;
{ audio resource limits defines }
AUDIO_MAX_VOICES = 32;
AUDIO_MAX_SAMPLES = 16;
AUDIO_MAX_PATCHES = 128;
AUDIO_MAX_PATTERNS = 256;
AUDIO_MAX_ORDERS = 256;
AUDIO_MAX_NOTES = 96;
AUDIO_MAX_POINTS = 12;
AUDIO_MIN_PERIOD = 1;
AUDIO_MAX_PERIOD = 31999;
AUDIO_MIN_VOLUME = $00;
AUDIO_MAX_VOLUME = $40;
AUDIO_MIN_PANNING = $00;
AUDIO_MAX_PANNING = $FF;
AUDIO_MIN_POSITION = $00000000;
AUDIO_MAX_POSITION = $00100000;
AUDIO_MIN_FREQUENCY = $00000200;
AUDIO_MAX_FREQUENCY = $00080000;
{ audio error code defines }
AUDIO_ERROR_NONE = $0000;
AUDIO_ERROR_INVALHANDLE = $0001;
AUDIO_ERROR_INVALPARAM = $0002;
AUDIO_ERROR_NOTSUPPORTED = $0003;
AUDIO_ERROR_BADDEVICEID = $0004;
AUDIO_ERROR_NODEVICE = $0005;
AUDIO_ERROR_DEVICEBUSY = $0006;
AUDIO_ERROR_BADFORMAT = $0007;
AUDIO_ERROR_NOMEMORY = $0008;
AUDIO_ERROR_NODRAMMEMORY = $0009;
AUDIO_ERROR_FILENOTFOUND = $000A;
AUDIO_ERROR_BADFILEFORMAT = $000B;
AUDIO_LAST_ERROR = $000B;
{ audio device identifiers }
AUDIO_DEVICE_NONE = $0000;
AUDIO_DEVICE_MAPPER = $FFFF;
{ audio product identifiers }
AUDIO_PRODUCT_NONE = $0000;
AUDIO_PRODUCT_SB = $0001;
AUDIO_PRODUCT_SB15 = $0002;
AUDIO_PRODUCT_SB20 = $0003;
AUDIO_PRODUCT_SBPRO = $0004;
AUDIO_PRODUCT_SB16 = $0005;
AUDIO_PRODUCT_AWE32 = $0006;
AUDIO_PRODUCT_WSS = $0007;
AUDIO_PRODUCT_ESS = $0008;
AUDIO_PRODUCT_GUS = $0009;
AUDIO_PRODUCT_GUSDB = $000A;
AUDIO_PRODUCT_GUSMAX = $000B;
AUDIO_PRODUCT_IWAVE = $000C;
AUDIO_PRODUCT_PAS = $000D;
AUDIO_PRODUCT_PAS16 = $000E;
AUDIO_PRODUCT_ARIA = $000F;
AUDIO_PRODUCT_WINDOWS = $0100;
AUDIO_PRODUCT_LINUX = $0101;
AUDIO_PRODUCT_SPARC = $0102;
AUDIO_PRODUCT_SGI = $0103;
AUDIO_PRODUCT_DSOUND = $0104;
{ audio envelope bit fields }
AUDIO_ENVELOPE_ON = $0001;
AUDIO_ENVELOPE_SUSTAIN = $0002;
AUDIO_ENVELOPE_LOOP = $0004;
{ audio pattern bit fields }
AUDIO_PATTERN_PACKED = $0080;
AUDIO_PATTERN_NOTE = $0001;
AUDIO_PATTERN_SAMPLE = $0002;
AUDIO_PATTERN_VOLUME = $0004;
AUDIO_PATTERN_COMMAND = $0008;
AUDIO_PATTERN_PARAMS = $0010;
{ audio module bit fields }
AUDIO_MODULE_AMIGA = $0000;
AUDIO_MODULE_LINEAR = $0001;
AUDIO_MODULE_PANNING = $8000;
type
{ audio capabilities structure }
PAudioCaps = ^TAudioCaps;
TAudioCaps = record
wProductId : Word; { product identifier }
szProductName : Array [0..29] of Char; { product name }
dwFormats : Longint; { formats supported }
end;
{ audio format structure }
PAudioInfo = ^TAudioInfo;
TAudioInfo = record
nDeviceId : Integer; { device identifier }
wFormat : Word; { playback format }
nSampleRate : Word; { sampling rate }
end;
{ audio waveform structure }
PAudioWave = ^TAudioWave;
TAudioWave = record
pData : Pointer; { data pointer }
dwHandle : Longint; { waveform handle }
dwLength : Longint; { waveform length }
dwLoopStart : Longint; { loop start point }
dwLoopEnd : Longint; { loop end point }
nSampleRate : Word; { sampling rate }
wFormat : Word; { format bits }
end;
{ audio envelope point structure }
PAudioPoint = ^TAudioPoint;
TAudioPoint = record
nFrame : Word; { envelope frame }
nValue : Word; { envelope value }
end;
{ audio envelope structure }
PAudioEnvelope = ^TAudioEnvelope;
TAudioEnvelope = record
aEnvelope : Array [1..AUDIO_MAX_POINTS] of TAudioPoint; { envelope points }
nPoints : Byte; { number of points }
nSustain : Byte; { sustain point }
nLoopStart : Byte; { loop start point }
nLoopEnd : Byte; { loop end point }
wFlags : Word; { envelope flags }
nSpeed : Word; { envelope speed }
end;
{ audio sample structure }
PAudioSample = ^TAudioSample;
TAudioSample = record
szSampleName : Array [0..31] of Char; { sample name }
nVolume : Byte; { default volume }
nPanning : Byte; { default panning }
nRelativeNote : Byte; { relative note }
nFinetune : Byte; { finetune }
Wave : TAudioWave; { waveform handle }
end;
{ audio patch structure }
PAudioPatch = ^TAudioPatch;
TAudioPatch = record
szPatchName : Array [0..31] of Char; { patch name }
aSampleNumber : Array [1..AUDIO_MAX_NOTES] of Byte; { multi-sample table }
nSamples : Word; { number of samples }
nVibratoType : Byte; { vibrato type }
nVibratoSweep : Byte; { vibrato sweep }
nVibratoDepth : Byte; { vibrato depth }
nVibratoRate : Byte; { vibrato rate }
nVolumeFadeout : Word; { volume fadeout }
Volume : TAudioEnvelope; { volume envelope }
Panning : TAudioEnvelope; { panning envelope }
aSampleTable : PAudioSample; { sample table }
end;
{ audio pattern structure }
PAudioPattern = ^TAudioPattern;
TAudioPattern = record
nPacking : Word; { packing type }
nTracks : Word; { number of tracks }
nRows : Word; { number of rows }
nSize : Word; { data size }
pData : Pointer; { data pointer }
end;
{ audio module structure }
PAudioModule = ^TAudioModule;
TAudioModule = record
szModuleName : Array [0..31] of Char; { module name }
wFlags : Word; { module flags }
nOrders : Word; { number of orders }
nRestart : Word; { restart position }
nTracks : Word; { number of tracks }
nPatterns : Word; { number of patterns }
nPatches : Word; { number of patches }
nTempo : Word; { initial tempo }
nBPM : Word; { initial BPM }
aOrderTable : Array [1..AUDIO_MAX_ORDERS] of Byte; { order table }
aPanningTable : Array [1..AUDIO_MAX_VOICES] of Byte; { panning table }
aPatternTable : PAudioPattern; { pattern table }
aPatchTable : PAudioPatch; { patch table }
end;
{ audio callback function defines }
TAudioWaveProc = procedure (pData: Pointer; nCount: Integer); stdcall;
TAudioTimerProc = procedure; stdcall;
TAudioCallback = procedure(nSyncMark: Byte; nOrder, nRow: Integer); stdcall;
{ audio handle defines }
PHAC = ^HAC;
HAC = Integer;
{ audio interface API prototypes }
function AInitialize: Integer; stdcall;
function AGetVersion: Integer; stdcall;
function AGetAudioNumDevs: Integer; stdcall;
function AGetAudioDevCaps(nDeviceId: Integer; var pCaps: TAudioCaps): Integer; stdcall;
function AGetErrorText(nErrorCode: Integer; pText: PChar; nSize: Integer): Integer; stdcall;
function APingAudio(var pnDeviceId: Integer): Integer; stdcall;
function AOpenAudio(var pInfo: TAudioInfo): Integer; stdcall;
function ACloseAudio: Integer; stdcall;
function AUpdateAudio: Integer; stdcall;
function AOpenVoices(nVoices: Integer): Integer; stdcall;
function ACloseVoices: Integer; stdcall;
function ASetAudioCallback(pfnWaveProc: TAudioWaveProc): Integer; stdcall;
function ASetAudioTimerProc(pfnTimerProc: TAudioTimerProc): Integer; stdcall;
function ASetAudioTimerRate(nTimerRate: Integer): Integer; stdcall;
function AGetAudioDataAvail: Longint; stdcall;
function ACreateAudioData(pWave: PAudioWave): Integer; stdcall;
function ADestroyAudioData(pWave: PAudioWave): Integer; stdcall;
function AWriteAudioData(pWave: PAudioWave; dwOffset: Longint; nCount: Integer): Integer; stdcall;
function ACreateAudioVoice(var phVoice: HAC): Integer; stdcall;
function ADestroyAudioVoice(hVoice: HAC): Integer; stdcall;
function APlayVoice(hVoice: HAC; pWave: PAudioWave): Integer; stdcall;
function APrimeVoice(hVoice: HAC; pWave: PAudioWave): Integer; stdcall;
function AStartVoice(hVoice: HAC): Integer; stdcall;
function AStopVoice(hVoice: HAC): Integer; stdcall;
function ASetVoicePosition(hVoice: HAC; dwPosition: Longint): Integer; stdcall;
function ASetVoiceFrequency(hVoice: HAC; dwFrequency: Longint): Integer; stdcall;
function ASetVoiceVolume(hVoice: HAC; nVolume: Integer): Integer; stdcall;
function ASetVoicePanning(hVoice: HAC; nPanning: Integer): Integer; stdcall;
function AGetVoicePosition(hVoice: HAC; var pdwPosition: Longint): Integer; stdcall;
function AGetVoiceFrequency(hVoice: HAC; var pdwFrequency: Longint): Integer; stdcall;
function AGetVoiceVolume(hVoice: HAC; var pnVolume: Integer): Integer; stdcall;
function AGetVoicePanning(hVoice: HAC; var pnPanning: Integer): Integer; stdcall;
function AGetVoiceStatus(hVoice: HAC; var pnStatus: Integer): Integer; stdcall;
function APlayModule(pModule: PAudioModule): Integer; stdcall;
function AStopModule: Integer; stdcall;
function APauseModule: Integer; stdcall;
function AResumeModule: Integer; stdcall;
function ASetModuleVolume(nVolume: Integer): Integer; stdcall;
function ASetModulePosition(nOrder, nRow: Integer): Integer; stdcall;
function AGetModuleVolume(var pnVolume: Integer): Integer; stdcall;
function AGetModulePosition(var pnOrder, pnRow: Integer): Integer; stdcall;
function AGetModuleStatus(var pnStatus: Integer): Integer; stdcall;
function ASetModuleCallback(pfnAudioCallback: TAudioCallback): Integer; stdcall;
function ALoadModuleFile(pszFileName: PChar; var ppModule: PAudioModule; FileOffset: Longint): Integer; stdcall;
function AFreeModuleFile(pModule: PAudioModule): Integer; stdcall;
function ALoadWaveFile(pszFileName: PChar; var ppWave: PAudioWave; FileOffset: Longint): Integer; stdcall;
function AFreeWaveFile(pWave: PAudioWave): Integer; stdcall;
type
TAudio = class(TObject)
constructor Create(Format: Word; SampleRate: Word);
destructor Destroy; override;
procedure Update;
private
FInfo: TAudioInfo;
function GetProductId: Integer;
function GetProductName: String;
public
property DeviceId: Integer read FInfo.nDeviceId;
property ProductId: Integer read GetProductId;
property ProductName: String read GetProductName;
property Format: Word read FInfo.wFormat;
property SampleRate: Word read FInfo.nSampleRate;
end;
TWaveform = class(TObject)
constructor Create(Format: Word; SampleRate: Word;
Length, LoopStart, LoopEnd: Longint);
constructor LoadFromFile(FileName: String);
destructor Destroy; override;
procedure Write(var Buffer; Count: Integer);
private
FHandle: TAudioWave;
PHandle: PAudioWave;
FVolume: Integer;
FPanning: Integer;
FPosition: Longint;
function GetHandle: PAudioWave;
procedure SetSampleRate(Value: Word);
procedure SetVolume(Value: Integer);
procedure SetPanning(Value: Integer);
procedure SetPosition(Value: LongInt);
public
property Handle: PAudioWave read GetHandle;
property Format: Word read FHandle.wFormat;
property Length: Longint read FHandle.dwLength;
property LoopStart: Longint read FHandle.dwLoopStart;
property LoopEnd: Longint read FHandle.dwLoopEnd;
property SampleRate: Word read FHandle.nSampleRate write SetSampleRate;
property Volume: Integer read FVolume write SetVolume;
property Panning: Integer read FPanning write SetPanning;
property Position: Longint read FPosition write SetPosition;
end;
TVoice = class(TObject)
constructor Create;
destructor Destroy; override;
procedure Prime(Wave: TWaveform);
procedure Play(Wave: TWaveform);
procedure Start;
procedure Stop;
private
FHandle: HAC;
FWave: TWaveform;
function GetHandle: HAC;
function GetWaveform: TWaveform;
function GetPosition: Longint;
procedure SetPosition(Value: Longint);
function GetFrequency: Longint;
procedure SetFrequency(Value: Longint);
function GetVolume: Integer;
procedure SetVolume(Value: Integer);
function GetPanning: Integer;
procedure SetPanning(Value: Integer);
function GetStopped: Boolean;
public
property Handle: HAC read GetHandle;
property Waveform: TWaveform read GetWaveform;
property Position: Longint read GetPosition write SetPosition;
property Frequency: Longint read GetFrequency write SetFrequency;
property Volume: Integer read GetVolume write SetVolume;
property Panning: Integer read GetPanning write SetPanning;
property Stopped: Boolean read GetStopped;
end;
TModule = class(TObject)
constructor LoadFromFile(FileName: String);
destructor Destroy; override;
procedure Play;
procedure Stop;
procedure Pause;
procedure Resume;
private
FHandle: PAudioModule;
FCallback: TAudioCallback;
function GetVolume: Integer;
procedure SetVolume(Value: Integer);
function GetOrder: Integer;
procedure SetOrder(Value: Integer);
function GetRow: Integer;
procedure SetRow(Value: Integer);
function GetStopped: Boolean;
procedure SetCallback(Value: TAudioCallback);
public
property Handle: PAudioModule read FHandle;
property Volume: Integer read GetVolume write SetVolume;
property Order: Integer read GetOrder write SetOrder;
property Row: Integer read GetRow write SetRow;
property Stopped: Boolean read GetStopped;
property OnSync: TAudioCallback read FCallback write SetCallback;
private
function GetName: String;
function GetNumOrders: Integer;
function GetNumTracks: Integer;
function GetNumPatterns: Integer;
function GetNumPatches: Integer;
function GetPatch(Index: Integer): PAudioPatch;
public
property Name: String read GetName;
property NumOrders: Integer read GetNumOrders;
property NumTracks: Integer read GetNumTracks;
property NumPatterns: Integer read GetNumPatterns;
property NumPatches: Integer read GetNumPatches;
property Patch[Index: Integer]: PAudioPatch read GetPatch;
end;
implementation
function AInitialize: Integer; stdcall; external 'AUDIOW32.DLL';
function AGetVersion: Integer; stdcall; external 'AUDIOW32.DLL';
function AGetAudioNumDevs: Integer; stdcall; external 'AUDIOW32.DLL';
function AGetAudioDevCaps(nDeviceId: Integer; var pCaps: TAudioCaps): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetErrorText(nErrorCode: Integer; pText: PChar; nSize: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function APingAudio(var pnDeviceId: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AOpenAudio(var pInfo: TAudioInfo): Integer; stdcall; external 'AUDIOW32.DLL';
function ACloseAudio: Integer; stdcall; external 'AUDIOW32.DLL';
function AUpdateAudio: Integer; stdcall; external 'AUDIOW32.DLL';
function AOpenVoices(nVoices: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function ACloseVoices: Integer; stdcall; external 'AUDIOW32.DLL';
function ASetAudioCallback(pfnWaveProc: TAudioWaveProc): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetAudioTimerProc(pfnTimerProc: TAudioTimerProc): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetAudioTimerRate(nTimerRate: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetAudioDataAvail: Longint; stdcall; external 'AUDIOW32.DLL';
function ACreateAudioData(pWave: PAudioWave): Integer; stdcall; external 'AUDIOW32.DLL';
function ADestroyAudioData(pWave: PAudioWave): Integer; stdcall; external 'AUDIOW32.DLL';
function AWriteAudioData(pWave: PAudioWave; dwOffset: Longint; nCount: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function ACreateAudioVoice(var phVoice: HAC): Integer; stdcall; external 'AUDIOW32.DLL';
function ADestroyAudioVoice(hVoice: HAC): Integer; stdcall; external 'AUDIOW32.DLL';
function APlayVoice(hVoice: HAC; pWave: PAudioWave): Integer; stdcall; external 'AUDIOW32.DLL';
function APrimeVoice(hVoice: HAC; pWave: PAudioWave): Integer; stdcall; external 'AUDIOW32.DLL';
function AStartVoice(hVoice: HAC): Integer; stdcall; external 'AUDIOW32.DLL';
function AStopVoice(hVoice: HAC): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetVoicePosition(hVoice: HAC; dwPosition: Longint): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetVoiceFrequency(hVoice: HAC; dwFrequency: Longint): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetVoiceVolume(hVoice: HAC; nVolume: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetVoicePanning(hVoice: HAC; nPanning: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetVoicePosition(hVoice: HAC; var pdwPosition: Longint): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetVoiceFrequency(hVoice: HAC; var pdwFrequency: Longint): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetVoiceVolume(hVoice: HAC; var pnVolume: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetVoicePanning(hVoice: HAC; var pnPanning: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetVoiceStatus(hVoice: HAC; var pnStatus: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function APlayModule(pModule: PAudioModule): Integer; stdcall; external 'AUDIOW32.DLL';
function AStopModule: Integer; stdcall; external 'AUDIOW32.DLL';
function APauseModule: Integer; stdcall; external 'AUDIOW32.DLL';
function AResumeModule: Integer; stdcall; external 'AUDIOW32.DLL';
function ASetModuleVolume(nVolume: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetModulePosition(nOrder, nRow: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetModuleVolume(var pnVolume: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetModulePosition(var pnOrder, pnRow: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function AGetModuleStatus(var pnStatus: Integer): Integer; stdcall; external 'AUDIOW32.DLL';
function ASetModuleCallback(pfnAudioCallback: TAudioCallback): Integer; stdcall; external 'AUDIOW32.DLL';
function ALoadModuleFile(pszFileName: PChar; var ppModule: PAudioModule; FileOffset: Longint): Integer; stdcall; external 'AUDIOW32.DLL';
function AFreeModuleFile(pModule: PAudioModule): Integer; stdcall; external 'AUDIOW32.DLL';
function ALoadWaveFile(pszFileName: PChar; var ppWave: PAudioWave; FileOffset: Longint): Integer; stdcall; external 'AUDIOW32.DLL';
function AFreeWaveFile(pWave: PAudioWave): Integer; stdcall; external 'AUDIOW32.DLL';
const
Semaphore: LongBool = False;
PlayingModule: PAudioModule = nil;
function SetPlayingModule(Value: PAudioModule): Boolean; pascal; assembler;
asm
mov eax,True
xchg eax,Semaphore
cmp eax,False
jne @@1
mov eax,PlayingModule
test eax,eax
jne @@0
mov eax,Value
mov PlayingModule,eax
@@0:
mov Semaphore,False
@@1:
push edx
xor eax,eax
mov edx,PlayingModule
cmp edx,Value
sete al
pop edx
end;
procedure Assert(Header: String; ErrorCode: Integer);
var
szText: Array [0..255] of Char;
begin
if ErrorCode <> AUDIO_ERROR_NONE then
begin
AGetErrorText(ErrorCode, szText, sizeof(szText) - 1);
raise Exception.Create(Header + ': ' + StrPas(szText));
end;
end;
{ TAudio }
constructor TAudio.Create(Format: Word; SampleRate: Word);
begin
inherited Create;
FInfo.nDeviceId := AUDIO_DEVICE_MAPPER;
FInfo.wFormat := Format;
FInfo.nSampleRate := SampleRate;
Assert('AOpenAudio', AOpenAudio(FInfo));
Assert('AOpenVoices', AOpenVoices(32));
end;
destructor TAudio.Destroy;
begin
Assert('ACloseVoices', ACloseVoices);
Assert('ACloseAudio', ACloseAudio);
inherited Destroy;
end;
procedure TAudio.Update;
begin
Assert('AUpdateAudio', AUpdateAudio);
end;
function TAudio.GetProductId: Integer;
var
Caps: TAudioCaps;
begin
Assert('AGetAudioDevCaps', AGetAudioDevCaps(FInfo.nDeviceId, Caps));
Result := Caps.wProductId;
end;
function TAudio.GetProductName: String;
var
Caps: TAudioCaps;
begin
Assert('AGetAudioDevCaps', AGetAudioDevCaps(FInfo.nDeviceId, Caps));
Result := StrPas(Caps.szProductName);
end;
{ TWaveform }
constructor TWaveform.Create(Format: Word; SampleRate: Word;
Length, LoopStart, LoopEnd: Longint);
begin
inherited Create;
FPosition := 0;
FVolume := 64;
FPanning := 128;
FHandle.wFormat := Format;
FHandle.dwLength := Length;
FHandle.dwLoopStart := LoopStart;
FHandle.dwLoopEnd := LoopEnd;
FHandle.nSampleRate := SampleRate;
PHandle := nil;
Assert('ACreateAudioData', ACreateAudioData(@FHandle));
end;
constructor TWaveform.LoadFromFile(FileName: String);
var
szFileName: Array [0..255] of Char;
begin
inherited Create;
FPosition := 0;
FVolume := 64;
FPanning := 128;
FHandle.pData := nil;
FHandle.wFormat := AUDIO_FORMAT_8BITS or AUDIO_FORMAT_MONO;
FHandle.dwLength := 0;
FHandle.dwLoopStart := 0;
FHandle.dwLoopEnd := 0;
FHandle.nSampleRate := 22050;
Assert('ALoadWaveFile', ALoadWaveFile(StrPCopy(szFileName, FileName), PHandle, 0));
if Assigned(PHandle) then
FHandle := PHandle^;
end;
destructor TWaveform.Destroy;
begin
if Assigned(PHandle) then
begin
Assert('AFreeWaveFile', AFreeWaveFile(PHandle));
end
else if Assigned(FHandle.pData) then
begin
Assert('ADestroyAudioData', ADestroyAudioData(@FHandle));
end;
inherited Destroy;
end;
procedure TWaveform.Write(var Buffer; Count: Integer);
var
Size: Integer;
begin
if Assigned(FHandle.pData) then
begin
while (Count > 0) and (FHandle.dwLength > 0) do
begin
Size := Count;
if FPosition + Size > FHandle.dwLength then
Size := FHandle.dwLength - FPosition;
Move(Buffer, PChar(FHandle.pData)[FPosition], Size);
Assert('AWriteAudioData', AWriteAudioData(@FHandle, FPosition, Size));
Inc(FPosition, Size);
if FPosition >= FHandle.dwLength then
Dec(FPosition, FHandle.dwLength);
Dec(Count, Size);
end;
end;
end;
function TWaveform.GetHandle: PAudioWave;
begin
Result := @FHandle;
end;
procedure TWaveform.SetSampleRate(Value: Word);
begin
if (Value >= AUDIO_MIN_FREQUENCY) and (Value <= AUDIO_MAX_FREQUENCY) then
FHandle.nSampleRate := Value;
end;
procedure TWaveform.SetVolume(Value: Integer);
begin
if (Value >= AUDIO_MIN_VOLUME) and (Value <= AUDIO_MAX_VOLUME) then
FVolume := Value;
end;
procedure TWaveform.SetPanning(Value: Integer);
begin
if (Value >= AUDIO_MIN_PANNING) and (Value <= AUDIO_MAX_PANNING) then
FPanning := Value;
end;
procedure TWaveform.SetPosition(Value: LongInt);
begin
if (Value >= 0) and (Value < FHandle.dwLength) then
FPosition := Value;
end;
{ TVoice}
constructor TVoice.Create;
begin
inherited Create;
FWave := nil;
Assert('ACreateAudioVoice', ACreateAudioVoice(FHandle));
end;
destructor TVoice.Destroy;
begin
if FHandle <> 0 then
Assert('ADestroyAudioVoice', ADestroyAudioVoice(FHandle));
inherited Destroy;
end;
procedure TVoice.Prime(Wave: TWaveform);
begin
if Assigned(Wave) then
begin
FWave := Wave;
Assert('APrimeVoice', APrimeVoice(FHandle, FWave.Handle));
Assert('ASetVoiceFrequency', ASetVoiceFrequency(FHandle, FWave.SampleRate));
Assert('ASetVoiceVolume', ASetVoiceVolume(FHandle, FWave.Volume));
Assert('ASetVoicePanning', ASetVoicePanning(FHandle, FWave.Panning));
end;
end;
procedure TVoice.Play(Wave: TWaveform);
begin
if Assigned(Wave) then
begin
FWave := Wave;
Assert('APrimeVoice', APrimeVoice(FHandle, FWave.Handle));
Assert('ASetVoiceFrequency', ASetVoiceFrequency(FHandle, FWave.SampleRate));
Assert('ASetVoiceVolume', ASetVoiceVolume(FHandle, FWave.Volume));
Assert('ASetVoicePanning', ASetVoicePanning(FHandle, FWave.Panning));
Assert('AStartVoice', AStartVoice(FHandle));
end;
end;
procedure TVoice.Start;
begin
Assert('AStartVoice', AStartVoice(FHandle));
end;
procedure TVoice.Stop;
begin
Assert('AStopVoice', AStopVoice(FHandle));
end;
function TVoice.GetHandle: HAC;
begin
Result := FHandle;
end;
function TVoice.GetWaveform: TWaveform;
begin
Result := FWave;
end;
function TVoice.GetPosition: Longint;
var
Value: Longint;
begin
Assert('AGetVoicePosition', AGetVoicePosition(FHandle, Value));
Result := Value;
end;
procedure TVoice.SetPosition(Value: Longint);
begin
Assert('ASetVoicePosition', ASetVoicePosition(FHandle, Value));
end;
function TVoice.GetFrequency: Longint;
var
Value: Longint;
begin
Assert('AGetVoiceFrequency', AGetVoiceFrequency(FHandle, Value));
Result := Value;
end;
procedure TVoice.SetFrequency(Value: Longint);
begin
Assert('ASetVoiceFrequency', ASetVoiceFrequency(FHandle, Value));
end;
function TVoice.GetVolume: Integer;
var
Value: Integer;
begin
Assert('AGetVoiceVolume', AGetVoiceVolume(FHandle, Value));
Result := Value;
end;
procedure TVoice.SetVolume(Value: Integer);
begin
Assert('ASetVoiceVolume', ASetVoiceVolume(FHandle, Value));
end;
function TVoice.GetPanning: Integer;
var
Value: Integer;
begin
Assert('AGetVoicePanning', AGetVoicePanning(FHandle, Value));
Result := Value;
end;
procedure TVoice.SetPanning(Value: Integer);
begin
Assert('ASetVoicePanning', ASetVoicePanning(FHandle, Value));
end;
function TVoice.GetStopped: Boolean;
var
Value: Integer;
begin
Assert('AGetVoiceStatus', AGetVoiceStatus(FHandle, Value));
Result := Value <> 0;
end;
{ TModule }
constructor TModule.LoadFromFile(FileName: String);
var
szFileName: Array [0..255] of Char;
begin
inherited Create;
FHandle := nil;
FCallback := nil;
Assert('ALoadModuleFile', ALoadModuleFile(StrPCopy(szFileName, FileName), FHandle, 0));
end;
destructor TModule.Destroy;
begin
if Assigned(FHandle) then
begin
if not Stopped then Stop;
Assert('AFreeModuleFile', AFreeModuleFile(FHandle));
end;
inherited Destroy;
end;
procedure TModule.Play;
begin
if Assigned(FHandle) and SetPlayingModule(FHandle) then
Assert('APlayModule', APlayModule(FHandle));
end;
procedure TModule.Stop;
begin
if Assigned(FHandle) and (PlayingModule = FHandle) then
begin
Assert('AStopModule', AStopModule);
PlayingModule := nil;
end;
end;
procedure TModule.Pause;
begin
if Assigned(FHandle) and (PlayingModule = FHandle) then
Assert('APauseModule', APauseModule);
end;
procedure TModule.Resume;
begin
if Assigned(FHandle) and (PlayingModule = FHandle) then
Assert('AResumeModule', AResumeModule);
end;
function TModule.GetVolume: Integer;
var
Value: Integer;
begin
Result := 0;
if Assigned(FHandle) and (PlayingModule = FHandle) then
begin
Assert('AGetModuleVolume', AGetModuleVolume(Value));
Result := Value;
end;
end;
procedure TModule.SetVolume(Value: Integer);
begin
if Assigned(FHandle) and (PlayingModule = FHandle) then
Assert('ASetModuleVolume', ASetModuleVolume(Value));
end;
function TModule.GetOrder: Integer;
var
Order, Row: Integer;
begin
Result := 0;
if Assigned(FHandle) and (PlayingModule = FHandle) then
begin
Assert('AGetModulePosition', AGetModulePosition(Order, Row));
Result := Order;
end;
end;
procedure TModule.SetOrder(Value: Integer);
begin
if Assigned(FHandle) and (PlayingModule = FHandle) then
Assert('ASetModulePosition', ASetModulePosition(Value, Row));
end;
function TModule.GetRow: Integer;
var
Order, Row: Integer;
begin
Result := 0;
if Assigned(FHandle) and (PlayingModule = FHandle) then
begin
Assert('AGetModulePosition', AGetModulePosition(Order, Row));
Result := Row;
end;
end;
procedure TModule.SetRow(Value: Integer);
begin
if Assigned(FHandle) and (PlayingModule = FHandle) then
Assert('ASetModulePosition', ASetModulePosition(Order, Value));
end;
function TModule.GetStopped: Boolean;
var
Value: Integer;
begin
Result := True;
if Assigned(FHandle) and (PlayingModule = FHandle) then
begin
Assert('AGetModuleStatus', AGetModuleStatus(Value));
Result := Value <> 0;
end;
end;
procedure TModule.SetCallback(Value: TAudioCallback);
begin
if Assigned(FHandle) and (PlayingModule = FHandle) then
begin
FCallback := Value;
Assert('ASetModuleCallback', ASetModuleCallback(Value));
end;
end;
function TModule.GetName: String;
begin
Result := '';
if Assigned(FHandle) then
Result := StrPas(FHandle^.szModuleName);
end;
function TModule.GetNumOrders: Integer;
begin
Result := 0;
if Assigned(FHandle) then
Result := FHandle^.nOrders;
end;
function TModule.GetNumTracks: Integer;
begin
Result := 0;
if Assigned(FHandle) then
Result := FHandle^.nTracks;
end;
function TModule.GetNumPatterns: Integer;
begin
Result := 0;
if Assigned(FHandle) then
Result := FHandle^.nPatterns;
end;
function TModule.GetNumPatches: Integer;
begin
Result := 0;
if Assigned(FHandle) then
Result := FHandle^.nPatches;
end;
function TModule.GetPatch(Index: Integer): PAudioPatch;
begin
Result := nil;
if Assigned(FHandle) then
begin
if (Index >= 1) and (Index <= FHandle^.nPatches) then
Result := PAudioPatch(@PChar(FHandle^.aPatchTable)[sizeof(TAudioPatch) * Pred(Index)]);
end;
end;
end.