Recent

Author Topic: it2play - IT/S3M module replay in native pascal  (Read 1502 times)

hukka

  • Jr. Member
  • **
  • Posts: 57
    • Github
it2play - IT/S3M module replay in native pascal
« on: February 07, 2026, 01:27:31 am »
A native Free Pascal class for playback of Impulse Tracker (IT) and Scream Tracker (S3M) tracker modules.
Basically a Pascal port of 8bitbubsy's it2play, which is an accurate port of Impulse Tracker 2.15's original IT playroutine ported from assembly to C.
Supports interpolation, sample ramping, filters, instruments, envelopes etc.

I will be adding example projects and cleaning up the code later on, but for now it does everything I wanted it to.

https://github.com/hukkax/it2play-pas

Gigatron

  • Sr. Member
  • ****
  • Posts: 402
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
Re: it2play - IT/S3M module replay in native pascal
« Reply #1 on: February 07, 2026, 01:55:02 am »
Thank you @hukka

That's really interesting all code made with pascal to play Impulse Tracker & Scream Tracker .
Coding faster than Light !

hukka

  • Jr. Member
  • **
  • Posts: 57
    • Github
Re: it2play - IT/S3M module replay in native pascal
« Reply #2 on: February 07, 2026, 02:24:02 am »
Thank you @hukka

That's really interesting all code made with pascal to play Impulse Tracker & Scream Tracker .

Thanks! I don't think it's the first attempt, but it may be the most accurate since it's indirectly based on the original IT sources.

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: it2play - IT/S3M module replay in native pascal
« Reply #3 on: February 07, 2026, 10:00:59 am »
Hi, thank you to share!
I tryed to compile the example but I don't know where to find the sdl3 package ?
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

hukka

  • Jr. Member
  • **
  • Posts: 57
    • Github
Re: it2play - IT/S3M module replay in native pascal
« Reply #4 on: February 08, 2026, 01:02:01 am »
Hi, thank you to share!
I tryed to compile the example but I don't know where to find the sdl3 package ?

Hi,
I've updated the repository, the demo no longer requires external libraries on Windows. On other platforms, SDL3 is still required for the example:
https://github.com/sechshelme/Lazarus-SDL-3.0-Packages-and-Examples

SDL2 and BASS will be added to the example project once I get around to it.
« Last Edit: February 08, 2026, 01:11:53 am by hukka »

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: it2play - IT/S3M module replay in native pascal
« Reply #5 on: February 08, 2026, 09:50:23 pm »
Hi, thanks.
I've tested it with 15 files .it or .s3m, it work very well (windows 10).

Good job ! Now we can play Impulse Tracker (IT) and Scream Tracker (S3M) natively in FreePascal !
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: it2play - IT/S3M module replay in native pascal
« Reply #6 on: February 09, 2026, 03:34:05 pm »
@hukka
Trying to include your lib in ALSound (OpenAL-Soft based framework to play, record and mix sounds) I notice the lib generate memory leak with .it files, no memory leak with .s3m files.

Since the code in ALSound is the same regardless the file extension, I think the issue comes from IT2Play. The problem seem to comes from unit IT2Play, line 5931:
Code: Pascal  [Select][+][-]
  1.         for i := 0 to MAX_INSTRUMENTS-1 do
  2.                 Instruments[i] := TInstrument.Create;
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

hukka

  • Jr. Member
  • **
  • Posts: 57
    • Github
Re: it2play - IT/S3M module replay in native pascal
« Reply #7 on: February 09, 2026, 04:44:48 pm »
@hukka
Trying to include your lib in ALSound (OpenAL-Soft based framework to play, record and mix sounds) I notice the lib generate memory leak with .it files, no memory leak with .s3m files.

Since the code in ALSound is the same regardless the file extension, I think the issue comes from IT2Play. The problem seem to comes from unit IT2Play, line 5931:
Code: Pascal  [Select][+][-]
  1.         for i := 0 to MAX_INSTRUMENTS-1 do
  2.                 Instruments[i] := TInstrument.Create;

Good catch! As a quick fix, free the Instrument before it gets reassigned near line 5360:
Code: Pascal  [Select][+][-]
  1. Instruments[i].Free;
  2. Instruments[i] := Ins;
  3.  

I'm working on some other changes on the unit so I won't update the repository yet.
« Last Edit: February 09, 2026, 04:46:55 pm by hukka »

d2010

  • Sr. Member
  • ****
  • Posts: 256
Re: it2play - IT/S3M module replay in native pascal
« Reply #8 on: February 09, 2026, 07:02:27 pm »
Hi, thank you to share!
I tryed to compile the example but I don't know where to find the sdl3 package ?

Here demo-s3m.

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: it2play - IT/S3M module replay in native pascal
« Reply #9 on: February 09, 2026, 08:28:38 pm »
Good catch! As a quick fix, free the Instrument before it gets reassigned near line 5360:
Code: Pascal  [Select][+][-]
  1. Instruments[i].Free;
  2. Instruments[i] := Ins;
  3.  

I'm working on some other changes on the unit so I won't update the repository yet.

I've applyed the change: no more memory leak. Thank you!
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: it2play - IT/S3M module replay in native pascal
« Reply #10 on: February 10, 2026, 03:08:17 pm »
Hi, Hukka, I'm not very familiar with music module.

With your lib, there is a way to :
 - choose if the music is looped or not ?
 - get the total song duration in seconds?
 - get the current position in seconds ?
 - jump to an audio position (in seconds)?

Thank you
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

hukka

  • Jr. Member
  • **
  • Posts: 57
    • Github
Re: it2play - IT/S3M module replay in native pascal
« Reply #11 on: February 10, 2026, 04:59:35 pm »
Hi, Hukka, I'm not very familiar with music module.

With your lib, there is a way to :
 - choose if the music is looped or not ?
 - get the total song duration in seconds?
 - get the current position in seconds ?
 - jump to an audio position (in seconds)?

Thank you

None of these are entirely straightforward to implement since a module can change tempo or have a position jump command at any point. The easiest way would be to prerender the entire module to a WAV, which you could then seek around and play like a normal WAV. All this is out of scope for a simple demo program, though.

It can definitely be done; I've implemented length calculation and time-based seeking in my Protracker replayer (https://github.com/hukkax/Propulse/blob/trunk/src/protracker/protracker.player.pas, GetLength/JumpToTime), so I will probably have similar methods in the IT player class at some point.

I will update the repository later with a fancier demo that visualizes pattern data (in a very simple manner) and allows seeking while playing pattern by pattern.
« Last Edit: February 10, 2026, 05:16:36 pm by hukka »

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: it2play - IT/S3M module replay in native pascal
« Reply #12 on: February 10, 2026, 08:45:11 pm »
Understood. For now, I will disable audio position changes and loop is True and can not be changed for music modules in my library.

This features are not very important for music modules, since they are simply played and stopped in a game.

Thank you !  :)
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: it2play - IT/S3M module replay in native pascal
« Reply #13 on: February 10, 2026, 09:11:05 pm »
Your Propulse Tracker editor is really impressive, good work!
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

hukka

  • Jr. Member
  • **
  • Posts: 57
    • Github
Re: it2play - IT/S3M module replay in native pascal
« Reply #14 on: February 15, 2026, 12:47:05 am »
Your Propulse Tracker editor is really impressive, good work!
Many thanks!
The repo is now updated with a lot of fixes and improvements, including calculation of song duration. The only thing that's really missing is unpacking MMCMP packed files, but those don't seem to be common, it was hard to find even one example of such.

 

TinyPortal © 2005-2018