Recent

Author Topic: UADE Library  (Read 2138 times)

Gigatron

  • Full Member
  • ***
  • Posts: 202
  • Amiga Rulez !!
UADE Library
« on: February 06, 2025, 11:40:39 pm »
Hi,
A beta stage of Ultimate amiga delitracker library, .dll compiled with Visual Studio 2022 for X64 windows platform; https://zakalwe.fi/uade/

Help from Hippoplayer and Replayers source code;
Very difficult to implement this library .. but stay tuned !!
@Tron will help me :)

Edit  ** I can just play some format now and library is waiting for upload ;

Actionamics , AIFF ,Supports 8 and 16bit samples.
AMOS , ArtOfNoise
DataType    Uses datatype.library for playing samples.
WARNING: certain datatypes have severe problems recognizing files (e.g. MacSND datatype)which can cause system lockups, gurus, etc. Martin Blom's ProTracker DataType is ignored by this player.
DDMF    Plays X-Tracker modules (version 8).
Uses Noteplayer Interface (up to 32 Voices).
DeliAY    ZX Spectrum sound emulation.
(No BEEP support)
DeliSID    Requires playsid.library.
Delta1.0    
Delta2.0    Uses Noteplayer Interface.
DIGIbooster    
DigiMugi    Supports 4 and 7 voice modules. Uses Noteplayer Interface (up to 8 Voices).
DSS    Uses Noteplayer Interface.
EarAche    
EMS    Rarely used.
FastTracker2    Requires at least a '020 CPU.
Uses Noteplayer Interface (up to 32 Voices).
FC1.4    Uses Noteplayer Interface.
Fred    Uses Noteplayer Interface.
FTM    Modules of this type may now be crunched.
GlueMon    Uses Noteplayer Interface.
GMOD    
Hippel    Replay code inside the module!
Hippel_7V    Uses Noteplayer Interface (7 Voices).
Hippel-COSO    Uses Noteplayer Interface.
HolyNoise    
IFF-8SVX    Don't pack the samples. Loads samples while playing. Has a GUI for some memory settings.
Hint: The normal audio DMA can playback samples with frequencies up to 28 kHz. If you want to play samples with a higher sampling rate make sure to have a productivity screen in the foreground. This is because in the current hardware, the audio DMA is coupled with the scanrate. The hardware can output two samples per scanline. In standard video mode, this results in a maximum output rate of 2 x 15kHz = 30 kHz. In productivity the scanrate is doubled so the maximum output rate raises to ~60 kHz.
IFF-SMUS    This player has a GUI for setting the instrument path. This path may also be relative to the module.
Notes: Songfiles where no instrument is set are recognized and loaded, but you won't hear anything. The instrument names must have a '.instr' suffix.
Impulse    Requires at least a '020 CPU.
Uses Noteplayer Interface (32 Voices).
JamCracker    Uses Noteplayer Interface.
JasonPage    Uses Noteplayer Interface.
LME    
M.O.N    Replay code inside the module!
MarkII    Uses Noteplayer Interface.
MaxTrax    
MED    Plays 'MMD0', 'MMD1' and 'MMD2' modules with 4-8 channels, no songs, no MIDI.
Uses Noteplayer Interface.
Mline    Modules may not be packed.
MultiTracker    Uses Noteplayer Interface (up to 32 Voices).
Music-Ass    Uses Noteplayer Interface.
MusicMaker    Uses Noteplayer Interface (up to 8 Voices).
OctaMED    Plays 'MMD3' modules of OctaMED Soundstudio.
Oktalyzer    Uses Noteplayer Interface (up to 8 Voices).
Poly    Requires at least a '020 CPU.
Uses Noteplayer Interface (up to 32 Voices).
ProRunner21    
PSA    
PumaTracker    
QuadraComposer    
RIFF-WAV    Don't pack; Loads samples while playing. Has a GUI.
Supports 8 and 16bit samples.
RobHubbard2    Uses Noteplayer Interface.
SaPlayer    Uses Noteplayer Interface.
ScreamTracker3    Requires at least a '020 CPU.
Uses Noteplayer Interface (up to 32 Voices).
SCUMM    Replay code inside the module!
SIDMon1.0    Uses Noteplayer Interface.
SIDMon2.0    Uses Noteplayer Interface.
SoundControl    Uses Noteplayer Interface.
Soundfactory    Doesn't play "executable" module format
SoundFX13    Doesn't play "executable" module format.
Uses Noteplayer Interface.
SoundFX20    Doesn't play "executable" module format.
Uses Noteplayer Interface.
SoundMon20    Uses Noteplayer Interface.
SoundMon22    Uses Noteplayer Interface.
StarTrekker4AM    Plays only StarTrekker modules with AM sounds. The corresponding '.NT' file must exist else the module won't be played. Both files may be crunched.
StoneTracker    Requires at least a 68020 CPU.
Uses Noteplayer Interface.
Synthesis    
TakeTracker    Uses Noteplayer Interface (up to 8 Voices).
TFMX_1.5    The songfile must begin with 'mdat.' and the sample file with 'smpl.' Both files may be crunched.
TFMX    Supports 4 and 7 voice modules. Uses Noteplayer Interface (up to 7 Voices). The songfile must begin with 'mdat.' and the sample file with 'smpl.' Both files may be crunched.
THX    
TimFollin    Uses Noteplayer Interface.
TME    
VectorDean    Uses Noteplayer Interface.
VSSDeliPlayer    
Whittaker    Replay code inside the module!


You can look the code :
Main Unit;

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   ExtCtrls,Windows,Uade,mmsystem;
  10.  
  11. const
  12.   Channels = 2;
  13.   BitsPerSample = 16;
  14.   SampleRate = 44100; // Nombre d'échantillons par seconde
  15.   BufSize =  8196*8 ;    // Taille du tampon audio x 2
  16.   BufferCount = 2;
  17.  
  18.  type
  19.  
  20.   { TForm1 }
  21.  
  22.    TForm1 = class(TForm)
  23.     btnQuit: TButton;
  24.     Button1: TButton;
  25.     Timer1: TTimer;
  26.     procedure FormCreate(Sender: TObject);
  27.     procedure FormShow(Sender: TObject);
  28.     procedure Timer1Timer(Sender: TObject);
  29.  
  30.   private
  31.  
  32.     buffers: array[0..BufferCount-1] of array[0..BufSize-1] of SmallInt;
  33.     waveHeaders: array[0..BufferCount-1] of TWaveHdr;
  34.     currentBuffer: Integer;
  35.  
  36.   public
  37.  
  38.   end;
  39.  
  40. var
  41.   Form1: TForm1;
  42.  
  43.   waveOut: HWAVEOUT;
  44.   ok_flag: Boolean = false;
  45.   fsize : integer;
  46.  
  47.   uade_cfg : PUADEConfig;
  48.   uade_st  : PUADEState;
  49.   uade_mod : TUADEFile;
  50.   uade_modp : PUADEFile;
  51.   uade_sinfo : PUADESongInfo;
  52.   uade_isrmc : integer;
  53.   uade_stp : integer;
  54.   uade_sr  : integer;
  55.   uade_buff_play : integer;
  56.   uade_pl        : integer;
  57.  
  58.   uade_rd  : UInt16;
  59.   uade_egp : integer;
  60.   uade_dinf  : PUADEDetectionInfo;
  61.  
  62.   uade_bencode   : PBEncode;
  63.  
  64.   // module in buffer
  65.   Buffer: array of Byte; // binary data song buffer
  66.   Filename: string;
  67.  
  68. implementation
  69.  
  70. {$R *.lfm}
  71.  
  72. { TForm1 }
  73.  
  74. procedure FillBuff(bufferIndex: Integer);
  75. var
  76.   GenSmp, NumSmp : Integer;
  77. begin
  78.   if ok_flag then
  79.   begin
  80.  
  81.     bufferIndex := Form1.currentBuffer;
  82.     NumSmp := BufSize div (Channels * (BitsPerSample div 16));
  83.     GenSmp := uade_read(@Form1.buffers[bufferIndex][0],NumSmp*4, uade_st);;
  84.  
  85.   end;
  86. end;
  87.  
  88. function WaveOutCallback(hwo: HWAVEOUT; uMsg: UINT; dwInstance, dwParam1, dwParam2: DWORD_PTR): DWORD; stdcall;
  89. begin
  90.   if uMsg = WOM_DONE then
  91.   begin
  92.     FillBuff(Form1.currentBuffer);
  93.     waveOutWrite(hwo, @Form1.waveHeaders[Form1.currentBuffer], SizeOf(TWaveHdr));
  94.     Form1.currentBuffer := (Form1.currentBuffer + 1) mod BufferCount;
  95.   end;
  96.   Result := 0;
  97. end;
  98.  
  99. procedure InitAudio;
  100. var
  101.   wFormat: TWaveFormatEx;
  102.   i: Integer;
  103. begin
  104.  
  105.   SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_LOWEST);
  106.  
  107.   with wFormat do
  108.   begin
  109.     wFormatTag := WAVE_FORMAT_PCM;
  110.     nChannels := Channels;
  111.     nSamplesPerSec := SampleRate;
  112.     wBitsPerSample := BitsPerSample;
  113.     nBlockAlign := (wBitsPerSample * nChannels) div 8;
  114.     nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;
  115.     cbSize := 0;
  116.   end;
  117.  
  118.   if waveOutOpen(@waveOut, WAVE_MAPPER, @wFormat, QWORD(@WaveOutCallback), 0, CALLBACK_FUNCTION) <> MMSYSERR_NOERROR then
  119.     raise Exception.Create('Erreur ouverture periph audio');
  120.  
  121.   // buffers
  122.   for i := 0 to BufferCount - 1 do
  123.   begin
  124.     ZeroMemory(@Form1.waveHeaders[i], SizeOf(TWaveHdr));
  125.      with Form1.waveHeaders[i] do
  126.     begin
  127.       lpData := @Form1.buffers[i][0];
  128.       dwBufferLength := BufSize * SizeOf(SmallInt);
  129.       dwFlags := 0;
  130.     end;
  131.     waveOutPrepareHeader(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  132.   end;
  133.   Form1.currentBuffer := 0;
  134.    for i := 0 to BufferCount - 1 do
  135.       begin
  136.         FillBuff(i);
  137.         waveOutWrite(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  138.       end;
  139.  
  140. end;
  141.  
  142. procedure LoadBinaryFileToBuffer(const FileName: string; var Buffer:   TBytes);
  143. var
  144.   MemoryStream: TMemoryStream;
  145. begin
  146.   MemoryStream := TMemoryStream.Create;
  147.   try
  148.     MemoryStream.LoadFromFile(FileName);
  149.     SetLength(Buffer, MemoryStream.Size); // Ajuste la taille du buffer
  150.     MemoryStream.ReadBuffer(Buffer[0], MemoryStream.Size);
  151.     fsize := MemoryStream.Size;
  152.   finally
  153.     MemoryStream.Free;
  154.   end;
  155. end;
  156.  
  157. procedure TForm1.FormCreate(Sender: TObject);
  158.  
  159. begin
  160. end;
  161.  
  162.  
  163. procedure TForm1.FormShow(Sender: TObject);
  164. begin
  165.  
  166.    FileName:='amegas.mod';
  167.  
  168.   try
  169.     LoadBinaryFileToBuffer(FileName, Buffer);
  170.  
  171.   except
  172.     on E: Exception do
  173.       ShowMessage('Erreur : ' );
  174.   end;
  175.  
  176.    uade_cfg := uade_new_config;
  177.  
  178.    uade_config_set_option(uade_cfg, UC_BASE_DIR,'');
  179.   // uade_config_set_option(uade_cfg, UC_UADECORE_FILE,Pchar('uade/uadecore.exe'));
  180.    uade_config_set_option(uade_cfg, UC_PLAYER_FILE,Pchar('players/CustomMade'));
  181.    uade_config_set_option(uade_cfg, UC_SCORE_FILE,Pchar('uade/score'));
  182.    uade_config_set_option(uade_cfg, UC_UAE_CONFIG_FILE,Pchar('uade/uade.conf'));
  183.    uade_config_set_option(uade_cfg, UC_EAGLEPLAYER_OPTION,Pchar('0'));
  184.    uade_config_set_option(uade_cfg, UC_ONE_SUBSONG, nil);
  185.    uade_config_set_option(uade_cfg, UC_CONTENT_DETECTION, Pchar('1'));
  186.    uade_config_set_option(uade_cfg, UC_IGNORE_PLAYER_CHECK, nil);
  187.    uade_config_set_option(uade_cfg, UC_NO_EP_END, Nil);
  188.    uade_config_set_option(uade_cfg, UC_PANNING_VALUE,'0.7');
  189.    uade_config_set_option(uade_cfg, UC_FILTER_TYPE,'1');
  190.    uade_config_set_option(uade_cfg, UC_FORCE_LED,'1');
  191.    uade_config_set_option(uade_cfg, UC_HEADPHONES,'nil');
  192.    uade_config_set_option(uade_cfg, UC_HEADPHONES2,'nil');
  193.    uade_config_set_option(uade_cfg, UC_RESAMPLER,pchar('nil'));
  194.    uade_config_set_option(uade_cfg, UC_AO_OPTION,'nil');
  195.    uade_config_set_option(uade_cfg, UC_TIMEOUT_VALUE,'3000');
  196.    uade_config_set_option(uade_cfg, UC_SUBSONG_TIMEOUT_VALUE, '-1');
  197.    uade_config_set_option(uade_cfg, UC_SILENCE_TIMEOUT_VALUE, '-1');
  198.    uade_config_set_option(uade_cfg, UC_GAIN, Pchar('0.8'));
  199.    uade_config_set_option(uade_cfg, UC_FREQUENCY, Pchar('44100'));
  200.  
  201.    uade_cleanup_state(uade_st);
  202.    uade_st := uade_new_state(nil); // nil yet
  203.  
  204.   // uade_st := uade_new_state(uade_cfg); // not working !!
  205.  
  206.    uade_sr := uade_get_sampling_rate(uade_st);
  207.  
  208.    uade_buff_play := uade_play_from_buffer(nil,@buffer[0], Length(buffer),-1,uade_st);
  209.  
  210.    uade_sinfo := uade_get_song_info(uade_st);
  211.  
  212.    InitAudio;
  213.    ok_flag := true;
  214.  
  215.  
  216. end;
  217.  
  218. procedure TForm1.Timer1Timer(Sender: TObject);
  219. begin
  220.  
  221. end;
  222.  
  223.  
  224. end.
  225.  

« Last Edit: February 06, 2025, 11:56:43 pm by Gigatron »
Sub Quantum Technology ! Gigatron 68000 Colmar France;

Gigatron

  • Full Member
  • ***
  • Posts: 202
  • Amiga Rulez !!
Re: UADE Library
« Reply #1 on: February 06, 2025, 11:41:14 pm »
I am on my second PC and not at home so download Uade.dll lib via :

https://limewire.com/d/1fbc65df-917c-4787-b851-8a05e8c0af45#7SKpjx047UYIvkFetolFkOzsZ0lWtGxPUf2QCWGAitE

Uade lib unit;
Code: Pascal  [Select][+][-]
  1. unit UADE;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   SysUtils;
  9.  
  10.  
  11.  
  12. const
  13.   UADELIB = 'UADE.dll';
  14.  
  15.  
  16.   UADE_CHANNELS = 2;
  17.   UADE_BYTES_PER_SAMPLE = 2;
  18.   UADE_BYTES_PER_FRAME = UADE_CHANNELS * UADE_BYTES_PER_SAMPLE;
  19.  
  20.   UADE_MAX_EXT_LEN = 16;
  21.   RMC_MAGIC: array[0..8] of AnsiChar = 'rmc'#0#251#19#246#31#162;
  22.   RMC_MAGIC_LEN = 9;
  23.   UADE_DEFAULT_FREQUENCY = 44100;
  24.   PATH_MAX = 4096;
  25.   UADE_MAX_MESSAGE_SIZE = 4096;
  26.   HEADPHONE2_DELAY_MAX_LENGTH = 48;
  27.   UADE_EFFECT_HEADPHONES_DELAY_LENGTH = 22;
  28.   HEADPHONE2_DELAY_TIME = 0.49e-3;
  29.   MAXIMUM_SAMPLING_RATE =96000;
  30.  
  31.   UADE_PLAY_CURRENT = 0;
  32.   UADE_PLAY_NEXT = 1;
  33.   UADE_PLAY_FAILURE = -1;
  34.   UADE_PLAY_EXIT = -2;
  35.  
  36.  
  37.   ES_A1200               = 1 shl 0;
  38.   ES_A500                = 1 shl 1;
  39.   ES_ALWAYS_ENDS         = 1 shl 2;
  40.   ES_BROKEN_SONG_END     = 1 shl 3;
  41.   ES_CONTENT_DETECTION   = 1 shl 4;
  42.   ES_EP_OPTION           = 1 shl 5;
  43.   ES_GAIN                = 1 shl 6;
  44.   ES_IGNORE_PLAYER_CHECK = 1 shl 7;
  45.   ES_LED_OFF             = 1 shl 8;
  46.   ES_LED_ON              = 1 shl 9;
  47.   ES_NEVER_ENDS          = 1 shl 10;
  48.   ES_NO_FILTER           = 1 shl 11;
  49.   ES_NO_HEADPHONES       = 1 shl 12;
  50.   ES_NO_PANNING          = 1 shl 13;
  51.   ES_NO_POSTPROCESSING   = 1 shl 14;
  52.   ES_NTSC                = 1 shl 15;
  53.   ES_ONE_SUBSONG         = 1 shl 16;
  54.   ES_PAL                 = 1 shl 17;
  55.   ES_PANNING             = 1 shl 18;
  56.   ES_PLAYER              = 1 shl 19;
  57.   ES_REJECT              = 1 shl 20;
  58.   ES_RESAMPLER           = 1 shl 21;
  59.   ES_SILENCE_TIMEOUT     = 1 shl 22;
  60.   ES_SPEED_HACK          = 1 shl 23;
  61.   ES_SUBSONGS            = 1 shl 24;
  62.   ES_SUBSONG_TIMEOUT     = 1 shl 25;
  63.   ES_TIMEOUT             = 1 shl 26;
  64.  
  65.   UADE_WS_DELIMITERS = ' '#9#10;
  66.  
  67.  
  68.  
  69. type
  70.   size_t = Int64;
  71.   int64_t = Int64;
  72.  
  73.     // Structure Path
  74.   TUADEPath = record
  75.     Name: array[0..PATH_MAX - 1] of AnsiChar;
  76.   end;
  77.  
  78.   // Options eagleplayer
  79.   TUADEEPOptions = record
  80.     O: array[0..255] of AnsiChar;
  81.     S: size_t;
  82.   end;
  83.  
  84.   // Options  audio output
  85.   TUADEAOOptions = record
  86.     O: array[0..255] of AnsiChar;
  87.   end;
  88.  
  89.   //  configurations
  90.   TUADECharConfig = record
  91.     Value: AnsiChar;
  92.     IsSet: Boolean;
  93.   end;
  94.  
  95.   TUADEFloatConfig = record
  96.     Value: Single;
  97.     IsSet: Boolean;
  98.   end;
  99.  
  100.   TUADEIntConfig = record
  101.     Value: Integer;
  102.     IsSet: Boolean;
  103.   end;
  104.  
  105.   TUADEPathConfig = record
  106.     Path: TUADEPath;
  107.     IsSet: Boolean ;
  108.   end;
  109.  
  110.   TUadeBiquad = record
  111.     b0: Single;
  112.     b1: Single;
  113.     b2: Single;
  114.     a1: Single;
  115.     a2: Single;
  116.     x: array[0..1] of Single;
  117.     y: array[0..1] of Single;
  118.   end;
  119.  
  120.   PUadeBiquad = ^TUadeBiquad;
  121.  
  122.   PUadeEffectState = ^TUadeEffectState;
  123.   TUadeEffectState = record
  124.     enabled: boolean;
  125.     gain: Integer;
  126.     pan: Integer;
  127.     rate: Integer;
  128.  
  129.     headphones_ap_l: array[0..UADE_EFFECT_HEADPHONES_DELAY_LENGTH - 1] of Single;
  130.     headphones_ap_r: array[0..UADE_EFFECT_HEADPHONES_DELAY_LENGTH - 1] of Single;
  131.     headphones_rc_l: array[0..3] of Single;
  132.     headphones_rc_r: array[0..3] of Single;
  133.  
  134.     headphone2_ap_l: array[0..HEADPHONE2_DELAY_MAX_LENGTH - 1] of Single;
  135.     headphone2_ap_r: array[0..HEADPHONE2_DELAY_MAX_LENGTH - 1] of Single;
  136.     headphone2_delay_length: Integer;
  137.     headphone2_shelve_l: PUadeBiquad;
  138.     headphone2_shelve_r: PUadeBiquad;
  139.     headphone2_rc_l: PUadeBiquad;
  140.     headphone2_rc_r: PUadeBiquad;
  141.   end;
  142.  
  143.   PUADEAttribute = ^TUADEAttribute;
  144.   TUADEAttribute = record
  145.     Next: PUADEAttribute;
  146.     Flag: Integer;
  147.     S: PChar;
  148.     I: Integer;
  149.     D: Double;
  150.   end;
  151.  
  152.   // Structure pour eagleplayer
  153.   PEaglePlayer = ^TEaglePlayer;
  154.   TEaglePlayer = record
  155.     PlayerName: PChar;
  156.     Nextensions:  Integer;
  157.     Extensions:  Pchar;
  158.     Flags: Integer;
  159.     AttributeList: PUADEAttribute;
  160.   end;
  161.  
  162.   // Structure pour eagleplayermap
  163.   PEaglePlayerMap = ^TEaglePlayerMap;
  164.   TEaglePlayerMap = record
  165.     Extension: PChar;
  166.     Player: PEaglePlayer;
  167.   end;
  168.  
  169.   // Structure eagleplayerstore
  170.   PEaglePlayerStore = ^TEaglePlayerStore;
  171.   TEaglePlayerStore = record
  172.     NPlayers: SizeUInt;
  173.     Players: PEaglePlayer ; // Tableau players
  174.     NExtensions: SizeUInt;
  175.     Map: PEaglePlayerMap; // Tableau de maps
  176.   end;
  177.  
  178.   // Structure pour epconfattr
  179.   TEPConfAttr = record
  180.     S: PChar;
  181.     E: Integer;
  182.     O: Integer;
  183.     C: PChar;
  184.   end;
  185.  
  186.   // Structure fichier
  187.   PUADEFile = ^TUADEFile;
  188.   TUADEFile = record
  189.     Name: PChar;      // Filename
  190.     Data: PChar;      // File data or null
  191.     Size: integer;     // File size
  192.   end;
  193.  
  194.   // Subsong information
  195.   TUADESubsongInfo = record
  196.     Cur: Integer;     // Current subsong:
  197.     Min: Integer;     // Minimum subsong number
  198.     Def: Integer;     // Default subsong -1
  199.     Max: Integer;     // Maximum subsong
  200.   end;
  201.  
  202.   // Detection information
  203.   PUADEDetectionInfo = ^TUADEDetectionInfo;
  204.   TUADEDetectionInfo =  record
  205.     Custom: Integer;                   // 1 if the file is custom, 0 otherwise
  206.     Content: Integer;                  // 1 if detected by content, 0 otherwise
  207.     Ext: array[0..UADE_MAX_EXT_LEN - 1] of AnsiChar; // File extension
  208.     EP: PEaglePlayer;                       // (don't touch)
  209.   end;
  210.  
  211.   // Extension to format and version mapping
  212.   TUADEExtToFormatVersion = record
  213.     FileExt: PChar;
  214.     Format: PChar;
  215.     Version: PChar;
  216.   end;
  217.  
  218.   // Song information
  219.   PUADESongInfo = ^TUADESongInfo;
  220.   TUADESongInfo = record
  221.     Subsongs: TUADESubsongInfo;
  222.     DetectionInfo: TUADEDetectionInfo;
  223.     ModuleBytes: size_t;           // Size of song file in bytes
  224.     ModuleMD5: array[0..32] of AnsiChar; // Hexadecimal string of MD5 sum
  225.     Duration: Double;              // Duration in seconds, 0 if unknown
  226.     SubsongBytes: int64_t;         // Bytes synthesized in current subsong
  227.     SongBytes: int64_t;            // Bytes synthesized in current song (all subsongs)
  228.     ModuleFName: array[0..4096 - 1] of AnsiChar;
  229.     PlayerFName: array[0..4096 - 1] of AnsiChar;
  230.     FormatName: array[0..255] of AnsiChar;
  231.     ModuleName: array[0..255] of AnsiChar;
  232.     PlayerName: array[0..255] of AnsiChar;
  233.   end;
  234.  
  235.   PUADEConfig  = ^TUADEConfig;
  236.   TUADEConfig = record
  237.     //// Path configurations
  238.     BaseDir: TUADEPathConfig;
  239.     PlayerFile: TUADEPathConfig;
  240.     ScoreFile: TUADEPathConfig;
  241.     UadeCoreFile: TUADEPathConfig;
  242.     UAEConfigFile: TUADEPathConfig;
  243.  
  244.     // Char configurations
  245.     ContentDetection: TUADECharConfig;
  246.  
  247.     // Eagleplayer options
  248.     EPOptions: TUADEEPOptions;
  249.     EPOptionsSet: Boolean;
  250.  
  251.     // Filter and frequency
  252.     FilterType: TUADECharConfig;
  253.     Frequency: TUADEIntConfig;
  254.  
  255.     // LED settings
  256.     LEDForced: TUADECharConfig;
  257.     LEDState: TUADECharConfig;
  258.  
  259.     // Gain configuration
  260.     GainEnable: TUADECharConfig;
  261.     Gain: TUADEFloatConfig;
  262.  
  263.     // Headphones configuration
  264.     Headphones: TUADECharConfig;
  265.     Headphones2: TUADECharConfig;
  266.  
  267.     // Player check
  268.     IgnorePlayerCheck: TUADECharConfig;
  269.  
  270.     // Resampler
  271.     Resampler: PChar;
  272.     ResamplerSet: Boolean;
  273.  
  274.     // Other configurations
  275.     NoContentDB: TUADECharConfig;
  276.     NoEPEnd: TUADECharConfig;
  277.     NoFilter: TUADECharConfig;
  278.     NoPostProcessing: TUADECharConfig;
  279.  
  280.     OneSubsong: TUADECharConfig;
  281.     Panning: TUADEFloatConfig;
  282.     PanningEnable: TUADECharConfig;
  283.  
  284.     SilenceTimeout: TUADEIntConfig;
  285.     SpeedHack: TUADECharConfig;
  286.     SubsongTimeout: TUADEIntConfig;
  287.     Timeout: TUADEIntConfig;
  288.  
  289.     UseTextScope: TUADECharConfig;
  290.     UseTimeouts: TUADECharConfig;
  291.     UseNTSC: TUADECharConfig;
  292.     Verbose: TUADECharConfig;
  293.  
  294.     WriteAudioFile: TUADEPathConfig;
  295.  
  296.     // Audio output options
  297.     AOOptions: TUADEAOOptions;
  298.     AOOptionsSet: Boolean;
  299.   end;
  300.   // Enum for song info type
  301.   TUADESongInfoType = (
  302.     UADE_MODULE_INFO = 1,
  303.     UADE_HEX_DUMP_INFO,
  304.     UADE_NUMBER_OF_INFOS
  305.   );
  306.  
  307.   // Enum for seek modes
  308.   TUADESeekMode = (
  309.     UADE_SEEK_NOT_SEEKING = 0,
  310.     UADE_SEEK_SONG_RELATIVE,
  311.     UADE_SEEK_SUBSONG_RELATIVE,
  312.     UADE_SEEK_POSITION_RELATIVE
  313.   );
  314.  
  315.   // Enum uade options
  316.   TUADEOption = (
  317.     UC_NO_OPTION = $1000,
  318.     UC_BASE_DIR,
  319.     UC_CONTENT_DETECTION,
  320.     UC_DISABLE_TIMEOUTS,
  321.     UC_ENABLE_TIMEOUTS,
  322.     UC_EAGLEPLAYER_OPTION,
  323.     UC_FILTER_TYPE,
  324.     UC_FORCE_LED_OFF,
  325.     UC_FORCE_LED_ON,
  326.     UC_FORCE_LED,
  327.     UC_FREQUENCY,
  328.     UC_GAIN,
  329.     UC_HEADPHONES,
  330.     UC_HEADPHONES2,
  331.     UC_IGNORE_PLAYER_CHECK,
  332.     UC_NO_CONTENT_DB,
  333.     UC_NO_FILTER,
  334.     UC_NO_HEADPHONES,
  335.     UC_NO_PANNING,
  336.     UC_NO_POSTPROCESSING,
  337.     UC_NO_EP_END,
  338.     UC_NTSC,
  339.     UC_ONE_SUBSONG,
  340.     UC_PAL,
  341.     UC_PANNING_VALUE,
  342.     UC_PLAYER_FILE,
  343.     UC_RESAMPLER,
  344.     UC_SCORE_FILE,
  345.     UC_SILENCE_TIMEOUT_VALUE,
  346.     UC_SPEED_HACK,
  347.     UC_SUBSONG_TIMEOUT_VALUE,
  348.     UC_TIMEOUT_VALUE,
  349.     UC_UADECORE_FILE,
  350.     UC_UAE_CONFIG_FILE,
  351.     UC_USE_TEXT_SCOPE,
  352.     UC_VERBOSE,
  353.     UC_AO_OPTION,
  354.     UC_WRITE_AUDIO_FILE
  355.  
  356.   );
  357.  
  358.   // Enum for audio effects
  359.   TUADEEffect = (
  360.     UADE_EFFECT_ALLOW,
  361.     UADE_EFFECT_GAIN,
  362.     UADE_EFFECT_HEADPHONES,
  363.     UADE_EFFECT_HEADPHONES2,
  364.     UADE_EFFECT_PAN
  365.   );
  366.  
  367.   TUADEEventType = (
  368.     UADE_EVENT_INVALID = 0,
  369.     UADE_EVENT_DATA,
  370.     UADE_EVENT_EAGAIN,
  371.     UADE_EVENT_FORMAT_NAME,
  372.     UADE_EVENT_MESSAGE,
  373.     UADE_EVENT_MODULE_NAME,
  374.     UADE_EVENT_PLAYER_NAME,
  375.     UADE_EVENT_READY,
  376.     UADE_EVENT_REQUEST_AMIGA_FILE,
  377.     UADE_EVENT_SONG_END,
  378.     UADE_EVENT_SUBSONG_INFO
  379.   );
  380.  
  381.   // Struct event
  382.   TUADEEventData = record
  383.     Size: SizeUInt;
  384.     Data: array[0..UADE_MAX_MESSAGE_SIZE - 1] of Byte;
  385.   end;
  386.  
  387.   // Structure end module
  388.   TUADEEventSongEnd = record
  389.     Happy: Integer;
  390.     StopNow: Integer;
  391.     TailBytes: Integer;
  392.     Reason: array[0..255] of AnsiChar;
  393.   end;
  394.  
  395.   // Structure des événements
  396.   TUADEEvent = record
  397.     EventType: TUADEEventType;
  398.     case Byte of
  399.       0: (Data: TUADEEventData);
  400.       1: (Message: array[0..1023] of AnsiChar);
  401.       2: (SongEnd: TUADEEventSongEnd);
  402.       3: (SubSongs: TUADESubSongInfo);
  403.   end;
  404.  
  405.   // Énumdes symboles d'état
  406.   TUADEStateSymbol = (
  407.     UADE_STATE_INVALID = 0,
  408.     UADE_STATE_INITIALIZED,
  409.     UADE_STATE_RECEIVE_MSGS,
  410.     UADE_STATE_SONG_END_PENDING,
  411.     UADE_STATE_WAIT_SUBSONG_CHANGE,
  412.     UADE_STATE_ERROR
  413.   );
  414.  
  415.   PUADESong = ^TUADESong;
  416.   TUADESong = record
  417.     MD5: array[0..32] of AnsiChar; // MD5
  418.  
  419.     ModuleFilename: array[0..PATH_MAX - 1] of AnsiChar; // Nom du fichier module
  420.  
  421.     PlayerName: array[0..255] of AnsiChar; // Nom du lecteur Eagleplayer
  422.     ModuleName: array[0..255] of AnsiChar; // Nom du module provenant du score
  423.     FormatName: array[0..255] of AnsiChar; // Nom du format
  424.  
  425.     Buf: PByte;
  426.     BufSize: SizeUInt;
  427.  
  428.     MinSubsong: Integer;
  429.     MaxSubsong: Integer;
  430.     CurSubsong: Integer;
  431.  
  432.     PlayTime: Integer;
  433.     Flags: Integer;
  434.     NSubSongs: Integer;
  435.     SubSongs: PByte;
  436.  
  437.     SongAttributes: PUADEAttribute;
  438.     EPOptions: TUADEEPOptions;
  439.     Normalisation: PChar;
  440.  
  441.     OutBytes: Int64;
  442.  
  443.     SilenceCount: Int64;
  444.   end;
  445.   // Struct song state
  446.   PUADESongState = ^TUADESongState;
  447.   TUADESongState = record
  448.     Info: TUADESongInfo;
  449.     // Membres internes
  450.     State: TUADEStateSymbol;
  451.     SeekModeTrigger: TUADESeekMode;
  452.     SeekSubSongTrigger: Integer;
  453.     SeekOffsetTrigger: UInt64;
  454.     NextSubSongTrigger: Integer;
  455.  
  456.     SeekMode: TUADESeekMode;
  457.     SeekSubSong: Integer;
  458.     SeekSongOffset: UInt64;
  459.     SeekSubSongOffset: UInt64;
  460.  
  461.     BytesRequested: Cardinal;
  462.  
  463.     EndEvent: TUADEEvent;
  464.  
  465.     SilenceCount: Int64;
  466.  
  467.     EPOptions: TUADEEPOptions;
  468.     Flags: Integer;
  469.     SongAttributes: Pointer;
  470.  
  471.     RecordSongTime: Integer;
  472.     RecordSubSongTime: Integer;
  473.     CollectLogs: Integer;
  474.   end;
  475.  
  476.    TUadeControlState = (
  477.     UCS_UNKNOWN,
  478.     UCS_IDLE,
  479.     UCS_BUSY,
  480.     UCS_ERROR
  481.   );
  482.  
  483.   TUADEIPC = record
  484.       InFD: Integer;
  485.       OutFD: Integer;
  486.       InputBytes: Cardinal;
  487.       InputBuffer: array[0..UADE_MAX_MESSAGE_SIZE - 1] of AnsiChar;
  488.       State: TUadeControlState;
  489.     end;
  490.  
  491.  
  492.    // Forward declarations for structures
  493.   PBEncode = record
  494.       car : AnsiChar;
  495.  
  496.  end;
  497.  
  498.   PFifo = ^TFifo;
  499.   TFifo = record
  500.      Lower: SizeUInt;
  501.      Upper: SizeUInt;
  502.      Capacity: SizeUInt;
  503.      Buf: PByte;
  504.  
  505. end;
  506.  
  507.   TRMC = record
  508.     RMC_MAGIC: array[0..8] of AnsiChar;// = 'rmc'#0#251#19#246#31#162;
  509.   end;
  510.  
  511.   // Structure de l'état principal
  512.   PUADEState = ^TUADEState ;
  513. TAmigaLoader = function( name: PChar; playerdir: PChar;context: Pointer;state: PUadeState): TUADEFile; cdecl;
  514.  
  515.   TUADEState = record
  516.  
  517.     Config: TUADEConfig;
  518.     EffectState: TUadeEffectState;
  519.     Song: TUADESongState;
  520.     RMC: TRMC;
  521.  
  522.     // Membres permanents
  523.     ValidConfig: Integer;
  524.     PermConfig: TUADEConfig;
  525.     PermConfigName: array[0..PATH_MAX - 1] of AnsiChar;
  526.     SetDebug: Integer;
  527.     HasEnded: Integer;
  528.  
  529.     ExtraConfig: TUADEConfig;
  530.  
  531.     PlayerStore: TEaglePlayerStore;
  532.     IPC: TUADEIPC;
  533.     UserData: Pointer;
  534.  
  535.     SongDB: Pointer; // Type pour uade_songdb
  536.     SongDBName: array[0..PATH_MAX - 1] of AnsiChar;
  537.  
  538.     AmigaLoader: function( name: PChar; playerdir: PChar;context: Pointer;state: PUadeState):  PUADEFile; cdecl;
  539.     AmigaLoaderContext: Pointer;
  540.  
  541.     ReadStash: Pfifo;
  542.     Notifications: Pfifo;
  543.     WriteQueue: Pfifo;
  544.   end;
  545.  
  546.  
  547.   TUADENotificationType = (
  548.     UADE_NOTIFICATION_MESSAGE,
  549.     UADE_NOTIFICATION_SONG_END
  550.   );
  551.  
  552.  
  553.   TUADENotificationSongEnd = record
  554.     Happy: Integer;
  555.     StopNow: Integer;
  556.     SubSong: Integer;
  557.     SubSongBytes: Int64;
  558.     Reason: PChar;
  559.   end;
  560.  
  561.   // Structure notification
  562.   PUADENotification = ^TUADENotification;
  563.   TUADENotification = record
  564.     NotificationType: TUADENotificationType;
  565.     case Integer of
  566.       0: (Msg: PChar);
  567.       1: (SongEnd: TUADENotificationSongEnd);
  568.   end;
  569.  
  570.  
  571.  
  572.  
  573. procedure uade_cleanup_state(st: PUADEState); cdecl;   external 'uade.dll' name 'uade_cleanup_state';
  574. procedure uade_enable_uadecore_log_collection(st: PUADEState); cdecl; external 'uade.dll';
  575.  
  576. procedure uade_effect_disable(st: TUADEState; effect: TUADEEffect); cdecl; external 'uade.dll';
  577. procedure uade_effect_disable_all(st: TUADEState); cdecl; external 'uade.dll';
  578. procedure uade_effect_enable(st: TUADEState; effect: TUADEEffect); cdecl; external 'uade.dll';
  579. function uade_effect_is_enabled(st: TUADEState; effect: TUADEEffect): Integer; cdecl; external 'uade.dll';
  580. procedure uade_effect_toggle(st: TUADEState; effect: TUADEEffect); cdecl; external 'uade.dll';
  581. procedure uade_effect_gain_set_amount(st: TUADEState; amount: Single); cdecl; external 'uade.dll';
  582. procedure uade_effect_pan_set_amount(st: TUADEState; amount: Single); cdecl; external 'uade.dll';
  583. function uade_event_name(event: TUADENotification): PChar; cdecl; external 'uade.dll';
  584. function uade_get_effective_config(st: TUADEState): TUADEConfig; cdecl; external 'uade.dll';
  585. function uade_get_event(event: TUADENotification; st: PUADEState): Integer; cdecl; external 'uade.dll';
  586. function uade_get_fd(st: TUADEState): Integer; cdecl; external 'uade.dll';
  587. function uade_get_filter_state(st: TUADEState): Integer; cdecl; external 'uade.dll';
  588.  
  589. function uade_read(buff: Pointer; bufferSize: Integer; st: Pointer): Integer; cdecl; external 'uade.dll' name 'uade_read';
  590.  
  591. function uade_read_notification(notification: TUADENotification; st: TUADEState): Integer; cdecl; external 'uade.dll';
  592. procedure uade_cleanup_notification(notification: TUADENotification); cdecl; external 'uade.dll';
  593. function uade_get_sampling_rate(st: PUADEState): Integer; cdecl; external 'uade.dll';
  594.  
  595. function uade_get_song_info(st: PUADEState): PUADESongInfo; cdecl; external 'uade.dll';
  596.  
  597. function uade_is_our_file(fname: PChar; st: PUADEState): integer; cdecl; external 'uade.dll';
  598. function uade_is_our_file_from_buffer(fname: PChar; buf: Pointer; size: SizeInt; st: PUADEState): Integer; cdecl; external 'uade.dll';
  599. function uade_is_rmc(buf: PChar; size: SizeInt): Integer; cdecl; external 'uade.dll';
  600. function uade_is_rmc_file(fname: PChar): Integer; cdecl; external 'uade.dll';
  601. function uade_is_verbose(st: TUADEState): Integer; cdecl; external 'uade.dll';
  602.  
  603. function uade_rmc_decode(buff : pointer; sz : integer):Pointer; cdecl; external 'uade.dll';
  604.  ///
  605. function uade_get_rmc_from_state(st: PUADEState): Pointer; cdecl; external 'uade.dll';
  606.  
  607. function uade_next_subsong(st: TUADEState): Integer; cdecl; external 'uade.dll';
  608.  
  609. function uade_play(fname: PChar; subsong: Integer; st: PUADEState): Integer; cdecl; external 'uade.dll' name 'uade_play';
  610.  
  611. function uade_play_from_buffer(  fname: PChar;  buf: Pointer; size: SizeUInt; subsong: Integer; st: PUADEState): Integer; cdecl; external 'uade.dll';
  612.  
  613.  
  614.  function uade_load_amiga_file(name: PChar; playerdir: PChar; st: PUADEState): PUADEFile; cdecl; external 'uade.dll';
  615.  function uade_new_state( const uc: PUADEConfig): PUADEState; cdecl; external 'uade.dll' name 'uade_new_state';
  616.  
  617.  
  618.  
  619. function uade_stop(st: PUADEState): Integer; cdecl;  external 'uade.dll' name 'uade_stop';
  620.  
  621. function uade_file(name : Pchar; data : Pointer; size : integer):PUADEFile; cdecl; external 'uade.dll';
  622. function uade_file_load(fname : Pchar):PUADEFile; cdecl; external 'uade.dll';
  623. procedure uade_file_free(fl :PUADEFile);cdecl; external 'uade.dll';
  624.  
  625. procedure uade_read_file(fsize: integer;  filename:Pchar);cdecl; external 'uade.dll';
  626.  
  627. // config
  628. procedure uade_config_set_defaults(uc: PUADEConfig); cdecl; external 'uade.dll';
  629. function uade_convert_to_double(value: PChar; def, low, high: Double; typ: PChar): Double; cdecl; external 'uade.dll';
  630. function uade_load_config(st: PUADEState; filename: PChar): Integer; cdecl; external 'uade.dll';
  631.  
  632. function uade_load_initial_config(st: PUADEState ; bdir: PChar): Integer; cdecl; external 'uade.dll';
  633.  
  634. function uade_load_initial_song_conf(songconfname: PChar; maxlen: SizeUInt; uc: PUADEConfig): Integer; cdecl; external 'uade.dll';
  635. procedure uade_merge_configs(ucd: PUADEConfig; const ucs: PUADEConfig); cdecl; external 'uade.dll';
  636. function uade_open_create_home: PChar; cdecl; external 'uade.dll';
  637. function uade_parse_subsongs(subsongs: Integer; option: PChar): Integer; cdecl; external 'uade.dll';
  638.  
  639. procedure uade_config_set_option(uc: PUADEConfig; opt: TUADEOption; value: PChar); cdecl; external 'uade.dll';
  640.  
  641. procedure uade_set_effects(st: PUADEState); cdecl; external 'uade.dll';
  642. procedure uade_set_ep_attributes(st: PUADEState); cdecl; external 'uade.dll';
  643. function uade_set_song_attributes(st: PUADEState; playername: PChar; playernamelen: SizeUInt): Integer; cdecl; external 'uade.dll';
  644. procedure uade_set_filter_type(uc: PUADEConfig; value: PChar); cdecl; external 'uade.dll';
  645.  
  646. function uade_set_song_options(sfile: PChar; sopt: PChar; state: PUADEState): Integer; cdecl; external 'uade.dll';
  647.  
  648. function uade_new_config: PUADEConfig; cdecl; external 'uade.dll' name 'uade_new_config';
  649.  
  650. //function uade_config_toggle_boolean(uc: TUADEConfig; opt: TUADEOption): Integer; cdecl; external 'uade.dll';
  651.  
  652. function uade_analyze_eagleplayer(detect_info: PUADEDetectionInfo;data: Pointer; data_size: integer; filename: PChar;filename_len: integer;st: PUADEState): Integer; cdecl; external 'uade.dll';
  653.  
  654. implementation
  655.  
  656. end.

« Last Edit: February 07, 2025, 12:09:01 am by Gigatron »
Sub Quantum Technology ! Gigatron 68000 Colmar France;

TRon

  • Hero Member
  • *****
  • Posts: 4151
Re: UADE Library
« Reply #2 on: February 07, 2025, 09:27:13 am »
@Tron will help me :)
Well, uhm...

Code: Bash  [Select][+][-]
  1. Content recognized: AHX (AHX.Cruisin)
  2. Content recognized: AHX (AHX.Cruisin)
  3. Player candidate: AbyssHighestExperience
  4. score path /mega/tron/project-uade/.uade/score
  5. uadecore: Amiga stack overrun warning.
  6. Illegal instruction: 7f45 at 00001000
  7. Illegal instruction: 4148 at 00000400
  8. Illegal instruction: 4148 at 00000400
  9. Illegal instruction: 4148 at 00000400
  10. Illegal instruction: 4148 at 00000400
  11. ...
  12. Illegal instruction: 4148 at 00000400
  13. Illegal instruction: 4148 at 00000400
  14. Illegal instruction: 4148 at 00000400
  15. uade_logs: {'uadecore:audio_start_time': 0.26}
  16. uade warning: Song ended prematurely due to error: the amiga player did something terribly stupid
  17. Warning: Supervisor stack may have been breached.
  18. Warning: User stack may have been breached possibly by the supervisor stack.
  19. Can not play AHX.Cruisin
  20.  

For some reason I do not seem to be able to get the core to accept anything atm, let alone be able to check any wrapper. So, might perhaps take a while  :(
Today is tomorrow's yesterday.

Gigatron

  • Full Member
  • ***
  • Posts: 202
  • Amiga Rulez !!
Re: UADE Library
« Reply #3 on: February 07, 2025, 01:50:35 pm »
Ok,
There are some issue for playing some formats , here is updated main unit witch load player file
depending extension .

** PS This is my last contribution for Lazarus audio library, after that return to DEMO WORLD :)

** EDIT Better module detection format , updated code !

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   ExtCtrls,Windows,Uade,mmsystem;
  10.  
  11. const
  12.   Channels = 2;
  13.   BitsPerSample = 16;
  14.   SampleRate = 44100; // Nombre d'échantillons par seconde
  15.   BufSize =  65536 ;    // Taille du tampon audio x 2
  16.   BufferCount = 2;
  17.  
  18.  type
  19.  
  20.   { TForm1 }
  21.  
  22.    TForm1 = class(TForm)
  23.     btnQuit: TButton;
  24.     Button1: TButton;
  25.     Timer1: TTimer;
  26.     procedure Button1Click(Sender: TObject);
  27.     procedure FormCreate(Sender: TObject);
  28.     procedure FormShow(Sender: TObject);
  29.     procedure Timer1Timer(Sender: TObject);
  30.  
  31.   private
  32.  
  33.     buffers: array[0..BufferCount-1] of array[0..BufSize-1] of SmallInt;
  34.     waveHeaders: array[0..BufferCount-1] of TWaveHdr;
  35.     currentBuffer: Integer;
  36.  
  37.   public
  38.  
  39.  
  40.  
  41.   end;
  42.  
  43. var
  44.   Form1: TForm1;
  45.  
  46.   waveOut: HWAVEOUT;
  47.   ok_flag: Boolean = false;
  48.   fsize : integer;
  49.  
  50.   uade_cfg : PUADEConfig;
  51.   uade_st  : PUADEState;
  52.   uade_mod : TUADEFile;
  53.   uade_modp : PUADEFile;
  54.   uade_sinfo : PUADESongInfo;
  55.   uade_isrmc, uade_stp, uade_sr, uade_buff_play, uade_pl:  integer;
  56.  
  57.   uade_rd  : UInt16;
  58.   uade_egp : integer;
  59.   uade_dinf  : PUADEDetectionInfo;
  60.   uade_sk : integer;
  61.  
  62.   uade_bencode   : PBEncode;
  63.  
  64.   // module in buffer
  65.   Buffer: array of Byte; // binary data song buffer
  66.   Filename: string;
  67.   // player map
  68.   PlayerMap: TStringList;
  69.  
  70. implementation
  71.  
  72. {$R *.lfm}
  73.  
  74. { TForm1 }
  75.  
  76. procedure FillBuff(bufferIndex: Integer);
  77. var
  78.   GenSmp, NumSmp : Integer;
  79. begin
  80.   if ok_flag then
  81.   begin
  82.  
  83.     bufferIndex := Form1.currentBuffer;
  84.     NumSmp := BufSize div (Channels * (BitsPerSample div 16));
  85.     GenSmp := uade_read(@Form1.buffers[bufferIndex][0],NumSmp*4, uade_st);;
  86.   end;
  87. end;
  88.  
  89. function WaveOutCallback(hwo: HWAVEOUT; uMsg: UINT; dwInstance, dwParam1, dwParam2: DWORD_PTR): DWORD; stdcall;
  90. begin
  91.   if uMsg = WOM_DONE then
  92.   begin
  93.     FillBuff(Form1.currentBuffer);
  94.     waveOutWrite(hwo, @Form1.waveHeaders[Form1.currentBuffer], SizeOf(TWaveHdr));
  95.     Form1.currentBuffer := (Form1.currentBuffer + 1) mod BufferCount;
  96.   end;
  97.   Result := 0;
  98. end;
  99.  
  100. procedure InitAudio;
  101. var
  102.   wFormat: TWaveFormatEx;
  103.   i: Integer;
  104. begin
  105.  
  106.   SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_LOWEST);
  107.  
  108.   with wFormat do
  109.   begin
  110.     wFormatTag := WAVE_FORMAT_PCM;
  111.     nChannels := Channels;
  112.     nSamplesPerSec := SampleRate;
  113.     wBitsPerSample := BitsPerSample;
  114.     nBlockAlign := (wBitsPerSample * nChannels) div 8;
  115.     nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;
  116.     cbSize := 0;
  117.   end;
  118.  
  119.   if waveOutOpen(@waveOut, WAVE_MAPPER, @wFormat, QWORD(@WaveOutCallback), 0, CALLBACK_FUNCTION) <> MMSYSERR_NOERROR then
  120.     raise Exception.Create('Erreur ouverture periph audio');
  121.  
  122.   // buffers
  123.   for i := 0 to BufferCount - 1 do
  124.   begin
  125.     ZeroMemory(@Form1.waveHeaders[i], SizeOf(TWaveHdr));
  126.      with Form1.waveHeaders[i] do
  127.     begin
  128.       lpData := @Form1.buffers[i][0];
  129.       dwBufferLength := BufSize * SizeOf(SmallInt);
  130.       dwFlags := 0;
  131.     end;
  132.     waveOutPrepareHeader(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  133.   end;
  134.   Form1.currentBuffer := 0;
  135.    for i := 0 to BufferCount - 1 do
  136.       begin
  137.         FillBuff(i);
  138.         waveOutWrite(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  139.       end;
  140.  
  141. end;
  142. // player map
  143. procedure InitializePlayerMap;
  144. begin
  145. PlayerMap := TStringList.Create;
  146. PlayerMap.Add('.mod=players/Soundtracker-IV');
  147. PlayerMap.Add('.ast=players/ActionAmics');
  148. PlayerMap.Add('.ahx=players/AbyssHighestExperience');
  149. PlayerMap.Add('.thx=players/AbyssHighestExperience');
  150. PlayerMap.Add('.adpcm=players/ADPCM_mono');
  151. PlayerMap.Add('.amc=players/AM-Composer');
  152. PlayerMap.Add('.abk=players/AMOS');
  153. PlayerMap.Add('.aam=players/ArtAndMagic');
  154. PlayerMap.Add('.alp=players/Alcatraz_Packer');
  155. PlayerMap.Add('.aon=players/ArtOfNoise-4V');
  156. PlayerMap.Add('.aon4=players/ArtOfNoise-4V');
  157. PlayerMap.Add('.aon8=players/ArtOfNoise-8V');
  158. PlayerMap.Add('.adsc=players/AudioSculpture');
  159. PlayerMap.Add('.mod_adsc4=players/AudioSculpture');
  160. PlayerMap.Add('.bss=players/BeathovenSynthesizer');
  161. PlayerMap.Add('.bd=players/BenDaglish');
  162. PlayerMap.Add('.BDS=players/BenDaglish-SID');
  163. PlayerMap.Add('.uds=players/BladePacker');
  164. PlayerMap.Add('.kris=players/ChipTracker');
  165. PlayerMap.Add('.cin=players/Cinemaware');
  166. PlayerMap.Add('.core=players/CoreDesign');
  167. PlayerMap.Add('.cus=players/custom');
  168. PlayerMap.Add('.cust=players/custom');
  169. PlayerMap.Add('.custom=players/custom');
  170. PlayerMap.Add('.cm=players/CustomMade');
  171. PlayerMap.Add('.rk=players/CustomMade');
  172. PlayerMap.Add('.rkb=players/CustomMade');
  173. PlayerMap.Add('.dz=players/DariusZendeh');
  174. PlayerMap.Add('.mkiio=players/DariusZendeh');
  175. PlayerMap.Add('.dl=players/DaveLowe');
  176. PlayerMap.Add('.dl_deli=players/DaveLowe_Deli');
  177. PlayerMap.Add('.dln=players/DaveLoweNew');
  178. PlayerMap.Add('.dh=players/DavidHanney');
  179. PlayerMap.Add('.dw=players/DavidWhittaker');
  180. PlayerMap.Add('.dwold=players/DavidWhittaker');
  181. PlayerMap.Add('.dlm2=players/Del]"]>Blockedsic2.0');
  182. PlayerMap.Add('.dm2=players/Del]"]>Blockedsic2.0');
  183. PlayerMap.Add('.dlm1=players/Del]"]>Blockedsic1.3');
  184. PlayerMap.Add('.dm1=players/Del]"]>Blockedsic1.3');
  185. PlayerMap.Add('.dsr=players/Desire');
  186. PlayerMap.Add('.db=players/DIGI-Booster');
  187. PlayerMap.Add('.digi=players/DIGI-Booster');
  188. PlayerMap.Add('.dsc=players/DigitalSonixChrome');
  189. PlayerMap.Add('.dss=players/DigitalSoundStudio');
  190. PlayerMap.Add('.dns=players/DynamicSynthesizer');
  191. PlayerMap.Add('.ems=players/EMS');
  192. PlayerMap.Add('.emsv6=players/EMS-6');
  193. PlayerMap.Add('.ex=players/FashionTracker');
  194. PlayerMap.Add('.fc13=players/FutureComposer1.3');
  195. PlayerMap.Add('.fc3=players/FutureComposer1.3');
  196. PlayerMap.Add('.fc=players/FutureComposer1.4');
  197. PlayerMap.Add('.fc14=players/FutureComposer1.4');
  198. PlayerMap.Add('.fc4=players/FutureComposer1.4');
  199. PlayerMap.Add('.fred=players/Fred');
  200. PlayerMap.Add('.gray=players/FredGray');
  201. PlayerMap.Add('.bfc=players/FutureComposer-BSI');
  202. PlayerMap.Add('.bsi=players/FutureComposer-BSI');
  203. PlayerMap.Add('.fc-bsi=players/FutureComposer-BSI');
  204. PlayerMap.Add('.fp=players/FuturePlayer');
  205. PlayerMap.Add('.fw=players/ForgottenWorlds_Game');
  206. PlayerMap.Add('.glue=players/GlueMon');
  207. PlayerMap.Add('.gm=players/GlueMon');
  208. PlayerMap.Add('.ea=players/EarAche');
  209. PlayerMap.Add('.mg=players/EarAche');
  210. PlayerMap.Add('.hd=players/HowieDavies');
  211. PlayerMap.Add('.hipc=players/JochenHippel-CoSo');
  212. PlayerMap.Add('.soc=players/JochenHippel-CoSo');
  213. PlayerMap.Add('.emod=players/QuadraComposer');
  214. PlayerMap.Add('.qc=players/QuadraComposer');
  215. PlayerMap.Add('.ims=players/ImagesMusicSystem');
  216. PlayerMap.Add('.dum=players/Infogrames');
  217. PlayerMap.Add('.is=players/InStereo');
  218. PlayerMap.Add('.is20=players/InStereo2.0');
  219. PlayerMap.Add('.jam=players/JamCracker');
  220. PlayerMap.Add('.jc=players/JamCracker');
  221. PlayerMap.Add('.jmf=players/JankoMrsicFlogel');
  222. PlayerMap.Add('.jcb=players/JasonBrooke');
  223. PlayerMap.Add('.jcbo=players/JasonBrooke');
  224. PlayerMap.Add('.jpn=players/JasonPage');
  225. PlayerMap.Add('.jpnd=players/JasonPage');
  226. PlayerMap.Add('.jp=players/JasonPage_JP');
  227. PlayerMap.Add('.jt=players/JeroenTel');
  228. PlayerMap.Add('.mon_old=players/JeroenTel');
  229. PlayerMap.Add('.jo=players/JesperOlsen');
  230. PlayerMap.Add('.hip=players/JochenHippel');
  231. PlayerMap.Add('.mcmd=players/JochenHippel');
  232. PlayerMap.Add('.sog=players/JochenHippel');
  233. PlayerMap.Add('.hip7=players/JochenHippel-7V');
  234. PlayerMap.Add('.s7g=players/JochenHippel-7V');
  235. PlayerMap.Add('.hst=players/Jochen_Hippel_ST');
  236. PlayerMap.Add('.kh=players/KrisHatlelid');
  237. PlayerMap.Add('.powt=players/Laxity');
  238. PlayerMap.Add('.pt=players/Laxity');
  239. PlayerMap.Add('.lme=players/LegglessMusicEditor');
  240. PlayerMap.Add('.mon=players/ManiacsOfNoise');
  241. PlayerMap.Add('.mfp=players/MagneticFieldsPacker');
  242. PlayerMap.Add('.hn=players/MajorTom');
  243. PlayerMap.Add('.mtp2=players/MajorTom');
  244. PlayerMap.Add('.thn=players/MajorTom');
  245. PlayerMap.Add('.mc=players/Mark_Cooksey');
  246. PlayerMap.Add('.mcr=players/Mark_Cooksey');
  247. PlayerMap.Add('.mco=players/Mark_Cooksey_Old');
  248. PlayerMap.Add('.mk2=players/MarkII');
  249. PlayerMap.Add('.mkii=players/MarkII');
  250. PlayerMap.Add('.avp=players/MartinWalker');
  251. PlayerMap.Add('.mw=players/MartinWalker');
  252. PlayerMap.Add('.max=players/Maximum_Effect');
  253. PlayerMap.Add('.mcmd_org=players/MCMD');
  254. PlayerMap.Add('.med=players/MED');
  255. PlayerMap.Add('.mmd0=players/MED');
  256. PlayerMap.Add('.mmd1=players/MED');
  257. PlayerMap.Add('.mmd2=players/MED');
  258. PlayerMap.Add('.mso=players/Medley');
  259. PlayerMap.Add('.midi=players/MIDI-Loriciel');
  260. PlayerMap.Add('.md=players/MikeDavies');
  261. PlayerMap.Add('.mmdc=players/MMDC');
  262. PlayerMap.Add('.dmu=players/Mugician');
  263. PlayerMap.Add('.mug=players/Mugician');
  264. PlayerMap.Add('.dmu2=players/MugicianII');
  265. PlayerMap.Add('.mug2=players/MugicianII');
  266. PlayerMap.Add('.ma=players/MusicAssembler');
  267. PlayerMap.Add('.mm4=players/MusicMaker-4V');
  268. PlayerMap.Add('.mm8=players/MusicMaker-8V');
  269. PlayerMap.Add('.mms=players/MultiMedia_Sound');
  270. PlayerMap.Add('.ntp=players/NovoTradePacker');
  271. PlayerMap.Add('.two=players/NTSP-system');
  272. PlayerMap.Add('.octamed=players/Octa-MED');
  273. PlayerMap.Add('.okt=players/Oktalyzer');
  274. PlayerMap.Add('.one=players/onEscapee');
  275. PlayerMap.Add('.dat=players/PaulRobotham');
  276. PlayerMap.Add('.ps=players/PaulShields');
  277. end;
  278.  
  279. function GetPlayerForExtension(const Ext: string): string;
  280. begin
  281.   Result := PlayerMap.Values[Ext];
  282. end;
  283.  
  284. procedure LoadPlayerForFile(const FilePath: string);
  285. var
  286.   Ext, Player: string;
  287. begin
  288.   Ext := LowerCase(ExtractFileExt(FilePath));
  289.   Player := GetPlayerForExtension(Ext);
  290.  
  291.   if Player <> '' then
  292.     uade_config_set_option(uade_cfg, UC_PLAYER_FILE, PChar(Player))
  293.   else
  294.     ShowMessage('No Player Found !!! : ' + FilePath);
  295. end;
  296.  
  297.  
  298. procedure LoadBinaryFileToBuffer(const FileName: string; var Buffer:   TBytes);
  299. var
  300.   MemoryStream: TMemoryStream;
  301. begin
  302.   MemoryStream := TMemoryStream.Create;
  303.   try
  304.     MemoryStream.LoadFromFile(FileName);
  305.     SetLength(Buffer, MemoryStream.Size); // Ajuste la taille du buffer
  306.     MemoryStream.ReadBuffer(Buffer[0], MemoryStream.Size);
  307.     fsize := MemoryStream.Size;
  308.   finally
  309.     MemoryStream.Free;
  310.   end;
  311. end;
  312.  
  313. procedure TForm1.FormCreate(Sender: TObject);
  314.  
  315. begin
  316.   InitializePlayerMap;
  317. end;
  318.  
  319. procedure TForm1.FormShow(Sender: TObject);
  320. begin
  321.  
  322.   // FileName:='songs/JTG.mk2';
  323.   // FileName:='songs/amegas.mod';
  324.   // FileName:='songs/jugtitle.ps';
  325.      FileName:='songs/jug-ingame.ps';
  326.   //   FileName:='songs/airball-intro.ps';
  327.    //FileName:='songs/cruisin.ahx';       // not working external samples !!!
  328.   // FileName:='songs/the viking child crack.cm';
  329.  
  330.   try
  331.     LoadBinaryFileToBuffer(FileName, Buffer);
  332.  
  333.   except
  334.     on E: Exception do
  335.       ShowMessage('Erreur : ' );
  336.   end;
  337.  
  338.    uade_cfg := uade_new_config;
  339.    LoadPlayerForFile(filename); // load player depending file module extension !
  340.  
  341.    uade_config_set_option(uade_cfg, UC_SCORE_FILE,Pchar('score'));
  342.    uade_config_set_option(uade_cfg, UC_UAE_CONFIG_FILE,Pchar('uade.conf'));
  343.    uade_config_set_option(uade_cfg, UC_ONE_SUBSONG, nil);
  344.    uade_config_set_option(uade_cfg, UC_IGNORE_PLAYER_CHECK, nil);
  345.    uade_config_set_option(uade_cfg, UC_NO_EP_END, Nil);
  346.    uade_config_set_option(uade_cfg, UC_FREQUENCY, Pchar('44100'));
  347.  
  348.    uade_st := uade_new_state(uade_cfg);
  349.  
  350.    uade_sr := uade_get_sampling_rate(uade_st);
  351.    uade_buff_play := uade_play_from_buffer(nil,@buffer[0], Length(buffer),-1,uade_st);
  352.  
  353.    uade_sinfo := uade_get_song_info(uade_st); // song info
  354.  
  355.    InitAudio;
  356.    ok_flag := true;
  357. end;
  358.  
  359. procedure TForm1.Button1Click(Sender: TObject);
  360.  
  361. begin
  362.   uade_effect_toggle(uade_st, TUADEEffect.UADE_EFFECT_PAN);
  363.   uade_effect_enable(uade_st, TUADEEffect.UADE_EFFECT_ALLOW);
  364.  
  365. end;
  366.  
  367. procedure TForm1.Timer1Timer(Sender: TObject);
  368. begin
  369.  
  370. end;
  371.  
  372. end.
  373.  
  374.  
« Last Edit: February 07, 2025, 03:36:27 pm by Gigatron »
Sub Quantum Technology ! Gigatron 68000 Colmar France;

Gigatron

  • Full Member
  • ***
  • Posts: 202
  • Amiga Rulez !!
Re: UADE Library
« Reply #4 on: February 10, 2025, 05:57:57 pm »
Hi, i am now on my workstation :)

This is the 3rd version of the Uade library, so be careful, I had some program crashes : Win10 X64 with some modules like .ahx or
.tfmx not working yet !

Disclaimer : This software is provided as-is. The author makes absolutely no warranties on it.
You use it at your own risk. The author shall not be held responsible for any
damage that may result from its use.


The library and additional files are big 5mb in this case:
You can download all files (dll, songs, players , project ... ) from my ftp server and look the project structure to see how uade working;

http://gigatron3k.free.fr/lazarus/Uade_lib4.zip

UADE Credits : https://zakalwe.fi/uade/  base source
                      https://github.com/arnaud-neny/rePlayer  Dll
                      https://github.com/HippoPlayer/HippoPlayer Help source


Supported and tested formats are in the listbox : 


Regards

Gigatron
             
« Last Edit: February 10, 2025, 06:00:19 pm by Gigatron »
Sub Quantum Technology ! Gigatron 68000 Colmar France;

Guva

  • Full Member
  • ***
  • Posts: 146
  • 🌈 ZX-Spectrum !!!
Re: UADE Library
« Reply #5 on: February 13, 2025, 02:54:05 pm »
@TRon Did you manage to make it work under linux?

I get access violation for any action. And another incomprehensible warning.

Quote
uade warning: Could not execute uaerc
Exception at 0000771D780A58A4: EAccessViolation:

Gigatron

  • Full Member
  • ***
  • Posts: 202
  • Amiga Rulez !!
Re: UADE Library
« Reply #6 on: February 13, 2025, 09:46:08 pm »
Well,
I'm not satisfied with UADE library, it doesn't play all the formats I wanted. However for now you do not need to load the players they are included in the library.

Here a simplified Main unit ; The Dll is not changed .

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   ExtCtrls, Spin,Windows,Uade,mmsystem;
  10.  
  11. const
  12.   Channels = 2;
  13.   BitsPerSample = 16;
  14.   SampleRate = 44100; // Nombre d'échantillons par seconde
  15.   BufSize =  65536 ;    // Taille du tampon audio x 2     65536
  16.   BufferCount = 2;
  17.  
  18.  type
  19.  
  20.   { TForm1 }
  21.  
  22.    TForm1 = class(TForm)
  23.     btnQuit: TButton;
  24.     Button1: TButton;
  25.     Label1: TLabel;
  26.     ListBox1: TListBox;
  27.     Memo1: TMemo;
  28.     SpinEdit1: TSpinEdit;
  29.     procedure Button1Click(Sender: TObject);
  30.     procedure FormCreate(Sender: TObject);
  31.     procedure FormShow(Sender: TObject);
  32.     procedure ListBox1SelectionChange(Sender: TObject; User: boolean);
  33.     procedure SpinEdit1Change(Sender: TObject);
  34.     procedure LoadModule;
  35.     procedure Module_Info;
  36.  
  37.   private
  38.  
  39.     buffers: array[0..BufferCount-1] of array[0..BufSize-1] of SmallInt;
  40.     waveHeaders: array[0..BufferCount-1] of TWaveHdr;
  41.     currentBuffer: Integer;
  42.  
  43.   public
  44.  
  45.   end;
  46.  
  47. var
  48.   Form1: TForm1;
  49.  
  50.   waveOut: HWAVEOUT;
  51.   ok_flag: Boolean = false;
  52.   fsize : integer;
  53.  
  54.   uade_cfg : PUADEConfig;
  55.   uade_st  : PUADEState;
  56.   uade_st1  : PUADEState;
  57.  
  58.  
  59.   uade_mod : TUADEFile;
  60.   uade_modp : PUADEFile;
  61.   uade_get_sinfo : PUADESongInfo;
  62.   uade_isrmc, uade_stp, uade_sr,  uade_pl,uade_epinfo,sinfo:  integer;
  63.  
  64.   uade_buff_play : integer;
  65.   uade_rd  : integer;
  66.   uade_egp : integer;
  67.   uade_epdinf  : PUADEDetectionInfo;
  68.   uade_sk : integer;
  69.  
  70.   uade_bencode   : PBEncode;
  71.   sinfo_char : array [0..16383]  of Char;
  72.  
  73.   uade_evt : integer;
  74.   uade_evtnot : TUADENotification;
  75.  
  76.   // module in buffer
  77.   Buffer: array of Byte; // binary data song buffer
  78.  
  79.   Filename: string;
  80.   s_infot : integer;
  81.  
  82.   var
  83.   UADEStates: TList;
  84.  
  85. implementation
  86.  
  87. {$R *.lfm}
  88.  
  89. { TForm1 }
  90.  
  91. procedure FillBuff(bufferIndex: Integer);
  92. var
  93.   GenSmp, NumSmp : Integer;
  94. begin
  95.   if ok_flag then
  96.   begin
  97.  
  98.     bufferIndex := Form1.currentBuffer;
  99.     NumSmp := BufSize div (Channels * (BitsPerSample div 16));
  100.     GenSmp := uade_read(@Form1.buffers[bufferIndex][0],NumSmp*4, uade_st);
  101.   end;
  102. end;
  103.  
  104. function WaveOutCallback(hwo: HWAVEOUT; uMsg: UINT; dwInstance, dwParam1, dwParam2: DWORD_PTR): DWORD; stdcall;
  105. begin
  106.   if uMsg = WOM_DONE then
  107.   begin
  108.     if ok_flag then  FillBuff(Form1.currentBuffer);
  109.     waveOutWrite(hwo, @Form1.waveHeaders[Form1.currentBuffer], SizeOf(TWaveHdr));
  110.     Form1.currentBuffer := (Form1.currentBuffer + 1) mod BufferCount;
  111.   end;
  112.   Result := 0;
  113. end;
  114.  
  115. procedure InitAudio;
  116. var
  117.   wFormat: TWaveFormatEx;
  118.   i: Integer;
  119. begin
  120.  
  121.   SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_LOWEST);
  122.  
  123.   with wFormat do
  124.   begin
  125.     wFormatTag := WAVE_FORMAT_PCM;
  126.     nChannels := Channels;
  127.     nSamplesPerSec := SampleRate;
  128.     wBitsPerSample := BitsPerSample;
  129.     nBlockAlign := (wBitsPerSample * nChannels) div 8;
  130.     nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;
  131.     cbSize := 0;
  132.   end;
  133.  
  134.   if waveOutOpen(@waveOut, WAVE_MAPPER, @wFormat, QWORD(@WaveOutCallback), 0, CALLBACK_FUNCTION) <> MMSYSERR_NOERROR then
  135.     raise Exception.Create('Erreur ouverture periph audio');
  136.  
  137.   // buffers
  138.   for i := 0 to BufferCount - 1 do
  139.   begin
  140.     ZeroMemory(@Form1.waveHeaders[i], SizeOf(TWaveHdr));
  141.      with Form1.waveHeaders[i] do
  142.     begin
  143.       lpData := @Form1.buffers[i][0];
  144.       dwBufferLength := BufSize * SizeOf(SmallInt);
  145.       dwFlags := 0;
  146.     end;
  147.     waveOutPrepareHeader(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  148.   end;
  149.   Form1.currentBuffer := 0;
  150.    for i := 0 to BufferCount - 1 do
  151.       begin
  152.         FillBuff(i);
  153.         waveOutWrite(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  154.       end;
  155.  
  156. end;
  157.  
  158. procedure ResetPlayback;
  159. var
  160.   i: Integer;
  161. begin
  162.   ok_flag := False;
  163.   if uade_st <> nil then
  164.   begin
  165.   uade_stop(uade_st);
  166.   end;
  167.  
  168.   // Réinitialiser les buffers waveOut
  169.   if waveOut <> 0 then
  170.   begin
  171.    // waveOutReset(waveOut);
  172.     for i := 0 to BufferCount - 1 do
  173.     begin
  174.       waveOutUnprepareHeader(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  175.     end;
  176.     waveOutClose(waveOut);
  177.     waveOut := 0;
  178.   end;
  179.  
  180. end;
  181.  
  182. procedure LoadBinaryFileToBuffer(const FileName: string; var Buffer:   TBytes);
  183. var
  184.   MemoryStream: TMemoryStream;
  185. begin
  186.   MemoryStream := TMemoryStream.Create;
  187.   try
  188.     MemoryStream.LoadFromFile(FileName);
  189.     SetLength(Buffer, MemoryStream.Size); // Ajuste la taille du buffer
  190.     MemoryStream.ReadBuffer(Buffer[0], MemoryStream.Size);
  191.     fsize := MemoryStream.Size;
  192.   finally
  193.     MemoryStream.Free;
  194.   end;
  195. end;
  196.  
  197. procedure TForm1.FormCreate(Sender: TObject);
  198. begin
  199. end;
  200.  
  201. procedure TForm1.FormShow(Sender: TObject);
  202. begin
  203.   InitAudio;
  204. end;
  205.  
  206. procedure TForm1.ListBox1SelectionChange(Sender: TObject; User: boolean);
  207. begin
  208.        LoadModule;
  209. end;
  210.  
  211. procedure TForm1.Button1Click(Sender: TObject);
  212. begin
  213.   uade_effect_toggle(uade_st, TUADEEffect.UADE_EFFECT_PAN);
  214.   uade_effect_enable(uade_st, TUADEEffect.UADE_EFFECT_ALLOW);
  215. end;
  216.  
  217. // select subsong !!
  218. procedure TForm1.SpinEdit1Change(Sender: TObject);
  219. begin
  220.      SpinEdit1.MaxValue := uade_get_sinfo^.Subsongs.Max;
  221.      uade_seek(TUADESeekMode.UADE_SEEK_SUBSONG_RELATIVE,0,SpinEdit1.Value,uade_st);
  222. end;
  223.  
  224. // load module
  225. procedure TForm1.LoadModule;
  226. var
  227.     insertPosition: Integer;     // Position d'insertion
  228.     en : integer;
  229. begin
  230.   ResetPlayback;
  231.   SetLength(Buffer, 0); // Réinitialisation du buffer
  232.  
  233.   try
  234.  
  235.     LoadBinaryFileToBuffer('songs/' + ListBox1.Items[ListBox1.ItemIndex], Buffer);
  236.  
  237.     if Length(Buffer) = 0 then
  238.     begin
  239.       ShowMessage('Erreur : Impossible de charger ' + FileName);
  240.       Exit;
  241.     end;
  242.  
  243.   except
  244.     on E: Exception do
  245.     begin
  246.       ShowMessage('Erreur Fichier : ' + E.Message);
  247.       Exit;
  248.     end;
  249.   end;
  250.  
  251.    uade_cfg := uade_new_config;
  252.  
  253.   // UADE new state
  254.    uade_st := uade_new_state(uade_cfg);
  255.    uade_sr := uade_get_sampling_rate(uade_st);
  256.    uade_buff_play := uade_play_from_buffer(Pchar(ListBox1.Items[ListBox1.ItemIndex]), @Buffer[0], Length(Buffer),-1, uade_st);
  257.    uade_get_sinfo := uade_get_song_info(uade_st);
  258.  
  259.    SpinEdit1.Value := uade_get_sinfo^.Subsongs.Max;
  260.  
  261.    Module_Info;  // Call Module Information
  262.    ok_flag := True;
  263.    Finalize(Buffer)
  264. end;
  265.  
  266. // Module Information
  267. Procedure TForm1.Module_Info;
  268. var i : Integer;
  269. begin
  270.  
  271.    Label1.Caption:=uade_get_sinfo^.DetectionInfo.Ext;
  272.    // some mod infos
  273.    Memo1.Clear;
  274.    for i:=0 to 255 do
  275.    memo1.Text:= memo1.text + uade_get_sinfo^.ModuleFName[i];
  276.    memo1.Text:= memo1.text + #13#10;
  277.  
  278.    for i:=0 to 255 do
  279.    memo1.Text:= memo1.text + uade_get_sinfo^.PlayerName[i];
  280.    memo1.Text:= memo1.text + #13#10;
  281.  
  282.    for i:=0 to 255 do
  283.    memo1.Text:= memo1.text + uade_get_sinfo^.FormatName[i];
  284.    memo1.Text:= memo1.text + #13#10;
  285.  
  286.    memo1.Text:= memo1.text + 'Sub-Songs : ' + IntToStr(uade_get_sinfo^.Subsongs.Max);
  287.  
  288. end;
  289.  
  290. end.
  291.  

Sub Quantum Technology ! Gigatron 68000 Colmar France;

TRon

  • Hero Member
  • *****
  • Posts: 4151
Re: UADE Library
« Reply #7 on: February 13, 2025, 10:03:14 pm »
@TRon Did you manage to make it work under linux?
Unfortunately I was not able to work on UADE so did not have any progress to report. Sorry for that.

Quote
I get access violation for any action. And another incomprehensible warning.
That looks like a configuration issue. I'll try and see if I am able to work on it this weekend. You should at least be able to load the UAE kernel.

I'm not satisfied with UADE library, it doesn't play all the formats I wanted. However for now you do not need to load the players they are included in the library.
I am starting to wonder if the v3 version of UADE changed significantly for the players to fail. I have had very good experience with UADE in the past (which was the reason to mention it in the first place).

I have seen many reports in the issue tracker of UADE about player related issues though.
Today is tomorrow's yesterday.

TRon

  • Hero Member
  • *****
  • Posts: 4151
Re: UADE Library
« Reply #8 on: February 18, 2025, 10:23:16 pm »
@TRon Did you manage to make it work under linux?
Yes and no  :)

Yes, as in it seem that I've managed to compile all the necessary dependencies, the library and what not and no because:
Code: [Select]
symbol lookup error: lib/libuade.so: undefined symbol: ben_free

I used following sources:
- UADE v3.05
- bencodetools v1.0.1
- zakalwe v1.0.0

In case someone has an idea....
« Last Edit: February 18, 2025, 10:48:24 pm by TRon »
Today is tomorrow's yesterday.

Guva

  • Full Member
  • ***
  • Posts: 146
  • 🌈 ZX-Spectrum !!!
Re: UADE Library
« Reply #9 on: February 19, 2025, 01:59:45 am »
Code: [Select]
symbol lookup error: lib/libuade.so: undefined symbol: ben_free

zakalwe seems to be needed only for examples and the player.
Uade cannot pick up bencodetools. I couldn't even do it locally using the /usr/local/lib path. I had to throw it in the usr/lib folder.

TRon

  • Hero Member
  • *****
  • Posts: 4151
Re: UADE Library
« Reply #10 on: February 19, 2025, 05:24:08 am »
zakalwe seems to be needed only for examples and the player.
And the uade core. Can be verified by ldd on the resulted core from the uae build.

Quote
Uade cannot pick up bencodetools. I couldn't even do it locally using the /usr/local/lib path. I had to throw it in the usr/lib folder.
Thank you for the hint but unfortunately not even that seem to have the desired effect (of getting rid of the message).

What is even more confusing is that I am almost there while the error message remains.

The configuration seems to load/modify correctly now (very finicky btw), the core seems to load as expected (it runs at least though issues with IPC), the module actually loads and is recognized without issues... though the correct player does not load. Still to do is the actual play-loop (but I call it quits for today because practice has already shown that there are a bunch of issue with some players. I do not have enough time to dive into those issues today).



Sweet the taste, victory is  :)

Code: [Select]
./play_uade_ao music/AHX.Cruisin
INFO: initialize ao
INFO: ao initialized
INFO: ao live mode opened
INFO: CfgDir = /media/projects/fpc/delitracker/.uade
INFO: uade configured
INFO: uade state set
INFO: sampling rate = 44100
INFO: is verbose = 1 (1 = yes)
INFO: loading module file music/AHX.Cruisin
INFO: UADE attempt to "play" the module from memory buffer
Content recognized: AHX ()
Player candidate: AbyssHighestExperience
score path /media/projects/fpc/delitracker/.uade/score
Got Amiga message before playloop: open library dos.library
Amiga requests file: ENV:EaglePlayer/ahx
Sending file: /media/projects/fpc/delitracker/.uade/players/ENV/EaglePlayer/ahx
Got Amiga message before playloop: filesize: file ENV:EaglePlayer/ahx res 0x1a
Got Amiga message before playloop: read: ENV:EaglePlayer/ahx dst 0x1586c off 0x0 len 0x100 bytesread 0x1a
Amiga requests file: ENV:EaglePlayer/ahx.waves
Sending file: /media/projects/fpc/delitracker/.uade/players/ENV/EaglePlayer/ahx.waves
Got Amiga message before playloop: filesize: file ENV:EaglePlayer/ahx.waves res 0x64488
Got Amiga message before playloop: read: ENV:EaglePlayer/ahx.waves dst 0x1586c off 0x0 len 0x64488 bytesread 0x64488

subsong: 0 from range [0, 0]
INFO: play song
INFO: Module loaded into UADE buffer
uade_logs: {'uadecore:audio_start_time': 0.97}
INFO: Song ended
INFO: Cleanup uade state
./play_uade_ao: symbol lookup error: lib/libuade.so: undefined symbol: ben_free


./play_uade_ao music/flimbo\'s\ quest.mon
INFO: initialize ao
INFO: ao initialized
INFO: ao live mode opened
INFO: CfgDir = /media/projects/fpc/delitracker/.uade
INFO: uade configured
INFO: uade state set
INFO: sampling rate = 44100
INFO: is verbose = 1 (1 = yes)
INFO: loading module file music/flimbo's quest.mon
INFO: UADE attempt to "play" the module from memory buffer
Content recognized: MON ()
Player candidate: ManiacsOfNoise
score path /media/projects/fpc/delitracker/.uade/score

subsong: 1 from range [1, 12]
INFO: play song
INFO: Module loaded into UADE buffer
uade_logs: {'uadecore:audio_start_time': 0.05}


./play_uade_ao music/projectx.mod
INFO: initialize ao
INFO: ao initialized
INFO: ao live mode opened
INFO: CfgDir = /media/projects/fpc/delitracker/.uade
INFO: uade configured
INFO: uade state set
INFO: sampling rate = 44100
INFO: is verbose = 1 (1 = yes)
INFO: loading module file music/projectx.mod
INFO: UADE attempt to "play" the module from memory buffer
Content recognized: MOD ()
Player candidate: PTK-Prowiz
Boolean option always_ends set.
Boolean option detect_format_by_content set.
Using eagleplayer option type:pt30
score path /media/projects/fpc/delitracker/.uade/score
Got Amiga message before playloop: open library uade.library
Got Amiga message before playloop: score issued an info request: eagleoptions (maxlen 256)
Got Amiga message before playloop: reply to score: type:pt30 (total len 10)
Got Amiga message before playloop: type:pt30

subsong: 1 from range [1, 1]
INFO: play song
INFO: Module loaded into UADE buffer
uade_logs: {'uadecore:audio_start_time': 0.83}
INFO: Song ended
INFO: Cleanup uade state
./play_uade_ao: symbol lookup error: lib/libuade.so: undefined symbol: ben_free

Though, the annoying symbol missing message stays. One of the weirdest things seen lately.

I'll try and see if I'm able to smash something together coming weekend.
« Last Edit: February 20, 2025, 04:13:24 am by TRon »
Today is tomorrow's yesterday.

Guva

  • Full Member
  • ***
  • Posts: 146
  • 🌈 ZX-Spectrum !!!
Re: UADE Library
« Reply #11 on: February 23, 2025, 07:25:25 am »
Hi @TRon I do not know if a message has been sent to you (for some reason it does not display the sent ones), just in case, I will duplicate it.

Quote
I also have issues with the build-system of UADE (at least I think that is the culprit) because no matter what, UADE refuses to find/load libbencode dynamically and/or link against it (same for libm) while the build output seems to suggest that it does.

You should probably add
uade-music-player/uade/src/Makefile.in

Quote
LIBRARIES = -lm $(AUDIOLIBS) $(ARCHLIBS) -lzakalwe
to LIBRARIES = -lm $(AUDIOLIBS) $(ARCHLIBS) -lzakalwe -lpthread -ldl

# pthread for threads, although I'm not sure what will work, but let it be.

# dl for working with dynamic libraries.


TRon

  • Hero Member
  • *****
  • Posts: 4151
Re: UADE Library
« Reply #12 on: February 23, 2025, 07:54:08 am »
Yeah, I just replied a moment ago. I was a bit busy.

Thank you very much for your findings, it is very much appreciated. I'll give these suggestions a spin tomorrow.
Today is tomorrow's yesterday.

TRon

  • Hero Member
  • *****
  • Posts: 4151
Re: UADE Library
« Reply #13 on: February 23, 2025, 04:53:29 pm »
Unfortunately that didn't had the desired result, thank you for the suggestion though.

In the version that uses the libao back-end it (stil)l complains about "./play_uade_ao: symbol lookup error: lib/libuade.so: undefined symbol: ben_free" and the version that uses raylib as back-end "./play_uade_rla: symbol lookup error: lib/libuade.so: undefined symbol: strlcpy".

With regards to raylib (which works just fine using other decoders), it is literally the first function that is called in libuade ( uade_new_config() ) and also quite literally the first function to be invoked at all inside the player (minus the parameter handling). To be clear, that works fine when using libao as back-end.

Any hints appreciated ( original c repository )

Code: Bash  [Select][+][-]
  1. ldd lib/libuade.so
  2. linux-vdso.so.1 (0x00007fff6b3a8000)
  3. libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa5f6a27000)
  4. /lib64/ld-linux-x86-64.so.2 (0x00007fa5f6c46000)
  5.  
« Last Edit: February 23, 2025, 05:58:20 pm by TRon »
Today is tomorrow's yesterday.

TRon

  • Hero Member
  • *****
  • Posts: 4151
Re: UADE Library
« Reply #14 on: February 23, 2025, 05:44:56 pm »
@Gigatron:
Did you just stuffed everything inside the DLL ?

BTW for loading files:
Code: Pascal  [Select][+][-]
  1.   uade_file := uade_file_load(pchar(Filename));
  2.   PrintStatus( assigned(uade_file), 'uade file loaded', 'unable to load uade file' );
  3.   PrintInfo('uade_file.data = %p', [pointer(uade_file^.data)]);
  4.   PrintInfo('uade_file.size = %d', [uade_file^.size]);
  5.  
  6.   retval := uade_play_from_buffer(nil, uade_file^.data, uade_file^.size, -1, uade_state);
  7.   PrintStatus( retval = 1, 'play song', 'play song failure' );
  8.   uade_file_free(uade_file);
  9.  
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018