Dual PCM

Discussion in 'Utilities' started by MarkeyJester, Nov 27, 2016.

Thread Status:
Not open for further replies.
  1. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Don't worry, I'll allow discussions of converters in this thread since it's related. Likewise, it's probably vital to the success of Dual PCM, since if people have tools to help them do the work, then they can use the product in question. So if anything, it's in my best interest to have that discussion going on here. So please do continue, while I don't use the tool, its very discussion of improvements is based around the software I'm writing.

    The code is so complex and precise, that you'd be better off having two Z80 drivers, and swapping the whole thing out. But this may cause havoc with the YM2612 data if not accounted for correctly, and the location as to where the 68k will write some of the data will change (some of it is inside the instructions themselves and cannot be aligned to match between drivers).

    If it doesn't cause a headache for me, then it'll certainly cause a headache for the 68k programmer.

    In fairness, one benefit to a lower sample rate is that it keeps the ROM size down, which is the point in pitch/volume control in the first place, to allow the same samples to be used at different pitches/volumes without having to include separate samples. But, I am trying to increase the sample rate from what it is now, frankly though, even 17,000Hz is a miracle in its own right, just give me time first to find all possible ways of reducing the CPU time.

    Out of my own curiosity, what sample rate would be "acceptable" for you guys? I've always found 16,000Hz to be good enough (voice samples sound OK with it, even those that put heavy emphasis on the "S" noises), I'm still trying to get it as high as possible though, but I'm still curious into all of your views on it.

    In fact, I am due to run a few hardware tests, if you'd like, you could give me a few samples to test with, and I can give you a recording of what they'll sound like on hardware for your interest.
     
  2. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    Since I am not planning on using voice samples really, even something as low as 12000Hz is good enough for most if not all purposes. Some fancier sounds could still disbenefit from that, but I don't feel it to be that much of a worry. Even Ristar with its piss poor 8344Hz playback which is crackly and interrupted all the time sounds 'fine', so I think its really more about finding the best ways to present audio than just pure sample rate alone.
     
  3. Devon

    Devon Down you're going... down you're going... Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    Since a project I'm programming for has quite a few voice samples, then I would say that 16,000Hz is "acceptable" if you say it is. (Though, I should probably ask BinBowie if he agrees, because it's his music EDIT: He does)

    For drum samples (except for the cymbal crash), I don't care too much if it's 16,000Hz or higher, since it isn't as noticeable to hear the quality loss than it is for voice samples, IMO.
     
    Last edited: Apr 3, 2017
  4. LuigiXHero

    LuigiXHero Well-Known Member Member

    Joined:
    Mar 22, 2014
    Messages:
    280
    Considering Super Mario 64 uses 16,000Hz for most of mario's voice samples that should be perfectly fine.
    Example
     
  5. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Do not be fooled. The Nintendo 64 has a 16-bit audio playback, as is that sample being 16-bit. The Mega Drive's DAC port holds 8-bits, with Dual PCM supporting only 7-bit playback to avoid overflow.

    The 16-bit sample can hold an extra 8-bits of precision to the wave position, the 8-bit (or in our case, 7-bit) audio of the Mega Drive has to quantise the lower 8-bit precisions in some way to the next whole upper 8-bit/7-bit number, sounds that are clear in 16-bit, can produce noise at 8/7-bit because of this quantisation. This is the nature of quantisation, and it cannot be avoided, though there are certain techniques to "hide" it, such as dithering.

    But the point is, that sample might not sound as good when in 8-bit, I'd also be careful with using certain software for playback, like Audacity for example, any sample loaded into it is converted to 32-bit floating point for playback, and this creates the misguided conception that an 16-bit/8-bit sounds as good as it does, when it actual fact, the software may be tampering with the audio data in realtime during playback and interpolated it in some way to make it sound good (not too 100% sure about this, a few updates may have fixed this). These features are quite nice, but they make it harder and harder for oldskool audio devs to make audio fairly, for old machines of primitive technology.

    Another thing to consider, is the type of sound being played back, that sample has mario making no sharp sounds, like "S" based sounds. It's a soft "hello" with no distortion. In effect, it's an unfair test...
     
    StephenUK, EMK-20218 and ProjectFM like this.
  6. ESauce64

    ESauce64 Newcomer Trialist

    Joined:
    Feb 25, 2019
    Messages:
    5
    (Sorry if this is an easy fix or anything I'm new to all of this) I followed the guide but when I run Assemble.bat I get this error:

    C:\***\***\***\***\***\S1 HACKING STUDIO V3.0\SOURCECODE\EQUZ80.ASM(13) : Error : Label 'start' multiply defined
    start = $0
    Errors during pass 1 - pass 2 abortedCheckFix: Error, could not open s1built.bin
    Press any key to continue . . .

    I tried looking for where "start = $0" is repeated but couldn't, deleting it from Equz80.asm doesn't help because it gets replaced with a new version that contains the problem when it is being reassembled, can anyone please help me sort this out?
     
  7. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    I suspect the main source code also has a label named "Start" somewhere.

    I would assume it'll be right at the beginning, the Hivebrain 2005 disassembly (of which this driver was built on) does not have "Start" anywhere as a label, so I would assume you have added this driver to a different/newer disassembly of Sonic 1 which has "Start" as a label somewhere in the main code.

    As an alternative solution, if you cannot find this "Start" label anywhere, then open up "Dual PCM\Z80.asm", there will be a "Start:" in there somewhere, either rename it to perhaps "StartDualPCM:" or you could just outright remove it since it's technically referenced, it's up to you.
     
    AkumaYin likes this.
  8. ESauce64

    ESauce64 Newcomer Trialist

    Joined:
    Feb 25, 2019
    Messages:
    5
    Yep, it's all good now. Thanks for the help.
     
  9. Ronald Rose

    Ronald Rose Newcomer In Limbo

    Joined:
    Feb 7, 2016
    Messages:
    10
    How Do I Get the Sonic 3 Drums Onto Sonic 1 And Sonic 2?
     
  10. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Well alright, as the forum has been bumped, I'll share an update!

    The latest Dual PCM Flex-Ed (Flexible Edition) is finished... Actually, it's been finished for basically a year now. Why has it been so long to release? Well, it's the release part that's actually causing the delay.

    So, since the last version, the driver has been written up, then rewritten, then rewritten again, and the 68k side has been thoroughly rewritten to absurd points of destruction from the original (the DAC channel routine was 100% rewritten because it lacked the pitch and volume controlling aspects - like modulation, detune, etc), every-time I got to a release, something would crop up that I didn't even think of, the latest one was PCM SFX support, while I can add support, it requires extra RAM for yet another two channels, I am not even sure the original sound driver RAM size is enough anymore. There is also the issue of needing to supply two updates, one for adding the new driver to a blank version of the game, and one for upgrading from the old (now outdated) version of Dual PCM, the changes are so complex and vast now it would be dangerous to release the driver as is (I am thinking more from a publicity point of view of course, the technical stuff is tricky, but do-able, but if something looks complicated, people will generally avoid it (because people are stupid and simple of course d=)).

    It's gotten so bad that the 68k SMPS side is dragging the driver down, quite badly. The only solution is to write a brand new tracker driver, and given that I've setup the Z80 in preparation of moving the tracker, FM, and PSG stuff to it, it makes sense to just write the whole driver on the Z80 right now, but this further delays the project, and it also means your SMPS tracks will be not be compatible as the driver will be based on a newer format.

    Natsumi had built a 68k tracker driver around Dual PCM Flex-Ed, meant to be an improved version for SMPS, but she hasn't been able to release it since she's been waiting for me to release first. Would you guys be opposed to using her driver in order to use Dual PCM Flex-Ed? If it's not a problem for you guys then we can release the final PCM only version of Dual PCM with an actual driver to play it, and I can then concentrate on the Z80 only version rather than wasting time with the 68k side for release.
     
  11. AkumaYin

    AkumaYin Well-Known Member Exiled

    Joined:
    Aug 21, 2014
    Messages:
    157
    I've been eagerly anticipating both this release and Natsumi's driver, so I'm absolutely in favor of taking this route.
     
  12. Aier

    Aier "Aieru Dotsuto" Member

    Joined:
    Nov 10, 2018
    Messages:
    41
    Location:
    Gensokyo's Boundaries
    To think this update was because of an answer in the wrong place :U. And yeah, I'm with you if you feel like you need to do this.
     
  13. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Don't get too excited. The driver only supplies you support, it won't improve your music skills.

    How well you make music is (and always has been) entirely your intellectual knowledge of music in general and perhaps your intuition and artistic talent, all of these features will not guarantee to improve on your own personal liability with music.

    I have seen cases where the same sound driver sounds awesome in one pair of hands, and sounds dreadful in another pair, and it's totally independent of the driver itself, but the hands of the musician using it.
     
  14. Ronald Rose

    Ronald Rose Newcomer In Limbo

    Joined:
    Feb 7, 2016
    Messages:
    10
    Um, Again, How Do I Get the Sonic 3 Drums Onto Sonic 1 And Sonic 2?
     
  15. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Sorry, I did not want to answer because it has a complicated answer which you will still ask questions about afterwards, but if you are absolutely sure...

    Sonic 1 has a 68k tracker based sound driver, this is known as SMPS, it can read tracker information and process FM and PSG playback, it also handles DAC tracker, but does not do the actual playback of DAC drums, that is sent to a Z80 based driver. This driver can playback the PCM SEGA sample through the 68k access window, or it can play DPCM samples within the Z80 RAM. These DPCM (Differential Pulse Code Modulation), holds the difference between each sample rather than the absolute position, the most predictably common differences of any possible sample are stored in a universal entropy table. Rather than storing the difference byte in the sample, this difference byte is matched to the closest one in the table, and a nybble is stored in the sample, this nybble represents which difference byte to use, since a single nybble references the difference, two nybbles can take the same space a single byte would take, thus cutting the sample size down by exactly half its original size in exchange for some lossy quality. Z80 RAM does not have much space however, you only have $2000 bytes of space for the Z80 instructions responsible for playing the sample, and so, Sonic 1's kick, snare, and timpani sample just barely fit into Z80 RAM along with the code.

    Sonic 2 has a Z80 tracker based sound driver, this is also known as SMPS (a different variation/version), which deals with FM, PSG and DAC playback, both tracker and actual playback of DAC drums. This driver can playback the PCM SEGA sample through the 68k access window, or it can play DPCM samples through the 68k access window. The samples are no-longer held in Z80 RAM, they are now stored in the ROM and accessed through the window, the music tracker itself is compressed in an LZSS variation known as Saxman, and is decompressed into Z80 RAM and processed there. Since the samples are in the ROM, they do not have to worry about space as much as they did in Sonic 1.

    Sonic 3 has a Z80 tracker based sound driver, this is also a variation of SMPS, it also deals with FM, PSG and DAC playback, both tracker and actual playback of DAC drums. The tracker data though is read through the 68k window, along with the samples.

    Sonic 2 and Sonic 3 use the exact same DPCM differential table as Sonic 1 does, so Sonic 1's driver is capable of playing Sonic 2 and Sonic 3's samples directly out of the box, however, Sonic 1's driver is designed to play samples only within its own Z80 RAM, and there is not much space in there for more samples, so, you would need to remove the samples currently in there to make space. While it can have a sample pointer point to the 68k window memory space, the driver does not set the bank window address to anything other than where the SEGA sample is in the 68k ROM ($7F8000 - $7FFFFF), it does this on start up of the Z80 driver, so in theory you could simply "not play" the SEGA sample, and put your DPCM samples in the space where the SEGA sample would have been, and then setup the pointer table to point to them in the window ($8000 - $FFFF), correct size, desired pitch, and so on.

    This does not suffice though as you will still run out of space eventually, so rather than trying to just get the Sonic 1 driver to play the Sonic 2 and Sonic 3 samples, you may as well implement a new DAC Z80 playback driver. I was going to link you to a few drivers, including my own Dual PCM, but then I realised, we are in Dual PCM's thread, so I feel as if linking you to places won't do you any good. The only advice I can give you, is to go back and read the first page very carefully, follow it to the letter. If you need a way of getting Sonic 2 and Sonic 3's samples, you can get them from all of the public disassemblies, you will need to decompress them to raw PCM though, unless you use Mega PCM by vladikomper of which his driver supports DPCM, but again, you're going to have to read his installation guide very carefully, and follow it to the letter.

    Sorry if this is not the answer you are looking for, I am not trying to be evasive intentionally, I really would like to help you, but the only real way would be to talk with you 1 on 1, and do the bulk of the work for you, I think even then you probably won't understand "why" it works, and will need help every single time you want to add in a new sample, and I really do not have the time for that.
     
Thread Status:
Not open for further replies.