asndlib.pp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. unit asndlib;
  2. {$mode objfpc}
  3. {$J+}
  4. {$INLINE ON}
  5. {$MACRO ON}
  6. {$PACKRECORDS C}
  7. {$ASSERTIONS ON}
  8. interface
  9. uses
  10. ctypes, gctypes;
  11. const
  12. ASND_LIB = $100;
  13. SND_LIB = ( ASND_LIB + 2 );
  14. SND_OK = 0;
  15. SND_INVALID = - 1;
  16. SND_ISNOTASONGVOICE = - 2;
  17. SND_BUSY = 1;
  18. SND_UNUSED = 0; (*!< This voice is available for use. *)
  19. SND_WORKING = 1; (*!< This voice is currently in progress. *)
  20. SND_WAITING = 2; (*!< This voice is currently in progress and waiting to one SND_AddVoice() function (the voice handler is called continuously) *)
  21. VOICE_MONO_8BIT = 0;
  22. VOICE_MONO_16BIT = 1;
  23. VOICE_MONO_16BIT_BE = 1;
  24. VOICE_STEREO_8BIT = 2;
  25. VOICE_STEREO_16BIT = 3;
  26. VOICE_STEREO_16BIT_BE = 3;
  27. VOICE_MONO_8BIT_U = 4;
  28. VOICE_MONO_16BIT_LE = 5;
  29. VOICE_STEREO_8BIT_U = 6;
  30. VOICE_STEREO_16BIT_LE = 7;
  31. MIN_VOLUME = 0;
  32. MID_VOLUME = 127;
  33. MAX_VOLUME = 255;
  34. MIN_PITCH = 1; (*!< 1Hz *)
  35. F44100HZ_PITCH = 44100; (*!< 44100Hz *)
  36. MAX_PITCH = 144000; (*!< 144000Hz (more process time for pitch>48000) *)
  37. NOTE_DO = 0;
  38. NOTE_DOs = 1;
  39. NOTE_REb = NOTE_DOs;
  40. NOTE_RE = NOTE_REb + 1;
  41. NOTE_REs = NOTE_RE + 1;
  42. NOTE_MIb = NOTE_REs;
  43. NOTE_MI = NOTE_MIb + 1;
  44. NOTE_FA = NOTE_MI + 1;
  45. NOTE_FAs = NOTE_FA + 1;
  46. NOTE_SOLb = NOTE_FAs;
  47. NOTE_SOL = NOTE_SOLb + 1;
  48. NOTE_SOLs = NOTE_SOL + 1;
  49. NOTE_LAb = NOTE_SOLs;
  50. NOTE_LA = NOTE_LAb + 1;
  51. NOTE_LAs = NOTE_LA + 1;
  52. NOTE_SIb = NOTE_LAs;
  53. NOTE_SI = NOTE_SIb + 1;
  54. NOTE_C = 0;
  55. NOTE_Cs = 1;
  56. NOTE_Db = NOTE_Cs;
  57. NOTE_D = NOTE_Db + 1;
  58. NOTE_Ds = NOTE_D + 1;
  59. NOTE_Eb = NOTE_Ds;
  60. NOTE_E = NOTE_Eb + 1;
  61. NOTE_F = NOTE_E + 1;
  62. NOTE_Fs = NOTE_F + 1;
  63. NOTE_Gb = NOTE_Fs;
  64. NOTE_G = NOTE_Gb + 1;
  65. NOTE_Gs = NOTE_G + 1;
  66. NOTE_Ab = NOTE_Gs;
  67. NOTE_A = NOTE_Ab + 1;
  68. NOTE_As = NOTE_A + 1;
  69. NOTE_Bb = NOTE_As;
  70. NOTE_B = NOTE_Bb + 1;
  71. function _NOTE(note, octave: cint): cint; inline;
  72. {$define Note2Freq := ANote2Freq}
  73. {$define SND_Init := ASND_Init}
  74. {$define SND_End := ASND_End}
  75. {$define SND_Pause := ASND_Pause}
  76. {$define SND_Is_Paused := ASND_Is_Paused}
  77. {$define SND_GetTime := ASND_GetTime}
  78. {$define SND_GetSampleCounter := ASND_GetSampleCounter}
  79. {$define SND_GetSamplesPerTick := ASND_GetSamplesPerTick}
  80. {$define SND_SetTime := ASND_SetTime}
  81. {$define SND_SetCallback := ASND_SetCallback}
  82. {$define SND_GetAudioRate := ASND_GetAudioRate}
  83. {$define SND_SetVoice := ASND_SetVoice}
  84. {$define SND_AddVoice := ASND_AddVoice}
  85. {$define SND_StopVoice := ASND_StopVoice}
  86. {$define SND_PauseVoice := ASND_PauseVoice}
  87. {$define SND_StatusVoice := ASND_StatusVoice}
  88. {$define SND_GetFirstUnusedVoice := ASND_GetFirstUnusedVoice}
  89. {$define SND_ChangePitchVoice := ASND_ChangePitchVoice}
  90. {$define SND_ChangeVolumeVoice := ASND_ChangeVolumeVoice}
  91. {$define SND_ChangeVolumeVoice := ASND_ChangeVolumeVoice}
  92. {$define SND_GetTickCounterVoice := ASND_GetTickCounterVoice}
  93. {$define SND_GetTimerVoice := ASND_GetTimerVoice}
  94. {$define SND_TestPointer := ASND_TestPointer}
  95. type
  96. ASNDVoiceCallback = procedure(voice: cint32); cdecl;
  97. function ANote2Freq(note, freq_base, note_base: cint): cint; cdecl; external;
  98. procedure ASND_Init; cdecl; external;
  99. procedure ASND_End; cdecl; external;
  100. procedure ASND_Pause(paused: cint32); cdecl; external;
  101. function ASND_Is_Paused: cint32; cdecl; external;
  102. function ASND_GetTime: cuint32; cdecl; external;
  103. function ASND_GetSampleCounter: cuint32; cdecl; external;
  104. function ASND_GetSamplesPerTick: cuint32; cdecl; external;
  105. procedure ASND_SetTime(time: cuint32); cdecl; external;
  106. type
  107. TAuxCallback0 = procedure; cdecl;
  108. procedure ASND_SetCallback(callback: TAuxCallback0); cdecl; external;
  109. function ASND_GetAudioRate: cint32; cdecl; external;
  110. function ASND_SetVoice(voice, format, pitch, delay: cint32; snd: pointer; size_snd, volume_l, volume_r: cint32; callback: ASNDVoiceCallback): cint32; cdecl; external;
  111. function ASND_SetInfiniteVoice(voice, format, pitch, delay: cint32; snd: pointer; size_snd, volume_l, volume_r: cint32): cint32; cdecl; external;
  112. function ASND_AddVoice(voice: cint32; snd: pointer; size_snd: cint32): cint32; cdecl; external;
  113. function ASND_StopVoice(voice: cint32): cint32; cdecl; external;
  114. function ASND_PauseVoice(voice, pause: cint32): cint32; cdecl; external;
  115. function ASND_StatusVoice(voice: cint32): cint32; cdecl; external;
  116. function ASND_GetFirstUnusedVoice: cint32; cdecl; external;
  117. function ASND_ChangePitchVoice(voice, pitch: cint32): cint32; cdecl; external;
  118. function ASND_ChangeVolumeVoice(voice, volume_l, volume_r: cint32): cint32; cdecl; external;
  119. function ASND_GetTickCounterVoice(voice: cint32): cuint32; cdecl; external;
  120. function ASND_GetTimerVoice(voice: cint32): cuint32; cdecl; external;
  121. function ASND_TestPointer(voice: cint32; pointer: pointer): cint32; cdecl; external;
  122. function ASND_TestVoiceBufferReady(voice: cint32): cint32; cdecl; external;
  123. function ASND_GetDSP_PercentUse: cuint32; cdecl; external;
  124. function ASND_GetDSP_ProcessTime: cuint32; cdecl; external;
  125. implementation
  126. function _NOTE(note, octave: cint): cint; inline;
  127. begin
  128. _NOTE := note + (octave shl 3) + (octave shl 2);
  129. end;
  130. initialization
  131. {$linklib asnd}
  132. end.