don't click here

C-based SMPS Playback Engine - updated

Discussion in 'Technical Discussion' started by ValleyBell, Dec 23, 2011.

  1. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    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
     
  2. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    Very cool. I look forward to the source release. :)
     
  3. sasuke

    sasuke

    Member
    66
    0
    0
    Yeah, especially since the original's link is dead.
     
  4. Nice.

    Will it build on VC6.0 or MinGW?
     
  5. 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. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    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.)

    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. LOst

    LOst

    Tech Member
    4,891
    8
    18
    I clearly remember that!

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

    Code (Text):
    1. if(install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0)
    And change it to:
    Code (Text):
    1. 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()
     
  8. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    1
    0
    being an asshole =P
    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. Isn't there a tool for SMPS2ASM? Wouldn't it be possible to just reverse that? :V
     
  10. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    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.


    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. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    1
    0
    being an asshole =P
    The Allegro documentation itself says that Allegro does that because it uses a different signedness.
     
  12. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    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 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.
     
  13. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Link for the extractor seem dead.

    I always loved this program. :)
     
  14. Nice. I'm in a hurry, so before I can check it out -- Has the FM and PSG emulation cores been updated?

    Cheers!
     
  15. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    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.)
     
  16. Oh my f**k. Very nice indeed!
     
  17. Shoemanbundy

    Shoemanbundy

    Researcher
    1,094
    30
    28
    Chicago, Illinois
    selling shoes
    Is there a reason this would be suffering from incredible stutter and slowdown on my PC? Surely you don't need a megacomputer to be able to get full speed with playback? :/
     
  18. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    Are you using Windows Vista? Vista seems to need larger sound buffer than all other Windows versions.
    SMPSPlay itself worked perfectly fine on my old PentiumII with Windows 2000, so you definitely don't need a strong computer.

    I will include a fix for that issue in one of the next builds.