News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: spc2it [Convert SPC into Impulse Tracker format]  (Read 12412 times)

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
spc2it [Convert SPC into Impulse Tracker format]
« on: December 30, 2014, 06:32:07 pm »
spc2it is a program that allows you to convert spc into Impulse Tracker format.

The source code can be found at https://github.com/uyjulian/spc2it

Binary releases can be found at https://github.com/uyjulian/spc2it/releases

The moonscript branch is at https://github.com/uyjulian/spc2it/tree/moonscript
No instructions yet, I'm still working on it.
« Last Edit: July 13, 2016, 03:20:49 pm by uyjulian »

DaVince

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Uyjulian's SPC to IT Converter Project
« Reply #1 on: January 12, 2015, 12:08:37 am »
This is awesome. I was recently reminded of the OpenSPC tool, and remembered how useful it was to pretty much perfectly rip the audio samples (with their loop points!) and use them in my favourite music tracker (which also works with .it files). Thank you so much for bringing this to modern systems. I'm very happy I can run this on my Linux system, even if it's not perfect and notes are dropped. :)

That said, besides the known bugs, I think there is still room for improvement for the sample dumping! The samples themselves are dumped perfectly, but it's dumping them as regular samples rather than instruments. If you dump them as instruments, you get the power of adding effects to the samples, which allows for emulation of the SPC's echo and reverb effects.

Quote
There's a limit of 200 patterns in IT file format, anybody here suggest a better format?
Well, the newest tracker-type format I can think of is .mptm, and that's actually more or less just like the .it format except extended as far as I'm aware. One possibly beneficial improvement is that it allows for multiple pattern sequences (basically meaning more than 200 patterns). Might be worth looking into.

I also have a question, or rather, a point of discussion:
How come it polls the SPC file a whole bunch of times per second and creates soooo many rows at a super high tempo that don't seem to fit in an accurate, regular timing in the .it file? In this one file I noticed that one beat takes 17 rows, which is already an odd number. Then the next beat after it takes 18 rows, and then the one after THAT is 17 rows again, all while 16 rows would have made a lot more sense because you get a perfectly steady rhythm on beats that are all equal length (and preferably a power of 2). I guess it has something to do with rounding, but does it really have to round things so inconsistently? Is there anything that can be done to fix this, like figuring out what the bpm and most regular beat/measure distance of the song is before dumping it into the IT? This would also fix any potential "200 patterns is not enough" issues because the song can be accurately fit in less rows.

But anyway! Thanks a ton for this effort. I'd be more than happy myself if just the sample export side of things gets explored for improvement, but that's not all the tool sets out to do, right? ;)
« Last Edit: October 05, 2015, 10:39:01 am by MathOnNapkins »
Tingle's balloon trip of love is finally translated! Go check it out!

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #2 on: January 12, 2015, 01:42:04 am »
This is awesome. I was recently reminded of the OpenSPC tool, and remembered how useful it was to pretty much perfectly rip the audio samples (with their loop points!) and use them in my favourite music tracker (which also works with .it files). Thank you so much for bringing this to modern systems. I'm very happy I can run this on my Linux system, even if it's not perfect and notes are dropped. :)

That said, besides the known bugs, I think there is still room for improvement for the sample dumping! The samples themselves are dumped perfectly, but it's dumping them as regular samples rather than instruments. If you dump them as instruments, you get the power of adding effects to the samples, which allows for emulation of the SPC's echo and reverb effects.
Well, the newest tracker-type format I can think of is .mptm, and that's actually more or less just like the .it format except extended as far as I'm aware. One possibly beneficial improvement is that it allows for multiple pattern sequences (basically meaning more than 200 patterns). Might be worth looking into.

I also have a question, or rather, a point of discussion:
How come it polls the SPC file a whole bunch of times per second and creates soooo many rows at a super high tempo that don't seem to fit in an accurate, regular timing in the .it file? In this one file I noticed that one beat takes 17 rows, which is already an odd number. Then the next beat after it takes 18 rows, and then the one after THAT is 17 rows again, all while 16 rows would have made a lot more sense because you get a perfectly steady rhythm on beats that are all equal length (and preferably a power of 2). I guess it has something to do with rounding, but does it really have to round things so inconsistently? Is there anything that can be done to fix this, like figuring out what the bpm and most regular beat/measure distance of the song is before dumping it into the IT? This would also fix any potential "200 patterns is not enough" issues because the song can be accurately fit in less rows.

But anyway! Thanks a ton for this effort. I'd be more than happy myself if just the sample export side of things gets explored for improvement, but that's not all the tool sets out to do, right? ;)

All right, I fixed your bug, however it isn't really with the Impulse Tracker format anymore (I change the row limit to 0xFD (aka 253), and that is the absolute limit!!! The file format can't handle any more orders!!!)
Also, if I was going to fix the row/timing problem, I might as well rewrite the entire IT dumping code, because it's a very ugly code designed for speed and memory saving (DOS ftw!!!!)

Also, Windows binaries for those that want them: https://github.com/uyjulian/spc2it/releases/tag/v0.1

azidahaka

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #3 on: January 12, 2015, 04:20:06 am »
Does it work on win7 64bit? If so,  :cookie: :)

DaVince

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #4 on: January 12, 2015, 07:47:19 am »
Thanks. That seemed to work fine even though it's going over the officially defined limit. I kinda figured you'd just force a cutoff and print a warning. :P

And yeah, I figured that any more thorough fixing would require a rewrite...

Edit: by the way, I noticed it outputs 15 channels rather than 16?
« Last Edit: January 12, 2015, 08:01:01 am by DaVince »
Tingle's balloon trip of love is finally translated! Go check it out!

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #5 on: January 12, 2015, 07:02:36 pm »
Thanks. That seemed to work fine even though it's going over the officially defined limit. I kinda figured you'd just force a cutoff and print a warning. :P

And yeah, I figured that any more thorough fixing would require a rewrite...

Edit: by the way, I noticed it outputs 15 channels rather than 16?
Don't the channels start at 0?
Does it work on win7 64bit? If so,  :cookie: :)
Yes, works on windows.

azidahaka

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #6 on: January 13, 2015, 02:03:25 am »
Don't the channels start at 0?Yes, works on windows.

Thanks i'll look into it :)  :thumbsup:

Azkadellia

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 865
  • 提交向你的情妇!
    • View Profile
    • Princess Translations
Re: Uyjulian's SPC to IT Convert Project
« Reply #7 on: January 13, 2015, 05:04:58 am »
Impulse Tracker files have 64 channels and they start at 1. Also, Jeff has released the source code to Impulse Tracker.
https://bitbucket.org/jthlim/impulsetracker
Current Projects: On hold indefinitely.
I do the Twitter thing now: https://twitter.com/MistressSaeko (expect lots of game streaming announcements)
Mistress of the RHDN Discord server.

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #8 on: January 13, 2015, 08:17:39 am »
Impulse Tracker files have 64 channels and they start at 1. Also, Jeff has released the source code to Impulse Tracker.
https://bitbucket.org/jthlim/impulsetracker
No, the IT documentation (ITTECH.TXT, line 384) says the channels start at 0.
Also, the 15 channels enabled thing was a error on my part. (https://github.com/uyjulian/spc2it/blob/master/it.c#L262)
Also, the source code to Impulse Tracker is written in assembly, but this might help: https://bitbucket.org/jthlim/impulsetracker/src/1e49b00d51921d5aa2edcae105529911a0fbb2a3/IT_MDATA.ASM

Azkadellia

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 865
  • 提交向你的情妇!
    • View Profile
    • Princess Translations
Re: Uyjulian's SPC to IT Convert Project
« Reply #9 on: January 13, 2015, 08:16:53 pm »
Impulse Tracker itself is telling me otherwise:

But, whatever.
Current Projects: On hold indefinitely.
I do the Twitter thing now: https://twitter.com/MistressSaeko (expect lots of game streaming announcements)
Mistress of the RHDN Discord server.

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #10 on: January 16, 2015, 05:03:11 am »
I won't be checking this topic much anymore, go to #spc2it on freenode or go here: http://webchat.freenode.net/?channels=%23spc2it&uio=d4

All right, I have fixed the channels thing (ITTECH.TXT was wrong!!!!)
16 channels should be used now.

Also, the IT code in spc2it wastes A LOT of space, so it's best if you open the IT file in another tracker (I like schism tracker) and then save it in that tracker. That will save you a lot of space (Example: top-102.it before: 589 KB after: 175 KB about 30% savings!)
« Last Edit: January 17, 2015, 09:42:10 pm by uyjulian »

azidahaka

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #11 on: January 19, 2015, 01:59:59 am »
Where can be found last version?

Also as a question, can you place same instruments in same columns when outputting the IT file? OR it's the way it works on the snes?

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #12 on: January 20, 2015, 04:32:51 am »
Where can be found last version?

Also as a question, can you place same instruments in same columns when outputting the IT file? OR it's the way it works on the snes?

Find stable windows binaries/source code here: https://github.com/uyjulian/spc2it/releases
Or latest source code here: https://github.com/uyjulian/spc2it

Also, I don't understand that last question, you should rephrase that question.

Oh, and I have some exciting news: First note problem fixed! Also, pitch slides are fixed, too. Also fixed the channel problem, now all 16 channels should be used. Also, the length problem should be fixed, so basically I'm back to where OpenSPC was with IT dumping :-)
« Last Edit: January 20, 2015, 04:58:31 am by uyjulian »

azidahaka

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #13 on: January 20, 2015, 10:21:57 am »
ah great i'll download the new version as i get home  :thumbsup:

What i meant is that sometime the same instruments play in 2 or 3 rows, is that the normal way the snes uses or a result of the conversion?

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #14 on: January 21, 2015, 05:14:24 am »
ah great i'll download the new version as i get home  :thumbsup:

What i meant is that sometime the same instruments play in 2 or 3 rows, is that the normal way the snes uses or a result of the conversion?
It's the result of the conversion, I think the new version will fix some of those problems.

Also, update: pitch sounds correctly now!!!
I couldn't find the error before (because I didn't know what bitshifts did), but I changed the bitshifts I could find in my code into multiply, and I found the error!
https://github.com/uyjulian/spc2it/blob/master/it.c#L181

Orig:
Code: [Select]
pitch = (s32)(*(u16 *)&SPC_DSP[(i << 4) + 0x02]) << 3;Multiply:
Code: [Select]
pitch = (s32)(*(u16 *)&SPC_DSP[(i << 4) + 0x02]) * 8;Fixed:
Code: [Select]
pitch = (s32)(*(u16 *)&SPC_DSP[(i << 4) + 0x02]) * 7.8125;
« Last Edit: January 21, 2015, 07:36:28 am by uyjulian »

DaVince

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #15 on: January 21, 2015, 10:40:47 am »
Thanks for the fixes! The new exported files sound much better now. :)

I noticed that a conversion of "103 Start Of Journey" from Lufia 2 still has a missing start note. However, the SPC itself also sounds as if the recording started a tiny bit after the first note, but the first note IS played in the SPC and not in the IT.
Edit: "102 Rumbling" and a lot of ohters also have their first note cut off, while the SPC sounds ripped properly.

Another edit: is there any chance that you could interpret any "note volume 0" commands as a "note off" command instead? This would make it easier to get an audible "note off" effect when messing with instrument effects.
« Last Edit: January 21, 2015, 10:58:23 am by DaVince »
Tingle's balloon trip of love is finally translated! Go check it out!

azidahaka

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #16 on: January 21, 2015, 11:05:34 am »
It's the result of the conversion, I think the new version will fix some of those problems.

Also, update: pitch sounds correctly now!!!
I couldn't find the error before (because I didn't know what bitshifts did), but I changed the bitshifts I could find in my code into multiply, and I found the error!
https://github.com/uyjulian/spc2it/blob/master/it.c#L181

Orig:
Code: [Select]
pitch = (s32)(*(u16 *)&SPC_DSP[(i << 4) + 0x02]) << 3;Multiply:
Code: [Select]
pitch = (s32)(*(u16 *)&SPC_DSP[(i << 4) + 0x02]) * 8;Fixed:
Code: [Select]
pitch = (s32)(*(u16 *)&SPC_DSP[(i << 4) + 0x02]) * 7.8125;

I'm really grateful for this! I had a project of creating some "High quality" remastered soundtracks using soundfonts and spacial effects... Seems this will make it all way easier! Is Dl link the same as usual?

DaVince

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #17 on: January 21, 2015, 11:06:47 am »
I'm really grateful for this! I had a project of creating some "High quality" remastered soundtracks using soundfonts and spacial effects... Seems this will make it all way easier! Is Dl link the same as usual?
Quote
Find stable windows binaries/source code here: https://github.com/uyjulian/spc2it/releases
;)

Looking forward ot those remasters, by the way!
Tingle's balloon trip of love is finally translated! Go check it out!

azidahaka

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #18 on: January 21, 2015, 11:40:48 am »
I'll post something when i'll get some good ones like this old one i made ages ago:

https://www.youtube.com/watch?v=iP3bIL4Pmlw is the only sample i uploaded

uyjulian

  • Jr. Member
  • **
  • Posts: 33
    • View Profile
Re: Uyjulian's SPC to IT Convert Project
« Reply #19 on: January 21, 2015, 08:45:18 pm »
Thanks for the fixes! The new exported files sound much better now. :)

I noticed that a conversion of "103 Start Of Journey" from Lufia 2 still has a missing start note. However, the SPC itself also sounds as if the recording started a tiny bit after the first note, but the first note IS played in the SPC and not in the IT.
Edit: "102 Rumbling" and a lot of ohters also have their first note cut off, while the SPC sounds ripped properly.

Another edit: is there any chance that you could interpret any "note volume 0" commands as a "note off" command instead? This would make it easier to get an audible "note off" effect when messing with instrument effects.

Hmm, I'll check that out and see what's going on.

Also, I'll clean up the IT pattern writing code, then I'll do that.


EDIT: Okay, fix is now up! Turns out I have to turn on the first note manually (since the SPC CPU emulator does not do that, the note is already on in the SPC!)
« Last Edit: January 22, 2015, 03:04:19 am by uyjulian »