Recent

Author Topic: Sid Player  (Read 6306 times)

Gigatron

  • Full Member
  • ***
  • Posts: 176
  • Amiga Rulez !!
Sid Player
« on: December 30, 2024, 11:20:05 pm »
Ok , here is another of my work ;
The famous C64 sid player :


https://github.com/libsidplayfp/sidplayfp
sidplayfp is a C64 music player which uses the libsidplayfp engine
to provide the best SID listening experience.

Copyright (c) 2000 Simon White
Copyright (c) 2007-2010 Antti Lankila
Copyright (c) 2010-2024 Leandro Nini <drfiemost@users.sourceforge.net>

Ok right now it's bugged and some functions are not working , the song is played badly .. i am working on it :
No sid module is atached yet , only the x64 library of sid player !
Have fun


The 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, ExtCtrls, sid_lib,
  9.   mmsystem, windows;
  10.  
  11. const
  12.   Channels = 1;
  13.   BitsPerSample = 16;
  14.   SampleRate = 44100; // Nombre d'Ă©chantillons par seconde
  15.   BufSize = 4096;    // Taille du tampon audio x 2
  16.   BufferCount = 2;
  17.  
  18. type
  19.   { TForm1 }
  20.  
  21.   TForm1 = class(TForm)
  22.     Timer1: TTimer;
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure FormShow(Sender: TObject);
  25.     procedure Timer1Timer(Sender: TObject);
  26.   private
  27.     buffers: array[0..BufferCount-1] of array[0..BufSize-1] of   SmallInt;
  28.     waveHeaders: array[0..BufferCount-1] of TWaveHdr;
  29.     currentBuffer: Integer;
  30.   public
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.   waveOut: HWAVEOUT;
  36.   sid_mus : pointer;
  37.   ok_flag: Boolean = false;
  38.   fsize : integer;
  39.   // sid
  40.   s_config : TSidConfig;
  41.  
  42.   s_kernal,s_basic,s_chargen : Pointer;
  43.  
  44.  
  45. implementation
  46.  
  47. {$R *.lfm}
  48.  
  49. procedure HandleError(const Str: PAnsiChar);
  50. begin
  51.   if Str <> nil then
  52.   begin
  53.     ShowMessage('Error: ' + Str);
  54.     Halt(1);
  55.   end;
  56. end;
  57.  
  58. procedure FillBuffer(bufferIndex: Integer);
  59. var
  60. GenSmp, NumSmp,sid_sng: Integer;
  61. begin
  62.  
  63.   if ok_flag then
  64.   begin
  65.  
  66.         bufferIndex := Form1.currentBuffer;
  67.        NumSmp :=  BufSize div (Channels * (BitsPerSample div 16));
  68.        GenSmp := sid_play(@Form1.buffers[0][0],NumSmp) ;
  69.  
  70.  
  71.      end;
  72. end;
  73.  
  74. function WaveOutCallback(hwo: HWAVEOUT; uMsg: UINT; dwInstance, dwParam1, dwParam2: DWORD_PTR): DWORD; stdcall;
  75. begin
  76.   if uMsg = WOM_DONE then
  77.   begin
  78.     FillBuffer(Form1.currentBuffer);
  79.     waveOutWrite(waveOut, @Form1.waveHeaders[Form1.currentBuffer], SizeOf(TWaveHdr));
  80.     Form1.currentBuffer := (Form1.currentBuffer + 1) mod BufferCount;
  81.   end;
  82.   Result := 0;
  83. end;
  84.  
  85. procedure InitAudio;
  86. var
  87.   wFormat: TWaveFormatEx;
  88.   i: Integer;
  89. begin
  90.   SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_LOWEST);
  91.  
  92.   with wFormat do
  93.   begin
  94.    wFormatTag := WAVE_FORMAT_PCM;
  95.    nChannels := Channels;
  96.     nSamplesPerSec := SampleRate;
  97.     wBitsPerSample := BitsPerSample;
  98.     nBlockAlign := (wBitsPerSample * nChannels) div 8;
  99.     nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;
  100.     cbSize := 0;
  101.   end;
  102.  
  103.   if waveOutOpen(@waveOut, WAVE_MAPPER, @wFormat, QWORD(@WaveOutCallback), 0, CALLBACK_FUNCTION) <> MMSYSERR_NOERROR then
  104.     raise Exception.Create('Erreur lors de l''ouverture du pĂ©riphĂ©rique audio');
  105.  
  106.   // PrĂ©paration des tampons
  107.   for i := 0 to BufferCount - 1 do
  108.   begin
  109.     ZeroMemory(@Form1.waveHeaders[i], SizeOf(TWaveHdr));
  110.     with Form1.waveHeaders[i] do
  111.     begin
  112.       lpData := @Form1.buffers[i][0];
  113.       dwBufferLength := BufSize  ;
  114.       dwFlags := 0;
  115.        FillBuffer(i);
  116.     end;
  117.     waveOutPrepareHeader(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  118.   end;
  119.     Form1.currentBuffer := 0;
  120.     for i := 0 to BufferCount - 1 do
  121.      begin
  122.      FillBuffer(i);
  123.      waveOutWrite(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  124.     end;
  125. end;
  126.  
  127. procedure LoadBinaryFileToBuffer(const FileName: string; var Buffer:   TBytes);
  128. var
  129.   MemoryStream: TMemoryStream;
  130. begin
  131.   MemoryStream := TMemoryStream.Create;
  132.   try
  133.     MemoryStream.LoadFromFile(FileName);
  134.     SetLength(Buffer, MemoryStream.Size);   //taille du buffer
  135.     MemoryStream.ReadBuffer(Buffer[0], MemoryStream.Size);
  136.     fsize := MemoryStream.Size;
  137.   finally
  138.     MemoryStream.Free;
  139.   end;
  140. end;
  141.  
  142. procedure LoadBinaryFileToPointer(const FileName: Pchar; var Buffer: Pointer; var FileSize: Integer);
  143. var
  144.   fs: TFileStream;
  145. begin
  146.   // VĂ©rifier si le fichier existe     if not FileExists(FileName) then
  147.     raise Exception.Create('Erreur : Fichier introuvable - ' + FileName);
  148.  
  149.   fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  150.   try
  151.     FileSize := fs.Size; // Taille du fichier
  152.     fsize := fs.Size;
  153.     GetMem(Buffer, FileSize);
  154.     fs.Read(Buffer^, FileSize);
  155.   finally
  156.     fs.Free;
  157.   end;
  158. end;
  159.  
  160. procedure TForm1.FormCreate(Sender: TObject);
  161.  var
  162.   Sid_buff: array of Byte;
  163.  
  164.   // roms
  165.   k_buff  : array of Byte;
  166.   b_buff  : array of Byte;
  167.   c_buff  : array of Byte;
  168.  
  169.   sid_cr : Pointer;
  170.   sid_ld : Boolean;
  171.   sid_cfg : Boolean;
  172.   sid_sng : integer;
  173.   song_state : Boolean;
  174.  begin
  175.  
  176.   try
  177.      // LoadBinaryFileToBuffer('Miami_vice.mus', Sid_buff);   // buffer load
  178.     //  LoadBinaryFileToBuffer('Miami_Vice.sid', Sid_buff);   // buffer load
  179.        LoadBinaryFileToBuffer('gyruss.psid', Sid_buff);   // buffer load
  180.  
  181.   except
  182.     on E: Exception do
  183.       ShowMessage('Erreur : ' );
  184.   end;
  185.  
  186.       // load c64 roms !
  187.        LoadBinaryFileToBuffer('kernal.901227-03.bin',     k_buff);
  188.        LoadBinaryFileToBuffer('basic.901226-01.bin',      b_buff);
  189.        LoadBinaryFileToBuffer('characters.901225-01.bin', c_buff);
  190.  
  191.        sid_cr := sid_Create;
  192.        sid_ld := sid_load(Pchar(sid_Buff),fsize);
  193.        ShowMessage('config ok  : ' );
  194.        sid_cfg := sid_Config();
  195.  
  196.   end;
  197.  
  198. procedure TForm1.FormShow(Sender: TObject);
  199.   var
  200.    sid_sng : integer; // in case
  201.  
  202. begin
  203.      InitAudio;
  204.      ok_flag := true;
  205.  
  206. end;
  207.  
  208. procedure TForm1.Timer1Timer(Sender: TObject);
  209. begin
  210.  
  211. end;
  212.  
  213. end.
  214.  

sid lib unit :

Code: Pascal  [Select][+][-]
  1. unit sid_lib;
  2.  
  3.  
  4. {$mode objfpc}{$H+}
  5.  
  6. interface
  7.  
  8. uses
  9.     windows;
  10.  
  11.   const
  12.  
  13.   MAX_POWER_ON_DELAY = $1FFF;
  14.   DEFAULT_POWER_ON_DELAY: UInt16 = MAX_POWER_ON_DELAY; //+1;
  15.   DEFAULT_SAMPLING_FREQ: UInt32 = 44100;
  16.  
  17.   SIDLIB = 'SidPlay.dll';
  18.  
  19. type
  20.  TUint8 = Byte;
  21.   PUint8 = ^TUint8;
  22.   TUint32 = Cardinal;
  23.   TUint16 = Word;
  24.  
  25.   TShortArray = array[0..0] of SmallInt;
  26.   PShortArray = ^TShortArray;
  27.  
  28. playback_t        = ( MONO = 1, STEREO);
  29. sid_model_t       = (MOS6581, MOS8580);
  30. sid_cw_t          = (AVERAGE, WEAK, STRONG);
  31. cia_model_t       = (MOS6526, MOS8521, MOS6526W4485);
  32. c64_model_t       = (PAL, NTSC, OLD_NTSC, DREAN, PAL_M);
  33. sampling_method_t = (INTERPOLATE, RESAMPLE_INTERPOLATE);
  34.  
  35.  
  36.  PSidConfig = ^TSidConfig;
  37.  TSidConfig = class
  38.   public
  39.  
  40.     DefaultC64Model: c64_model_t;
  41.     ForceC64Model: Boolean;
  42.     DefaultSidModel: sid_model_t;
  43.     ForceSidModel: Boolean;
  44.     DigiBoost: Boolean;
  45.     CiaModel: cia_model_t;
  46.     Playback: playback_t;
  47.     Frequency: UInt32;
  48.     SecondSidAddress: UInt16;
  49.     ThirdSidAddress: UInt16;
  50.     SidEmulation: Pointer;
  51.     LeftVolume: UInt32;
  52.     RightVolume: UInt32;
  53.     PowerOnDelay: UInt16;
  54.     FastSampling: Boolean;
  55.  
  56.    // function Compare(const Config: TSidConfig): Boolean;
  57.   end;
  58.  
  59.  
  60.  
  61.  
  62. //function sid_Load_Rom(path : PChar; romSize : Integer):Pchar;cdecl; external SIDLIB;
  63.  
  64.   procedure sid_SetRoms(kernal, basic, character: Byte); cdecl; external SIDLIB;
  65.   procedure sid_Set_Kernal(rom: PUint8); cdecl; external SIDLIB;
  66.   procedure sid_Set_Basic(rom: PUint8); cdecl; external SIDLIB;
  67.   procedure sid_Set_Chargen(rom: PUint8); cdecl; external SIDLIB;
  68.   function sid_Select_Song(song: integer):integer; cdecl; external SIDLIB;
  69.   function sid_Create(): Pointer; cdecl; external SIDLIB;
  70.   function sid_Config(): Boolean; cdecl; external SIDLIB;
  71.   function error(): PChar; cdecl; external SIDLIB;
  72.  // function fastForward(percent: TUint32): Boolean; cdecl; external SIDLIB;
  73.   function sid_load(oneFileFormatSidtune: PChar; sidtuneLength: TUint32): Boolean; cdecl; external SIDLIB;
  74.   function sid_play(buffer: PByte; count: Uint32): Integer; cdecl; external SIDLIB;
  75.   function isPlaying(): Boolean; cdecl; external SIDLIB;
  76.   procedure sid_stop(); cdecl; external SIDLIB;
  77.   procedure debug(enable: Boolean; outFile: Pointer); cdecl; external SIDLIB;
  78.   procedure mute(sidNum, voice: int32; enable: Boolean); cdecl; external SIDLIB;
  79.   function timeMs(): TUint32; cdecl; external SIDLIB;
  80.   function getCia1TimerA(): int16; cdecl; external SIDLIB;
  81.   function sid_GetStatus(): Boolean; cdecl; external SIDLIB;
  82.  
  83.  
  84. implementation
  85.  
  86. end.
Sub Quantum Technology ! Gigatron 68000 Colmar France;

Gigatron

  • Full Member
  • ***
  • Posts: 176
  • Amiga Rulez !!
Re: Sid Player
« Reply #1 on: December 31, 2024, 04:44:23 pm »
Hello, some functions are reworked, I am learning C;C++!! I hate this language!

** Update library now .rsid format is working too.

Playing sid  is now more accurate .rsid .mus and .psid are supported;

No need to load C64 roms, there are included in the library , '0x' Format.
This player need some work to configure the engine , select sid models etc ...

The dll was updated and attached in .zip format so replace the old library.
59000 sids here : https://hvsc.de/players
 

From now on I wish you a happy new year 2025 and good coding!!

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, sid_lib,
  9.   mmsystem, windows;
  10.  
  11. const
  12.   Channels = 1;
  13.   BitsPerSample = 16;
  14.   SampleRate = 44100; // Nombre d'Ă©chantillons par seconde
  15.   BufSize = 8192*2;    // Taille du tampon audio x 2
  16.   BufferCount = 4;
  17.  
  18. type
  19.   { TForm1 }
  20.  
  21.   TForm1 = class(TForm)
  22.     Timer1: TTimer;
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure FormShow(Sender: TObject);
  25.     procedure Timer1Timer(Sender: TObject);
  26.   private
  27.     buffers: array[0..BufferCount-1] of array[0..BufSize-1] of SmallInt;
  28.     waveHeaders: array[0..BufferCount-1] of TWaveHdr;
  29.     currentBuffer: Integer;
  30.   public
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.   waveOut: HWAVEOUT;
  36.   sid_mus : pointer;
  37.   ok_flag: Boolean = false;
  38.   fsize : integer;
  39.   // sid
  40.   s_config : TSidConfig;
  41.  
  42. implementation
  43.  
  44. {$R *.lfm}
  45.  
  46. procedure HandleError(const Str: PAnsiChar);
  47. begin
  48.   if Str <> nil then
  49.   begin
  50.     ShowMessage('Error: ' + Str);
  51.     Halt(1);
  52.   end;
  53. end;
  54.  
  55. procedure FillBuffer(bufferIndex: Integer);
  56. var
  57. GenSmp, NumSmp,sid_sng: Integer;
  58. begin
  59.  
  60.   if ok_flag then
  61.   begin
  62.        bufferIndex := Form1.currentBuffer;
  63.        NumSmp :=  BufSize div (Channels * (BitsPerSample div 8));
  64.        GenSmp := sid_play(@Form1.buffers[bufferIndex][0],NumSmp) ;
  65.       end;
  66. end;
  67.  
  68. function WaveOutCallback(hwo: HWAVEOUT; uMsg: UINT; dwInstance, dwParam1, dwParam2: DWORD_PTR): DWORD; stdcall;
  69. begin
  70.   if uMsg = WOM_DONE then
  71.   begin
  72.     FillBuffer(Form1.currentBuffer);
  73.     waveOutWrite(waveOut, @Form1.waveHeaders[Form1.currentBuffer], SizeOf(TWaveHdr));
  74.     Form1.currentBuffer := (Form1.currentBuffer + 1) mod BufferCount;
  75.   end;
  76.   Result := 0;
  77. end;
  78.  
  79. procedure InitAudio;
  80. var
  81.   wFormat: TWaveFormatEx;
  82.   i: Integer;
  83. begin
  84.   SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_LOWEST);
  85.  
  86.   with wFormat do
  87.   begin
  88.    wFormatTag := WAVE_FORMAT_PCM;
  89.    nChannels := Channels;
  90.     nSamplesPerSec := SampleRate;
  91.     wBitsPerSample := BitsPerSample;
  92.     nBlockAlign := (wBitsPerSample * nChannels) div 8;
  93.     nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;
  94.     cbSize := 0;
  95.   end;
  96.  
  97.   if waveOutOpen(@waveOut, WAVE_MAPPER, @wFormat, QWORD(@WaveOutCallback), 0, CALLBACK_FUNCTION) <> MMSYSERR_NOERROR then
  98.     raise Exception.Create('Erreur lors de l''ouverture du pĂ©riphĂ©rique audio');
  99.  
  100.   // PrĂ©paration des tampons
  101.   for i := 0 to BufferCount - 1 do
  102.   begin
  103.     ZeroMemory(@Form1.waveHeaders[i], SizeOf(TWaveHdr));
  104.     with Form1.waveHeaders[i] do
  105.     begin
  106.       lpData := @Form1.buffers[i][0];
  107.       dwBufferLength := BufSize  ;
  108.       dwFlags := 0;
  109.        FillBuffer(i);
  110.     end;
  111.     waveOutPrepareHeader(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  112.   end;
  113.     Form1.currentBuffer := 0;
  114.     for i := 0 to BufferCount - 1 do
  115.      begin
  116.      FillBuffer(i);
  117.      waveOutWrite(waveOut, @Form1.waveHeaders[i], SizeOf(TWaveHdr));
  118.     end;
  119. end;
  120.  
  121. procedure LoadBinaryFileToBuffer(const FileName: string; var Buffer:   TBytes);
  122. var
  123.   MemoryStream: TMemoryStream;
  124. begin
  125.   MemoryStream := TMemoryStream.Create;
  126.   try
  127.     MemoryStream.LoadFromFile(FileName);
  128.     SetLength(Buffer, MemoryStream.Size);   //taille du buffer
  129.     MemoryStream.ReadBuffer(Buffer[0], MemoryStream.Size);
  130.     fsize := MemoryStream.Size;
  131.   finally
  132.     MemoryStream.Free;
  133.   end;
  134. end;
  135.  
  136. procedure LoadBinaryFileToPointer(const FileName: Pchar; var Buffer: Pointer; var FileSize: Integer);
  137. var
  138.   fs: TFileStream;
  139. begin
  140.   // VĂ©rifier si le fichier existe     if not FileExists(FileName) then
  141.     raise Exception.Create('Erreur : Fichier introuvable - ' + FileName);
  142.  
  143.   fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  144.   try
  145.     FileSize := fs.Size; // Taille du fichier
  146.     fsize := fs.Size;
  147.     GetMem(Buffer, FileSize);
  148.     fs.Read(Buffer^, FileSize);
  149.   finally
  150.     fs.Free;
  151.   end;
  152. end;
  153.  
  154. procedure TForm1.FormCreate(Sender: TObject);
  155.  var
  156.   Sid_buff: array of Byte;
  157.  
  158.   sid_cr : Pointer;
  159.   sid_ld : Boolean;
  160.   sid_cfg : Boolean;
  161.   sid_sng : integer;
  162.   song_state : Boolean;
  163.  begin
  164.  
  165.   try
  166.      // LoadBinaryFileToBuffer('Miami_vice.mus', Sid_buff);   // buffer load
  167.     //  LoadBinaryFileToBuffer('Miami_Vice.sid', Sid_buff);   // buffer load
  168.        LoadBinaryFileToBuffer('gyruss.sid', Sid_buff);   // buffer load
  169.        //LoadBinaryFileToBuffer('blackangle.rsid', Sid_buff);   //working !!
  170.  
  171.   except
  172.     on E: Exception do
  173.       ShowMessage('Erreur : ' );
  174.   end;
  175.  
  176.        sid_cr := sid_Create;
  177.        sid_cfg := sid_Config();
  178.        sid_ld := sid_load(Pchar(sid_Buff),fsize,5); // sid_buffer,file size, song= num;
  179.  
  180.   end;
  181.  
  182. procedure TForm1.FormShow(Sender: TObject);
  183. begin
  184.      InitAudio;
  185.      ok_flag := true;
  186. end;
  187.  
  188. procedure TForm1.Timer1Timer(Sender: TObject);
  189. begin
  190. end;
  191.  
  192. end.
  193.  

Libsid Unit

Code: Pascal  [Select][+][-]
  1. unit sid_lib;
  2.  
  3.  
  4. {$mode objfpc}{$H+}
  5.  
  6. interface
  7.  
  8. uses
  9.     windows;
  10.  
  11.   const
  12.  
  13.   MAX_POWER_ON_DELAY = $1FFF;
  14.   DEFAULT_POWER_ON_DELAY: UInt16 = MAX_POWER_ON_DELAY; //+1;
  15.   DEFAULT_SAMPLING_FREQ: UInt32 = 44100;
  16.  
  17.   SIDLIB = 'SidPlay.dll';
  18.  
  19. type
  20.   TUint8 = Byte;
  21.   PUint8 = ^TUint8;
  22.   TUint32 = Cardinal;
  23.   TUint16 = Word;
  24.  
  25.   TShortArray = array[0..0] of SmallInt;
  26.   PShortArray = ^TShortArray;
  27.  
  28. playback_t        = ( MONO = 1, STEREO);
  29. sid_model_t       = (MOS6581, MOS8580);
  30. sid_cw_t          = (AVERAGE, WEAK, STRONG);
  31. cia_model_t       = (MOS6526, MOS8521, MOS6526W4485);
  32. c64_model_t       = (PAL, NTSC, OLD_NTSC, DREAN, PAL_M);
  33. sampling_method_t = (INTERPOLATE, RESAMPLE_INTERPOLATE);
  34.  
  35.  
  36.  PSidConfig = ^TSidConfig;
  37.  TSidConfig = class
  38.   public
  39.  
  40.     DefaultC64Model: c64_model_t;
  41.     ForceC64Model: Boolean;
  42.     DefaultSidModel: sid_model_t;
  43.     ForceSidModel: Boolean;
  44.     DigiBoost: Boolean;
  45.     CiaModel: cia_model_t;
  46.     Playback: playback_t;
  47.     Frequency: UInt32;
  48.     SecondSidAddress: UInt16;
  49.     ThirdSidAddress: UInt16;
  50.     SidEmulation: Pointer;
  51.     LeftVolume: UInt32;
  52.     RightVolume: UInt32;
  53.     PowerOnDelay: UInt16;
  54.     FastSampling: Boolean;
  55.    // function Compare(const Config: TSidConfig): Boolean;
  56.   end;
  57.  
  58. //function sid_Load_Rom(path : PChar; romSize : Integer):Pchar;cdecl; external SIDLIB;
  59.  
  60.   procedure sid_SetRoms(kernal, basic, character: Byte); cdecl; external SIDLIB;
  61.   procedure sid_Set_Kernal(rom: PUint8); cdecl; external SIDLIB;
  62.   procedure sid_Set_Basic(rom: PUint8); cdecl; external SIDLIB;
  63.   procedure sid_Set_Chargen(rom: PUint8); cdecl; external SIDLIB;
  64.   function sid_Select_Song(song: integer):integer; cdecl; external SIDLIB;
  65.   function sid_Create(): Pointer; cdecl; external SIDLIB;
  66.   function sid_Config(): Boolean; cdecl; external SIDLIB;
  67.   function error(): PChar; cdecl; external SIDLIB;
  68.  // function fastForward(percent: TUint32): Boolean; cdecl; external SIDLIB;
  69.   function sid_load(oneFileFormatSidtune: Pointer; sidtuneLength: TUint32;songnum : Integer): Boolean; cdecl; external SIDLIB;
  70.   function sid_play(buffer: PByte; count: Uint32): Integer; cdecl; external SIDLIB;
  71.   function isPlaying(): Boolean; cdecl; external SIDLIB;
  72.   procedure sid_stop(); cdecl; external SIDLIB;
  73.   procedure debug(enable: Boolean; outFile: Pointer); cdecl; external SIDLIB;
  74.   procedure mute(sidNum, voice: int32; enable: Boolean); cdecl; external SIDLIB;
  75.   function timeMs(): TUint32; cdecl; external SIDLIB;
  76.   function getCia1TimerA(): int16; cdecl; external SIDLIB;
  77.   function sid_GetStatus(): Boolean; cdecl; external SIDLIB;
  78.  
  79. implementation
  80.  
  81. end.

« Last Edit: December 31, 2024, 07:54:32 pm by Gigatron »
Sub Quantum Technology ! Gigatron 68000 Colmar France;

Gigatron

  • Full Member
  • ***
  • Posts: 176
  • Amiga Rulez !!
Re: Sid Player
« Reply #2 on: January 02, 2025, 07:23:14 pm »
Hi,
This is the next release of sidplayer;
Some functions were added , you can test this player i am sure there are some bugs.

The library + project + 2 songs added(Blackangle : Visac ; Starsign : Sonic);

Have fun
Sub Quantum Technology ! Gigatron 68000 Colmar France;

Gigatron

  • Full Member
  • ***
  • Posts: 176
  • Amiga Rulez !!
Re: Sid Player
« Reply #3 on: January 04, 2025, 05:04:10 pm »
Hi,

This is maybe the latest version of this library , wich use 4 buffers , 16384 byte of size.
The initial sid_buffer contain the sid module and then fill the buffers to generate PCM samples.
 
sid_play(@Form1.buffers[bufferIndex][0],NumSmp ) ; So you can not stop sid module, you must close audio..

If you want to listen subsong 3 for eg: you must load again the song with the subsong num;
sid_load(Pchar(sid_Buff),fsize,3);


Be careful what you do because there are still some bugs in the library function calls.
I don't want to be responsible for crashes or data loss in 2025 . So use with caution.
I hope someone will improve this library based on replayer and hyppoplayer sources.

Have fun

Regards GTR
« Last Edit: January 05, 2025, 05:05:37 pm by Gigatron »
Sub Quantum Technology ! Gigatron 68000 Colmar France;

Roland57

  • Sr. Member
  • ****
  • Posts: 490
    • msegui.net
Re: Sid Player
« Reply #4 on: January 05, 2025, 11:00:44 am »
Hello! Sounds interesting. Thank you for sharing.

Here on Linux, I can build and install the library, but the ./configure command for the player fails:

checking for SIDPLAYFP... no
configure: error: Package requirements (libsidplayfp >= 1.0) were not met:

Package 'libsidplayfp', required by 'virtual:world', not found


I used version 2.12.0 for library and player.
My projects are on Gitlab and on Codeberg.

Guva

  • Full Member
  • ***
  • Posts: 126
Re: Sid Player
« Reply #5 on: January 05, 2025, 03:33:33 pm »
Hello! Sounds interesting. Thank you for sharing.

Here on Linux, I can build and install the library, but the ./configure command for the player fails:

checking for SIDPLAYFP... no
configure: error: Package requirements (libsidplayfp >= 1.0) were not met:

Package 'libsidplayfp', required by 'virtual:world', not found


I used version 2.12.0 for library and player.

I had the same error. I compiled it this way.

Download from
https://github.com/libsidplayfp/libsidplayfp/releases/download/v2.12.0/libsidplayfp-2.12.0.tar.gz

./configure
make
sudo make install

download
https://github.com/libsidplayfp/sidplayfp/releases/download/v2.12.0/sidplayfp-2.12.0.tar.gz

./configure
make
sudo make install

But sidplayfp swears at the lack of a library
sidplayfp: error while loading shared libraries: libsidplayfp.so.6: cannot open shared object file: No such file or directory

I just copied it.
sudo cp /usr/local/lib/libsidplayfp.so.6.5.37 /usr/lib/libsidplayfp.so.6

TRon

  • Hero Member
  • *****
  • Posts: 3957
Re: Sid Player
« Reply #6 on: January 05, 2025, 04:33:16 pm »
Is that missing virtual world even mandatory ? e.g. the library builds just fine (even though it is cpp) even mentioning falling back to internal solution instead.

Strange that the library reports being unable to load after installation. I do without install and the links seem to be all there.
Code: Bash  [Select][+][-]
  1. $> ls src/.libs/
  2. libsidplayfp.a                    libsidplayfp.lai          libsidplayfp_la-psiddrv.o  libsidplayfp.so         libstilview.a    libstilview.so
  3. libsidplayfp.la                   libsidplayfp_la-mixer.o   libsidplayfp_la-reloc65.o  libsidplayfp.so.6       libstilview.la   libstilview.so.0
  4. libsidplayfp_la-EventScheduler.o  libsidplayfp_la-player.o  libsidplayfp_la-sidemu.o   libsidplayfp.so.6.5.34  libstilview.lai  libstilview.so.0.0.6
  5.  
  6. $> ldd src/.libs/libsidplayfp.so.6.5.34
  7. linux-vdso.so.1 (0x00007ffd8d10f000)
  8. libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8c71200000)
  9. libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8c71121000)
  10. libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8c70f40000)
  11. libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8c70f20000)
  12. /lib64/ld-linux-x86-64.so.2 (0x00007f8c7293a000)
  13.  
« Last Edit: January 05, 2025, 05:53:49 pm by TRon »
I do not have to remember anything anymore thanks to total-recall.

 

TinyPortal © 2005-2018