PDA

View Full Version : Kanon on Mac OS X & Music Issues


Roto
2005-03-31, 18:43
I can't seem to get the music to work on Mac OS X. With the version of Kurokoge listed on the download page, the game seems to run relatively well, but I don't get any of the music from the CD. If I download the Japanese binary of Kurokoge, the music works fine, but the text in the game has alignment problems. Downloading the source for the Japanese version and building it myself also results in a game without music.

Any suggestions? I'm running Mac OS 10.3.8 with the adult version of the game.

Edit: I'm guessing that it has something to do with the fact that iTunes is re-naming the files with the names of the tracks from the CDDB, and that Kurokoge is looking for them to be called "Track 02" or similar. Unfortunately, the fact that I can't read Japanese makes it hard for me to decipher the comments in the source code...

Edit, again: It looks like there's some information on this on the Kurokoge page, specifically note number 5. I'm having about as much luck deciphering Google's translation as I would have had trying to read it in Japanese, though. If anyone could tell me what that says, I would appreciate it greatly. :)

(Note number 5 on this page: http://www001.upp.so-net.ne.jp/keta/kurokoge/ )

Haeleth
2005-04-01, 01:28
Note 5 suggests ripping the music from the CD to MP3 files and putting them in the game directory with Kurokoge. It says you can use several different methods for naming the files: you should be able to see what it's suggesting there without needing to read Japanese. ;)

If that doesn't work I'll take a look at the music code and see if I can figure out what the problem is...

Roto
2005-04-01, 10:46
Thanks... I figured it was saying something like that, so I tried it, and still no music. I also tried the .aiff files straight from the CD copied into the game directory and had no luck with that, either. I also tried the files in the DAT folder, still with no luck.

I've also noticed that the voice patch files that I have installed do not play with the newer Kurokoge either. Sound effects, however, work fine (doors closing, footsteps, etc.)

Looking more closely at the Kurokoge site, I see that the binary version I downloaded (which plays the soundtrack and the voice files just fine) is the one at the very top of the page: the CodeWarrior version. I'm suspecting that something was changed in between the CodeWarrior and the Xcode versions (or it just compiles differently with gcc) that breaks some of the audio stuff.

Okay, I just did some experimenting with the CD out of my drive. The Japanese CodeWarrior binary plays the .aiff files that I imported into the game folder, but the Xcode version still does not (and still won't play voice files, either.) So it's not just reading the audio CD that's causing problems.

And here's another observation that may or may not be relevant. The first version of Kurokoge I downloaded was the patched English version, from this site. I couldn't get it to start (the window would show up briefly and then it would quit.) That's what led me to download the Japanese version, which opened fine, played the music, etc, but has problems with the dialogue. After having started the Japanese version once, the English version launches fine. Through experimentation, I found that it needs a ????.plist file [note: that should be 'kurokoge' in hiragana, but my browser/phpbb isn't behaving] with a font setting in it in the preferences folder, or it won't start. Launching the Japanese version creates this file with the necessary setting. Since the font setting isn't getting properly added to the preferences with the patched English version, is it possible that there is some other preference setting that the new version needs to play the soundtrack and voice files properly? Here is my ????.plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http&#58;//www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Font</key>
<string>Hikyaku</string>
<key>TrackNames</key>
<array>
<string>%d</string>
<string>%02d</string>
<string>%d.mp3</string>
<string>%02d.mp3</string>
<string>Track %02d</string>
<string>Track %02d.aiff</string>
<string>Track %02d.mp3</string>
<string>�g���b�N %02d</string>
<string>�g���b�N %02d.mp3</string>
</array>
</dict>
</plist>

Thanks for any help you can offer. I'm slowly picking my way through the source code trying to find an answer to this, but for me it might as well be uncommented and C++ and the Carbon framework isn't a language I'm particularly familiar with either...

Roto
2005-04-01, 13:42
I think I've figured out what's going on. The CodeWarrior version builds as a single file executable (Mac OS 9-style) whereas the Xcode version builds as a Mac OS X bundle (meaning that the actual executable file is inside of kurokage.app/Contents/MacOS/ ). As a result, it's guessing the game directory is ~/Kanon/kurokoge.app/Contents/MacOS/ rather than ~/Kanon/. Obviously this has been compensated for in parts of the source, otherwise the game would not run at all (it wouldn't find gameexe.ini). However, it doesn't compensate for this in looking for the music files. I tested this out by putting the track files in the Contents/MacOS/ directory and sure enough, the music plays.

So, I have a temporary fix for the music, but it doesn't work for the voice files. I tried both aliasing and symlinking the DAT directory into the Contents/MacOS/ folder, but that didn't help. I just need to find where in the source the paths to the voice and music files are determined and fix it there.

I'm slowly working my way through the code, but if someone who's worked with it before can point me in the right direction to look, it might save me a little time...

:)

Haeleth
2005-04-01, 13:50
Now that's the kind of bug report I like. Detailed and containing the solution. ;)

I'm out of town this weekend, so I can't look through the code myself, but I'll be able to get on it probably Monday or Tuesday if you're still looking at that point.

Roto
2005-04-01, 16:54
Well, I've been messing with the code for a while and haven't really gotten anywhere (well, I guess I've learned a bit about C++ and a bit about AVG32...)

For now, I'm able to play the game with music by placing aliases to the files in the Contents/MacOS folder. That's really a workaround rather than a fix, but it works.

I'm at a loss for why the voice files aren't playing. They're called with the same opcode as the sound effects [$30] (which do work.) The only difference is that they are in a directory inside of the DAT directory, whereas the sound effects are just loose in DAT. Here are a few possibilities I can come up with:

OS X uses "/" as its directory separator. Classic Mac OS uses ":". The AVG uses the Windows "\". On line 402 of soundmgr.cpp, the backslashes are converted to colons. This may or may not need to be changed to a forward slash to work on OS X; changing it still doesn't fix it. (So it may be part of the solution, but it's definitely not the only thing.)

OS X is somewhat case-sensitive in terms of file names; it may not like the fact that the files are named with a lowercase .wav and the source is using a capitalized WAV. I tried renaming a few of the files, but that still didn't help.

Since I really don't understand how Carbon handles files very well at all, nor do I really follow the intricacies of C++ syntax, it's becoming an exercise in frustration.

I'll probably keep trying things for a while, but I don't really hope to get anywhere. Hopefully what I've found out thusfar will be helpful to someone who actually knows what's going on ;)

Roto
2005-04-09, 23:27
Well, after a week of not looking at the code and coming back to it, I'm onto something. I have determined the reason for the voice sounds not playing.

The AVG bytecode refers to the file (in this case, Nayuki's "Yuki?") as 0\0000. Kurokoge replaces the backslash (path separator on Windows) with a colon, and adds the .WAV to the end. The resulting partial path gets passed to FileReference::Find, which uses FSMakeFSRefUnicode to get an FSRef to the file. FSRef returns a fnfErr (File Not Found Error).

The reason for this is clearly outlined in Apple's docs for FSMakeFSRefUnicode:

The name must be a leaf name; partial or full pathnames are not allowed. If you have a partial or full pathname in Unicode, you will have to parse it yourself and make multiple calls to FSMakeFSRefUnicode.

Since it's being passed a partial path, it doesn't work.

This explains why the game's sound effects work but the voice files don't: the sound effects are located out in the DAT directory, while the voice files are inside numbered folders inside the DAT directory and are referred with a partial path in the bytecode.

Unfortunately, as I've mentioned before, my C++ is not good enough to be able to figure out how to parse the path name into its individual parts (especially because it's working with UniStrings instead of plain c strings) and make a call on FileReference::Find for each part of the path.

If someone who knows something about the Carbon File Manager and C++ could write me a fragment of code (which should be relatively simple) or even take a look at the appropriate lines in FileReference.cpp I would be really happy.

Roto
2005-04-10, 00:54
First off, apologies for replying to myself twice in a row.

I am way too stubborn for my own good.

I dug out my copy of K&R and figured out a way to kluge together a really messy solution, but it actually works. I made my changes in soundmgr.cpp, where the file is still referenced as a char array rather than a UniString (char arrays I can deal with, UniStrings throw me for a loop...)

I'll post my code if you want it, but someone should really fix this in its proper place (in FileReference.cpp) and make it compatible with paths more than one level deep.

For now, though, I've got a copy of Kurokoge that actually plays the voice files, plays the music (once the files are aliased into Contents/MacOS) and displays text correctly! Sure, it's practically held together with duct tape, but it works.

I hope the information that I've reported in this thread will be helpful when someone who actually knows what they're doing can take a look at it.

Haeleth
2005-04-10, 03:30
Do you think you could send me a copy of your changes? At the very least it would save me a little time working out which bits to look at...

Roto
2005-04-10, 12:52
Sure.

Here's the output of diff on soundmgr.cpp.

393d392
< int i;
395a395,396
> char *dirname = new char&#91;256&#93;;
> char *fname = new char&#91;256&#93;;
399,409c400,402
< /* 音声化パッ�対策 */
< for&#40;i = 0; *&#40;f+i&#41;; i++&#41;
< &#123;
< if&#40;*&#40;f+i&#41; == '\\'&#41; *&#40;f+i&#41; = '&#58;'; // f&#91;&#93; 内�'¥'を'&#58;'�置�
< &#125;
<
< /* ���� */
<
<
< // ファイル�リファレンス
< FileRefPtr WAVEFile;
---
> // break up the file name at the backslash, if it has one
> dirname = strtok&#40; f, "\\" &#41;;
> fname = strtok&#40; NULL, "\\" &#41;;
411,412c404,405
< sprintf&#40; file, "%s.WAV", f &#41;;
< WAVEFile = FileReference&#58;&#58;Find&#40; ini->wavdir, file &#41;;
---
> FileRefPtr WAVEFile;
> FileRefPtr WAVEDir; // new var to store the directory the file's in
413a407,419
> // if fname's not null, it means there were at least two parts to the
> // pathname. The second one is assumed to be the file &#40;i.e. this won't
> // work for paths more than one directory deep&#41;
> if&#40; fname != NULL &#41; &#123;
> sprintf&#40; file, "%s.WAV", fname &#41;;
> WAVEDir = FileReference&#58;&#58;Find&#40;ini->wavdir, dirname&#41;;
> WAVEFile = FileReference&#58;&#58;Find&#40; file, WAVEDir->GetFSRefPtr&#40;&#41; &#41;;
> &#125; else &#123;
> sprintf&#40; file, "%s.WAV", f &#41;;
> WAVEFile = FileReference&#58;&#58;Find&#40; ini->wavdir, file &#41;;
> &#125;
>
> // do the same thing for .MP3 and .WAV.MP3 until we get a valid file
417,418c423,430
< sprintf&#40; file, "%s.MP3", f &#41;;
< WAVEFile = FileReference&#58;&#58;Find&#40; ini->wavdir, file &#41;;
---
> if&#40; fname != NULL &#41; &#123;
> sprintf&#40; file, "%s.MP3", fname &#41;;
> WAVEDir = FileReference&#58;&#58;Find&#40;ini->wavdir, dirname&#41;;
> WAVEFile = FileReference&#58;&#58;Find&#40; file, WAVEDir->GetFSRefPtr&#40;&#41; &#41;;
> &#125; else &#123;
> sprintf&#40; file, "%s.MP3", f &#41;;
> WAVEFile = FileReference&#58;&#58;Find&#40; ini->wavdir, file &#41;;
> &#125;
423,424c435,442
< sprintf&#40; file, "%s.WAV.MP3", f &#41;;
< WAVEFile = FileReference&#58;&#58;Find&#40; ini->wavdir, file &#41;;
---
> if&#40; fname != NULL &#41; &#123;
> sprintf&#40; file, "%s.WAV.MP3", fname &#41;;
> WAVEDir = FileReference&#58;&#58;Find&#40;ini->wavdir, dirname&#41;;
> WAVEFile = FileReference&#58;&#58;Find&#40; file, WAVEDir->GetFSRefPtr&#40;&#41; &#41;;
> &#125; else &#123;
> sprintf&#40; file, "%s.WAV.MP3", f &#41;;
> WAVEFile = FileReference&#58;&#58;Find&#40; ini->wavdir, file &#41;;
> &#125;