If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler
NEW : We have got a new blog where we post some interesting SWF internals info.

#2451 Replacing SoundStreamHead with gaps doesn't work as expected
Author:
Vicious

Date created:
Type: feature
Visibility: Everybody
Assigned to:
Labels: Sound
State: closed 

> What steps will reproduce the problem?
Replace a SoundStreamHead entry which contains multiple SoundStreamBlocks entries with
frame gaps between them with a file from disc. Let's say, there's 5 SoundStreamBlocks for
the following frame sequencies:
954-973
982-1016
1060-1234
1251-1277
1375-1854
> What is the expected output? What do you see instead?
The layout of the entries is preserved. What JPEXS does instead is it creates a single
SoundStreamBlock entry that spans frames 954-1680. Removing sound blocks from individual
frames isn't going to work, so there's no way around this other than maybe padding sound
data with silence to match the original gaps.
> What version of the product are you using? Is it "nightly build"? Which operating system
do you have?
v22.0.2, Windows 10
In nightly 3185, you can replace individual SoundStreamBlock ranges.
However, it is required to specify file with exact same sound format (bits / stereo/mono /
soundrate / format) as the original sound stream head.
State: new→upgraded
Type: bug→feature
Type: bug→feature
Hm.. The imposed limitations are quite unfortunate as the make remastering of old games as
equally impossible as the broken approach did :)
The problems are:
1) All sound ranges in the stream must be in the same format (they have same head)
2) I cannot do and do not want to do any sound encoding of the formats (to MP3, to ADPCM,
...)
3) I don't think importing whole soundstream without(!) gaps and then distributing it to
the ranges as you suggested is a good idea. The soundstream is exported to separate files
- 1 file per range and should be imported in the same manner.
I think there may be another way:
- Select file to replace specific range.
- Decode the whole original stream to raw WAV uncompressed data.
- Decode newly selected file to WAV uncompressed data
- Handle sound rate and mono/stereo, 16bit/8bit somehow
- Set format of head to WAV uncompressed data
- Replace the range with the data from selected file
Unfortunately, this may significantly increase the SWF file size.
What's your opinion?
Don't get me wrong, replacing individual ranges is still a HUGE improvement and is much
appreciated. Thank you for taking the time to implement it!
With that said, I don't quite understand how converting them to uncompressed WAVs may
allow us to workaround the bitrate limitation given that the imported file format should
match the original. That is, a 16kbps MP3 range can only be replaced with a 16kbps MP3
file.
Ad "I think there may be another way" .. "I don't quite understand..."
I thought the conversion would be done by FFDec, not by you manually.
The Stream head would be 16kbps MP3 stereo.
You select a file to replace range 1060-1234 with 128kbps MP3 mono.
FFDec will convert the whole stream (all ranges) to uncompressed stereo WAV,
setting head format to WAV.
Then I will convert your selected file to uncompressed WAV stereo.
It can then replace target range, because now HEAD and new file match (they are both
uncompressed WAV stereo).
But as I said, this will increase file size, since it is not an MP3 anymore.
Hm.. I think the conversion process should probably keep the number of channels intact.
That is, you'd be able to replace mono with mono and stereo with stereo.
Otherwise it'd work just fine at least in my case since sound streams are few and far
between in the game that I'm working on.
In nightly 3191, the replacing of ranges uses conversion(of whole stream) to uncompressed
when the sound format does not match.
It also converts parameters like mono/stereo, sound rate, bitness when needed (always to
higher value).
Excellent, thank you!
The new feature works almost perfectly. One thing that I noticed is that after importing
the new files the sound rages have changed slightly, off by a couple of frames.
In nightly 3195 I modified MP3 frames placement a bit, might be related.
Yes, the ranges may be a bit different, since MP3 is placing MP3FRAMES, but uncompressed
waw allows more precision placing sound samples. MP3 may then take slightly different
number of SWF frames than WAVe,
but the resulting playback should be very similar.
If you still think it is a problem, then give me sample SWF file and sounds files you are
trying to replace the ranges with, I can take a closer look.
I think everything seems to work fine at this point. At least it's a workable situation
and a definite improvement. Whatever issues there might be, I believe they can be tracked
separately.
Thanks a lot!
State: upgraded→closed