Page 1 of 2

Removing the QTE sounds in Shenmue

PostPosted: Tue Mar 29, 2016 12:10 pm
by BlueMue
I'm trying to figure out how to successfully get rid of the QTE sound effects in Shenmue.

They are in the SYSTEM1.snd file, wich is located in the MISC folder and also in the SOUND folder. Shenmue II uses the same file and location and removing it from the MISC folder gets rid of not only the QTE sounds but also all the menu beeps and even Ryo's footsteps. Even though this is only a stopgap for the "silent" QTEs, it's still useful to get clean QTE cutscenes (comined with invisible QTE buttons).

This method doesn't work in Shenmue however. If the file is removed or just made empty, with all the code removed, it will cause some extremely annoying sound issues. It somehow messes up the DSP effects and whenever someone starts to speak a line or if the notebook dings the reverberation makes a really loud gunshot-like sound.

I guess the only way is to dissected the file in order to pinpoint where the sounds are and only pull that specific block of code out. I didn't have any luck so far, so any kind of help is appreciated.

Re: Removing the QTE sounds in Shenmue

PostPosted: Tue Mar 29, 2016 7:04 pm
by Giorgio
BlueMue wrote:[...] I guess the only way is to dissected the file in order to pinpoint where the sounds are and only pull that specific block of code out. I didn't have any luck so far, so any kind of help is appreciated.

A theory: If someone will go for that route, it may be useful to study the source code of the scripts about ripping/exporting AM2 DTPK sound files: http://snesmusic.org/hoot/kingshriek/ssf/ (look for "Scripts for AM2 DTPK sound driver"), in order to figure out the data structure of the file (such as header, samples etc.) and, thus, be able to delete/remove/nullify from the data the specific sounds.

A query/idea: maybe if the header remains intact and everything else gets nullified (but keeping the size of the original file) it could work?

Re: Removing the QTE sounds in Shenmue

PostPosted: Wed Mar 30, 2016 11:03 am
by shengoro86
Giorgio wrote:
BlueMue wrote:[...] I guess the only way is to dissected the file in order to pinpoint where the sounds are and only pull that specific block of code out. I didn't have any luck so far, so any kind of help is appreciated.

A theory: If someone will go for that route, it may be useful to study the source code of the scripts about ripping/exporting AM2 DTPK sound files: http://snesmusic.org/hoot/kingshriek/ssf/ (look for "Scripts for AM2 DTPK sound driver"), in order to figure out the data structure of the file (such as header, samples etc.) and, thus, be able to delete/remove/nullify from the data the specific sounds.

A query/idea: maybe if the header remains intact and everything else gets nullified (but keeping the size of the original file) it could work?



Blue, I can not wait to see what you have cooking up with this! :)

As for removing QTE sounds, I haven't tried it myself but I know LanDC did a lot of stuff with audio, maybe he might know?

I'd ask him but I shut my facebook off.


BlueMue wrote:
They are in the SYSTEM1.snd file, wich is located in the MISC folder and also in the SOUND folder. Shenmue II uses the same file and location and removing it from the MISC folder gets rid of not only the QTE sounds but also all the menu beeps and even Ryo's footsteps. Even though this is only a stopgap for the "silent" QTEs, it's still useful to get clean QTE cutscenes (comined with invisible QTE buttons).

I guess the only way is to dissected the file in order to pinpoint where the sounds are and only pull that specific block of code out. I didn't have any luck so far, so any kind of help is appreciated.


If they use the same files, could we cross reference the hex between both games? I believe the footsteps would probably be pretty similar from a hex standpoint but the QTEs will be different, especially in scenes where multi-tiered QTEs exist. Maybe that could give some sort of insight as to where the blocks of hex interchange between sounds?

Re: Removing the QTE sounds in Shenmue

PostPosted: Wed Mar 30, 2016 5:38 pm
by BlueMue
I don't plan anything with this yet, James. I wanted to incorporate this into my recent mod video but I pressured myself to get that out. I wish I had looked a little more into it...

Anyway, thanks for the ideas and hints. I took more time to look through the file and cross check it with the one from Shenmue II and I did find the end of the header. It's right after the first "solid" looking block wich isn't far from the start of the file.

Image

With just the header left, it works like in Shenmue II. No QTE sounds, no menu beeps, no footsteps and the page flipping sounds for the notebook are also gone. So this is a good enough working solution for now.

I tried to remove bits of code that stood out and it did show results. The general menu beep was shorter. I removed more and then it started to get messed up. You can hear parts of other sounds overlapping or totally annoying noise. I guess the solution to this would be to not delete code for single sound effects and instead overwrite them with zeros maybe. That way at least things don't change their lines. Might look further into this at some point.

Just to add: The file has a larger header in Shenmue II, with a bunch more lines before DTPK, but the end is the same. So it should work the same there, though I haven't tested it since you can just remove the entire file.

Re: Removing the QTE sounds in Shenmue

PostPosted: Thu Mar 31, 2016 3:26 am
by Radar
Can't say for sure but that how I think it works, In beginning of the file there's data related to sample locations, DSP effects notes, pan, volume, etc.. rest of the file is pure sample data. In HEX editor, if you scroll down a little. you should see noticeable separation between them in form of bunch of "00". So if you fill rest of file after these "00" with "80" you should be able to mute all samples.

Re: Removing the QTE sounds in Shenmue

PostPosted: Thu Mar 31, 2016 10:41 am
by shengoro86
BlueMue wrote: I don't plan anything with this yet, James. I wanted to incorporate this into my recent mod video but I pressured myself to get that out. I wish I had looked a little more into it...

Anyway, thanks for the ideas and hints. I took more time to look through the file and cross check it with the one from Shenmue II and I did find the end of the header. It's right after the first "solid" looking block wich isn't far from the start of the file.

Image

With just the header left, it works like in Shenmue II. No QTE sounds, no menu beeps, no footsteps and the page flipping sounds for the notebook are also gone. So this is a good enough working solution for now.

I tried to remove bits of code that stood out and it did show results. The general menu beep was shorter. I removed more and then it started to get messed up. You can hear parts of other sounds overlapping or totally annoying noise. I guess the solution to this would be to not delete code for single sound effects and instead overwrite them with zeros maybe. That way at least things don't change their lines. Might look further into this at some point.

Just to add: The file has a larger header in Shenmue II, with a bunch more lines before DTPK, but the end is the same. So it should work the same there, though I haven't tested it since you can just remove the entire file.


I am not very familiar with audio hacking in both games. Is it possible to replace these sounds with quiet sound files? So the code remains the same but it loads a nullified audio file? Or is it one giant binary, kinda like a mapinfo binary?

Radar wrote: Can't say for sure but that how I think it works, In beginning of the file there's data related to sample locations, DSP effects notes, pan, volume, etc.. rest of the file is pure sample data. In HEX editor, if you scroll down a little. you should see noticeable separation between them in form of bunch of "00". So if you fill rest of file after these "00" with "80" you should be able to mute all samples.


I think that is already what he tried but I can't say for sure. Thanks for the info!
Sequentially I agree that this makes sense since shenmue seems to be very procedural in their code binaries. Layered in other terms.

Blue:
Is it cool if I take your findings and include them in the mods page? (If you dont have access yourself that is)

Re: Removing the QTE sounds in Shenmue

PostPosted: Thu Mar 31, 2016 12:23 pm
by BlueMue
shengoro86 wrote:I am not very familiar with audio hacking in both games. Is it possible to replace these sounds with quiet sound files? So the code remains the same but it loads a nullified audio file? Or is it one giant binary, kinda like a mapinfo binary?

It's one snd file that contains all the mentioned sound effects in itself. Only way is to mess with it's contents directly.
I think I do have access to the modding page but it's been so long, I honestly forgot how to access it lol.
Sure you can add the info I came up with so far if you like.

Unfortunately I didn't have any luck with anything so far. I overwrote a big block in the beginning of the file with 08 and all the sound effects were muted again. So it must still be a bit that controlls the audio. I went further into the file and overwrote different blocks wich were clearly disconnected from the rest. It didn't make a difference if I overwrote it with 00, 08 or 80, it was always the same glitchy sound. I think I just didn't find the right spots with beginning and end after all...

Re: Removing the QTE sounds in Shenmue

PostPosted: Thu Mar 31, 2016 12:51 pm
by shengoro86
BlueMue wrote:
Unfortunately I didn't have any luck with anything so far. I overwrote a big block in the beginning of the file with 08 and all the sound effects were muted again.

I wonder if the unreadable hex contains multiple sounds in their entirety, so then it would just be trial and error.

BlueMue wrote:
So it must still be a bit that controlls the audio. I went further into the file and overwrote different blocks wich were clearly disconnected from the rest. It didn't make a difference if I overwrote it with 00, 08 or 80, it was always the same glitchy sound. I think I just didn't find the right spots with beginning and end after all...


Yeah probably. I wonder if going down to SH-Assembly would be better for this mod since its pretty much human unreadable when it comes to the audio itself. I think at that level we could see where each file sector is loaded in specific scenes. It is too bad we can't see this in a console on dev hardware or else life would be easier lol.

Re: Removing the QTE sounds in Shenmue

PostPosted: Sat Aug 27, 2016 10:00 am
by Switch
BlueMue wrote: I don't plan anything with this yet, James. I wanted to incorporate this into my recent mod video but I pressured myself to get that out. I wish I had looked a little more into it...

Anyway, thanks for the ideas and hints. I took more time to look through the file and cross check it with the one from Shenmue II and I did find the end of the header. It's right after the first "solid" looking block wich isn't far from the start of the file.
Image

With just the header left, it works like in Shenmue II. No QTE sounds, no menu beeps, no footsteps and the page flipping sounds for the notebook are also gone. So this is a good enough working solution for now.

Nice work on achieving this for both games. The loss of the menu beep when turning off the QTE sounds I'm guessing is because this beep is used in various places like the main menu selection screen, taking out your notebook, receiving or spending pocket money etc. So it gets muted in all those places also which probably can't be helped.

Has anyone has successfully extracted all the expected sounds from the file? I ran FamilyGuy's SND2WAV batch script on the SYSTEM1.SND file from Shenmue 1 to extract the sounds but certain sounds were missing that I would expect to be there. 8 sounds were extracted in total such as the short beep and various footsteps but there was no "notebook page flip" sound or "QTE fail buzzer" sound.

Anyway I tried having a look today to see if the QTE sounds could be muted in a similar way while keeping the other sounds. I found that the four bytes highlighted below correspond to the third sound (short QTE/menu beep). Setting these bytes to zero has the effect of muting all the QTE sounds, while keeping the footsteps - a small advancement? :) However for some reason the notebook page sound also gets muted along with them.
Image

Re: Removing the QTE sounds in Shenmue

PostPosted: Sat Aug 27, 2016 4:58 pm
by raymonf
Switch wrote:
BlueMue wrote:Anyway I tried having a look today to see if the QTE sounds could be muted in a similar way while keeping the other sounds. I found that the four bytes highlighted below correspond to the third sound (short QTE/menu beep). Setting these bytes to zero has the effect of muting all the QTE sounds, while keeping the footsteps - a small advancement? :) However for some reason the notebook page sound also gets muted along with them.


Looking at it, it could be a pointer to where the sound file is at, or the length of the audio file after that header.
Maybe you made the game keep trying to play the sound at 0x0000 (because that's where you set it to) for a certain thread of the sound engine (not sure if thread is the right here, not sure what the DC arch is like), causing it to become an infinite loop there, and thus not play any sound from that file/thread or something?

Re: Removing the QTE sounds in Shenmue

PostPosted: Sun Aug 28, 2016 2:02 am
by Radar
It's been more than year since I tried to do anything with sound, but from what I remember this is how I approached it
Image
This is how snd file looks like. First part I believe consist of data, like where samples located,Volume,Pan,DSP effects, notes(frequencies) etc. and etc.. Second part is pure samples. So my approach was to locate certain sample(s), fill them with "silence" and that's it!

Of course knowing the file structure,it would be much simpler to just edit first part of file,I mean there must be information somewhere about where each sample located or their sizes, or their volume information? but who knows where these bytes are.. Maybe it worth asking FamilyGuy? I think i've seen him at assemblergames.com.

Re: Removing the QTE sounds in Shenmue

PostPosted: Sun Aug 28, 2016 3:28 am
by KiBa
What is this mutilation of innocent code? You'll never get away with this.

Re: Removing the QTE sounds in Shenmue

PostPosted: Sun Aug 28, 2016 4:37 am
by Switch
I was able to extract the full set of sounds from the file after making a small edit to the python script dfsdtpk.py (which is called from SND2WAV). A DTPK sound file contains a certain number of sound "groups", each of which can have multiple "tracks" that represent a single sound. The Shenmue SYSTEM1.SND file does not specify the number of tracks so the script was extracting only the first track from each group. To extract all the sounds, set the number of tracks directly (around line 96 of dfsdtpk.py) to something larger e.g. "ntracks = 0x10".

Anyway, these are the sounds that make up the third "group" in the file - mainly the QTE-related sounds plus the notebook page turning sound:
Tracks 0-7: short QTE beep
Track 8: four quick beeps
Track 9: QTE action correct sound
Track 10: QTE action incorrect buzzer
Track 11: notebook page turn 1
Track 12: notebook page turn 2
Track 13: short beep
Track 14: short beep (quieter)
Tracks 15, 16: silence
Track 17: warning chime

raymonf wrote: Looking at it, it could be a pointer to where the sound file is at, or the length of the audio file after that header.
Maybe you made the game keep trying to play the sound at 0x0000 (because that's where you set it to) for a certain thread of the sound engine (not sure if thread is the right here, not sure what the DC arch is like), causing it to become an infinite loop there, and thus not play any sound from that file/thread or something?

Yes, something like that sounds likely. And since the four bytes correspond to the third group of sounds, all the sounds in the group listed above get muted after if these bytes are modified.

Radar wrote:It's been more than year since I tried to do anything with sound, but from what I remember this is how I approached it

This is how snd file looks like. First part I believe consist of data, like where samples located,Volume,Pan,DSP effects, notes(frequencies) etc. and etc.. Second part is pure samples. So my approach was to locate certain sample(s), fill them with "silence" and that's it!

That's great! I did not realize these samples could be played directly from the file. I think this is the easiest way to achieve BlueMue's goal for now.

I referenced your old post here and tried loading the file into AWave Studio after renaming it to SYSTEM1.YADPCM and can play & view the waveform as in your screenshot. Now it should not be too difficult to locate the position of the QTE-related sounds from within the waveform.

About the DTPK sound file format, I was able to glean some interesting clues about the structure from kingshriek's extractor python scripts but not enough to be able to identify how specific samples are treated. Some more poking around might pay off though.

KiBa wrote:What is this mutilation of innocent code? You'll never get away with this.

O:)

Re: Removing the QTE sounds in Shenmue

PostPosted: Mon Aug 29, 2016 12:25 am
by Radar
Switch wrote:
I referenced your old post..

Yeah, I remember, it was at the time when I made this video :D
phpBB [video]

Switch wrote:About the DTPK sound file format, I was able to glean some interesting clues about the structure from kingshriek's extractor python scripts but not enough to be able to identify how specific samples are treated. Some more poking around might pay off though.

Yes, I expected that there's wouldn't be much information, because kingshriek's extractor doesn't really handles DTPK files directly. Basically it creates compressed with Zlib DSF file that contains DTPK file together with AM2 AICA sound Driver.
So all information should be in AM2 sound driver and nothing we can do about it. Poking around is probably the best we can do for now.

Re: Removing the QTE sounds in Shenmue

PostPosted: Mon Aug 29, 2016 8:32 am
by Switch
Radar wrote:Yeah, I remember, it was at the time when I made this video :D
phpBB [video]

Very convincing! If I didn't know Ryo's character I would think it was straight from the game =D>

After spending a fair amount of time with Awave Studio (30-day trial version is a free download) I eventually managed to precisely locate and mute out the QTE sounds in the Shenmue SYSTEM1.SND file. In Awave Studio the sounds play at a different default speed & pitch than in the game so are a bit harder to recognize, plus the interface for playing and editing is pretty restricted so it took much longer than I'd expected. Oh yeah, the trial version of the software makes you restart after every file save too. #-o

After editing the soundwaves and resaving in the same format (Yamaha 4-bit ADPCM @8000Hz) I reinstated the header bytes from the original file since they are corrupted after saving from Awave. Finally I copied the file back on top of the original SYSTEM1.SND file in the MISC directory, and rebuilt the disk image to test. It worked nicely!

The modified SYSTEM1.SND can be downloaded here.

Quick video of the result:
phpBB [video]


Although it would still be kind of nice to get the result without the hassle of editing the actual samples.