Sonic and Sega Retro Message Board: C-based SMPS Playback Engine - updated - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

C-based SMPS Playback Engine - updated

#1 User is offline ValleyBell 

Posted 23 December 2011 - 06:12 AM

  • Posts: 197
  • Joined: 08-September 10
  • Gender:Male
  • Project:researching SMPS sound drivers
  • Wiki edits:10
Do you rememer this SMPS player?

Well, I worked a little on it. And although I didn't improve the actual smps playback a lot (aside from a few small bugfixes), I made a lot of other changes.

At first, it can log v1.60 VGMs. (press V to enable/disable logging)
Also all DACs sounds and PSG envelopes are dynamically loaded and are easy to change. (I included a small editor for the PSG envelope files.)
And I removed Allegro (and made it a console app), so it continues playing if the program doesn't have the focus.
Finally, there is a 32-bit version (compiled with MSVC6 for compatibility) and a 64-bit versions (compiled with MSVC2010, so you need .NET 4.0).

Download

Enjoy!

EDIT: File updated, see this post
This post has been edited by ValleyBell: 15 February 2012 - 03:34 PM

#2 User is offline Chilly Willy 

Posted 23 December 2011 - 06:31 PM

  • Posts: 738
  • Joined: 10-April 09
  • Gender:Male
  • Project:Wolf3D MCD
Very cool. I look forward to the source release. :)

#3 User is offline sasuke 

Posted 23 December 2011 - 09:48 PM

  • Posts: 66
  • Joined: 05-June 09
  • Gender:Male
  • Wiki edits:1
Yeah, especially since the original's link is dead.

#4 User is offline Oerg866 

Posted 23 December 2011 - 10:41 PM

  • Posts: 1720
  • Joined: 07-September 06
  • Gender:Male
  • Location:Frankfurt, Germany
  • Wiki edits:3
Nice.

Will it build on VC6.0 or MinGW?

#5 User is offline Irixion 

Posted 01 January 2012 - 05:05 PM

  • Posts: 1362
  • Joined: 30-December 04
  • Gender:Male
  • Location:Ontario, Canada
  • Project:Life
  • Wiki edits:152
Don't mean to bump but when trying to play .asm music files, the program explodes, both x64 and x86 builds. Sonic 1's driver also crashed, until it was put on an even address (by adding even at the beginning of the file)

#6 User is offline ValleyBell 

Posted 01 January 2012 - 06:08 PM

  • Posts: 197
  • Joined: 08-September 10
  • Gender:Male
  • Project:researching SMPS sound drivers
  • Wiki edits:10
It doesn't support ASM files and it never will. (But if someone wants to write an SMPS ASM-compiler and the source is easy to include, feel free to send me code and this may change.)

View PostOerg866, on 23 December 2011 - 10:41 PM, said:

Will it build on VC6.0 or MinGW?

View PostValleyBell, on 23 December 2011 - 06:12 AM, said:

there is a 32-bit version (compiled with MSVC6 for compatibility)
I don't think it compiles with MinGW without fixing some lines.


btw: I plan to add automatic loop support for VGM dumps, but for SMPS files that requires a little more work than for Data East music files.

#7 User is offline LOst 

Posted 05 January 2012 - 05:18 AM

  • Sonic 2 HD - Lead Programmer
  • Posts: 4877
  • Joined: 10-January 03
  • Gender:Male
  • Wiki edits:2

View PostValleyBell, on 23 December 2011 - 06:12 AM, said:

Do you rememer this SMPS player?


I clearly remember that!

Now, can you help me with a thing? If you go to the line in sound.cpp:

if(install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0)


And change it to:
if(install_sound(DIGI_DIRECTX(0), MIDI_AUTODETECT, NULL) != 0)


Now you will hear repeated garbage, and a lower volume distorted playback. Do you have any idea what is producing the wrong sound output? Is the sound buffer too short? Is the format of the sound buffer differently (doesn't look like that, but the sound is clearly distorted).


DIGI_AUTODETECT on Windows uses a directsound8 sound buffer of size 0x1800, and mixes in a software buffer every 50 Hz in 0x1000 chunks. This is done in allegro\4.2\src\win\wdsndmix.c from allegro\4.2\src\stream.c (the stream code accesses the software buffer)

DIGI_DIRECTX(0) directly writes the streamed data into a directsound8 sound buffer. The sound driver is in allegro\4.2\src\win\wdsound.c and is called from allegro\4.2\src\stream.c (the stream code locks the directsound8 sound buffer directly)

Both uses the stream code in allegro\4.2\src\stream.c, which SMPS accesses through get_audio_stream_buffer() and free_audio_stream_buffer()
This post has been edited by LOst: 05 January 2012 - 05:22 AM

#8 User is offline Sik 

Posted 05 January 2012 - 11:39 AM

  • Sik is pronounced as "seek", not as "sick".
  • Posts: 6719
  • Joined: 17-March 06
  • Gender:Male
  • Project:being an asshole =P
  • Wiki edits:11
I assume there must be a reason why DIGI_AUTODETECT doesn't try to do what DIGI_DIRECTX(0) is doing =P Also this would be an Allegro issue, not an issue with the player, so don't expect much help here...

DIGI_AUTODETECT is pretty much the best option, period.

#9 User is offline Irixion 

Posted 05 January 2012 - 01:15 PM

  • Posts: 1362
  • Joined: 30-December 04
  • Gender:Male
  • Location:Ontario, Canada
  • Project:Life
  • Wiki edits:152

View PostValleyBell, on 01 January 2012 - 06:08 PM, said:

It doesn't support ASM files and it never will. (But if someone wants to write an SMPS ASM-compiler and the source is easy to include, feel free to send me code and this may change.)

View PostOerg866, on 23 December 2011 - 10:41 PM, said:

Will it build on VC6.0 or MinGW?

View PostValleyBell, on 23 December 2011 - 06:12 AM, said:

there is a 32-bit version (compiled with MSVC6 for compatibility)
I don't think it compiles with MinGW without fixing some lines.


btw: I plan to add automatic loop support for VGM dumps, but for SMPS files that requires a little more work than for Data East music files.



Isn't there a tool for SMPS2ASM? Wouldn't it be possible to just reverse that? :V

#10 User is offline ValleyBell 

Posted 05 January 2012 - 03:13 PM

  • Posts: 197
  • Joined: 08-September 10
  • Gender:Male
  • Project:researching SMPS sound drivers
  • Wiki edits:10

View PostLOst, on 05 January 2012 - 05:18 AM, said:

Now, can you help me with a thing? If you go to the line in sound.cpp:

if(install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0)


And change it to:
if(install_sound(DIGI_DIRECTX(0), MIDI_AUTODETECT, NULL) != 0)


Now you will hear repeated garbage, and a lower volume distorted playback. Do you have any idea what is producing the wrong sound output? Is the sound buffer too short? Is the format of the sound buffer differently (doesn't look like that, but the sound is clearly distorted).
I never used Allegro, but I'm sure that the sound format is wrong.
When I replaced the allegro sound with my own (Windows-specific) sound code, I noticed that there was an ^0x8000 applied to all samples and I got very distorted sound.
I wondered about it, removed it and it worked.

I'm sure that's because Allegro uses unsigned 16-bit integers for samples, while Windows uses signed 16-bit ones. Just invert bit 15 and it should work.


View PostIrixion, on 05 January 2012 - 01:15 PM, said:

Isn't there a tool for SMPS2ASM? Wouldn't it be possible to just reverse that? :V
Of course it would be possible. I just don't feel like including an 68k assembler in SMPSPlay.
And I have no use for ASM files (mid2smps outputs .bin files), so I won't put too much work into it.

#11 User is offline Sik 

Posted 05 January 2012 - 03:42 PM

  • Sik is pronounced as "seek", not as "sick".
  • Posts: 6719
  • Joined: 17-March 06
  • Gender:Male
  • Project:being an asshole =P
  • Wiki edits:11

View PostValleyBell, on 05 January 2012 - 03:13 PM, said:

When I replaced the allegro sound with my own (Windows-specific) sound code, I noticed that there was an ^0x8000 applied to all samples and I got very distorted sound.
I wondered about it, removed it and it worked.

I'm sure that's because Allegro uses unsigned 16-bit integers for samples, while Windows uses signed 16-bit ones. Just invert bit 15 and it should work.
The Allegro documentation itself says that Allegro does that because it uses a different signedness.

#12 User is offline ValleyBell 

Posted 15 February 2012 - 03:26 PM

  • Posts: 197
  • Joined: 08-September 10
  • Gender:Male
  • Project:researching SMPS sound drivers
  • Wiki edits:10
I updated SMPSPlay. There are some new features:
- added loop detection (doesn't always work), added display of current loop (the same as in DEPlay)
- fixed DAC playback rate (based on the research I did [topic=27713]here[/url])
- added SFX playback (they play over the music, so you can test what gets muted)
- improved support for S3K and late 68k SMPS files
- added some special keys (playlist auto-advance and PSG/DAC data reload)

And this time I included the source.

Download

btw: You can play Sonic 1 SMPS music and Sonic 3 SFX at the same time.

Enjoy!

And here a small bonus: SMPS Song Extractor (source included)
It extracts SMPS 68k songs. It can even scan for the music pointer list in games that use the Sonic 1 sound driver.
EDIT: Extractor link fixed.
This post has been edited by ValleyBell: 16 February 2012 - 02:00 AM

#13 User is offline Hitaxas 

Posted 15 February 2012 - 10:06 PM

  • SEGA: Sorry Classic Sonic, we are sending you back to 1994
  • Posts: 1404
  • Joined: 30-September 07
  • Gender:Male
  • Location:Back in Litchfield,CT
  • Project:Sonic: Super Deformed (head director) - Slowly working on it.
  • Wiki edits:196
Link for the extractor seem dead.

I always loved this program. :)

#14 User is offline Oerg866 

Posted 16 February 2012 - 07:14 AM

  • Posts: 1720
  • Joined: 07-September 06
  • Gender:Male
  • Location:Frankfurt, Germany
  • Wiki edits:3
Nice. I'm in a hurry, so before I can check it out -- Has the FM and PSG emulation cores been updated?

Cheers!

#15 User is offline ValleyBell 

Posted 17 February 2012 - 12:12 PM

  • Posts: 197
  • Joined: 08-September 10
  • Gender:Male
  • Project:researching SMPS sound drivers
  • Wiki edits:10
Yes, I updated both cores.
The current FM core is from MAME (from the current VGMPlay, to be exact), the PSG core from Maxim's in_vgm.

But please note that I emulate the YM2612 at playback rate, not at its native sample rate, because I didn't implement a resampler. Also PSG noise could be louder. (Just fixed it - I halved its volume for some reason.)

  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users