Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
Acmlm's Board - I2 Archive - - Posts by kode54
User Post
kode54

Level: 4

Posts: 1/7
EXP: 246
For next: 33

Since: 05-09-05

Since last post: 154 days
Last activity: 133 days
Posted on 05-09-05 09:51 AM, in Not really rom hacking but still... Link
Originally posted by Keitaro
Heh...this reminded me just how much of a BITCH BRR-compression is...good luck if you do go after those samples


Here is a foobar2000 component which contains SNES and PSX ADPCM decoders and encoders, among other things. It slaps a simple header on files, and supports uggly stereo interleave that the real hardware would never support. The player and converter (use foobar2000 converter component) are basically just to play around with the format. (Plus, when I find some odd format with an odd loop point, and I don't want to use whatever software is otherwise required to play the stuff, I convert it to this format and hack in the loop point myself. I've only done this a few times, though...)

Anyway, link to binary:

http://www.saunalahti.fi/cse/kode54/foo_adpcm.zip

The source code itself would probably be more relevant for general use. The encoder, which is loosely based on the MS ADPCM encoder from SoX (adpcm.c), is in brr.cpp. Good ol' brute force attack. Although, I'm not sure that it represents the SPC-700's odd clipping behavior properly. Or, maybe the real problem is the emulators... Test on real hardware with SPC2ROM? Or, play it safe and make sure none of the samples peak over ~95% amplitude.

http://www.saunalahti.fi/cse/kode54/foo_adpcm_source.zip

*Whew*

Oh yeah, and before I forget, some tips for preparing samples. Testing shows one-shot samples end 25 samples before the end (block marked with the end bit is discarded, as are the last 9 samples from the block preceding it) probably due to some look-ahead mechanism. So, account for this by padding one-shot samples with 25 samples worth of silence on the end, then round that padding up until the length is a multiple of 16 samples.

Looped samples should be even more fun, as the loop has to be an exact multiple of 16 samples. Note how the brute force function can also be forced to "hint" its search to fit the two samples preceding the loop start point, so the loop hopefully meshes / fits / whatever when run through the ADPCM decoder.

I'm done now, really. I think...


(edited by kode54 on 05-08-05 04:52 PM)
(edited by kode54 on 05-08-05 05:05 PM)
kode54

Level: 4

Posts: 2/7
EXP: 246
For next: 33

Since: 05-09-05

Since last post: 154 days
Last activity: 133 days
Posted on 05-10-05 06:56 AM, in Not really rom hacking but still... Link
Originally posted by Darth Mole

@Dwedit ~ 5 half tones too low?
What I did for this converter was just adding 0x80 to the .org tone height values (thus transferring them 1:1 to the N-SPC tone range) and replacing any tones that ended up being higher than 0xC8 (which appears to be the upper limit of the N-SPC tone height range) with zero tones (0xC9). Now, because I mainly use Snes9x as an emulator, the songs sounded too high for me, so I added a transpose 0xFB command to every track. The parameter for transpose is signed, so the music was lowered by exactly 5 half tones. Heh.
http://a3o.attrib.org/cs_gravity_h.spc - here's a version of "Gravity" with nulled transpose commands.

For reference, you may wish to check against SNESAmp or Game_Music_Emu. (foo_gep would be one front-end, or you could toss together your own based on the included demo code.)

I'm not so sure about Snes9X. Maybe v1.43 is nearly up to spec, but it lacks Gaussian interpolation, as well as cycle-accurate sample generation. The pitch was off for many versions due to an improper rate conversion, and I have completely forgotten if that was fixed. Mainly because my build doesn't use the original sound code, heh.


@kode54 ~ what do you mean by "one-shot samples"? Do you mean especially short ones, or does that limitation with the 25 dropped samples apply to all of them?

If it isn't looping, it's a one shot sample. This behavior is quite noticeable in both Earthworm Jim and Plok, where several percussion and voice samples are apparently padded with whatever garbage was left in some buffer instead of silence, and therefore produce obvious popping noises on the ends if the emulator doesn't observe this behavior.


Anyway, welcome to Acmlm's board.

Thanks.
kode54

Level: 4

Posts: 3/7
EXP: 246
For next: 33

Since: 05-09-05

Since last post: 154 days
Last activity: 133 days
Posted on 06-01-05 06:26 AM, in How do you feel about the recent Chrono C&D orders? Link
You forgot the "They knew it was coming and everything worked out exactly as planned" option. Although, I suppose unlike Square-Enix, they wouldn't have been able to get away with admitting all their work was a bid for attention. Square-Enix can tell everyone that their FF7 PS3 tech demo does not mean they are remaking FF7, but people will either refuse to believe them, or "know" they are hiding the truth. Yeah, they already have it completed and slated to release at the same time as the Advent Children movie. Coincidentally, that will be the same day that Duke Nukem Forever is released.
kode54

Level: 4

Posts: 4/7
EXP: 246
For next: 33

Since: 05-09-05

Since last post: 154 days
Last activity: 133 days
Posted on 06-01-05 06:33 AM, in Time() fails in PHP Link
Also works here, using the official win32 build of v5.0.4. What do you get when you echo time()?
kode54

Level: 4

Posts: 5/7
EXP: 246
For next: 33

Since: 05-09-05

Since last post: 154 days
Last activity: 133 days
Posted on 06-01-05 06:43 AM, in Grabbing URL's with PHP? Link
Here's a regular expression I kind of borrowed from Invision Power Board months ago, and later modified. As you can see, it uses case insensitive (i) and also PHP's extended execute (e) attribute, which treats the replacement string as a piece of code to execute instead of merely a replacement. I think you can still catch the echoed output by assigning the return value to an array, but this works as well:

$urls = array();

preg_replace('#(^|\s|"|'."'".')((http|https|news|ftp)://\w+[^\s\(\)\[\]"'."'".']+)#ie', '\$urls[] = "\2"', $input_text);

Token 2 (the complete link) in every match will be pushed into $urls. Token 1 is only there for the original code to preserve the preceding whitespace, but I added various quotation marks since I encountered various IRC logs where clients or servers added the quotes or other characters.

It is probably not a good idea to use this string in a redundant manner, rather to process data once and record somewhere that you processed it. Well, since you're processing a web page, that should mean less complexity than what I was doing. (Thousands of lines of IRC logs, all processed from a MySQL server, every time the page is loaded... No I won't demonstrate.)

Also, if you know what you are doing, and you will always be processing properly formed X/HTML content, it may be more secure to parse the pages with the XML extension and locate all anchor tags. Then worry about the Regex if/when you need fulltext scanning.
kode54

Level: 4

Posts: 6/7
EXP: 246
For next: 33

Since: 05-09-05

Since last post: 154 days
Last activity: 133 days
Posted on 06-01-05 07:33 AM, in Grabbing URL's with PHP? Link
That does not treat user input as code. It merely processes a token of the data which the expression finds using its own code. I don't think it's vulnerable to double-quotes faking out the processor code either. Even if that were possible, the expression cuts off at the first single or double quote character. There may yet be a vulnerability somewhere in there, but since IPB is using almost the same code, I presume it to be safe.

Just to clarify the preg_replace "e" flag, it specifies that your replacement string, which in this case is a string constant, is a piece of PHP code to be executed once per match. I will have to look it up again, as I am not sure if it means that said code can "echo" or otherwise manipulate the standard output and in turn be piped as the replacement text, which is eventually output as the return value of preg_replace(). My example simply ignores the return and stores the data in an array created outside of the function. In fact, you could do like my code does and further foreach() parse an array of strings, or while() parse a SQL result set.

As I said, Regex isn't the only way. You may want to experiment with the XML extension, it may prove to be faster for handling just anchors and/or img tags than scanning the raw text with a regular expression.
kode54

Level: 4

Posts: 7/7
EXP: 246
For next: 33

Since: 05-09-05

Since last post: 154 days
Last activity: 133 days
Posted on 06-01-05 10:14 AM, in Grabbing URL's with PHP? Link
Here is information on the function handling functions. call_user_func may be what you want, but create_function may also be handy for declaring the function at once, or even custom generating function code on the fly, in the event that you find it more efficient to generate one function to be executed repeatedly.
Acmlm's Board - I2 Archive - - Posts by kode54


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.006 seconds.