Help with adding something to the source code...
Moderator: ScummVM Team
Help with adding something to the source code...
I'm looking for a way to introduce a piece of code in the middle of scummvm execution so I can load and play an mp3 file.
I don't think it should be very difficult for someone who understands how this source works, but I don't know the way to do it.
What I want to do is just open an mp3 file and play it. Then, probably, close or destroy it. It could be streamed instead of loaded to memory, also.
Is there any programmer who can bring help to me with that?
Thanks in advance!
I don't think it should be very difficult for someone who understands how this source works, but I don't know the way to do it.
What I want to do is just open an mp3 file and play it. Then, probably, close or destroy it. It could be streamed instead of loaded to memory, also.
Is there any programmer who can bring help to me with that?
Thanks in advance!
- dreammaster
- ScummVM Developer
- Posts: 559
- Joined: Fri Nov 04, 2005 2:16 am
- Location: San Jose, California, USA
Re: Help with adding something to the source code...
That's an incredibly vague request. ScummVM consists of almost 50 game engines, many of which support multiple different games. So are you talking about a specific game? And when do you want the mp3 to be launched? Is this a case of trying to add speech support to a specific game? If so, then it would have to be hooked into the game's existing text display code for characters "speech", so couldn't be done generically for all ScummVM games. Not to mention that there'd be other secondary things you'd have to worry about too, in the case of speech, such as hacking the text display not to finish displaying what the character said until the MP3 of the speech had finished.cisco17 wrote:I'm looking for a way to introduce a piece of code in the middle of scummvm execution so I can load and play an mp3 file.
You'd likely do better narrowing your focus, and discuss it on the IRC channel. If it's a case of adding speech to an existing game, and you can demonstrate some effort already done to create a speech pack, you might be able to entice someone to assist you with the programming.
Well, I'm sorry you found this request incredibly vague. Probably it is, but in the other thread I'm asking for the same with more explanation, I have been waiting and trying again for like 5 years with no luck or much interest.
So, as you supposed, that's what I wanted to do: a speech pack, concretely for Maniac Mansion and specifically in Spanish.
I have compiled a debug version of ScummVm where everytime an actor talks, a name for a wave file is generated depending on the actor number and the text.
In the same place of the code, a part that loads and plays this wave (or mp3) could be added, an also, a hack for the delay time for the text so it waits for the mp3 to finish.
I can do the speech pack. The actors and actresses part is not a problem. The problem is the tecnical part.
There is no hurry to do this project, I have been going to it for several years. But it could be great to try.
So, maybe I could go to IRC channel to seek for help?
So, as you supposed, that's what I wanted to do: a speech pack, concretely for Maniac Mansion and specifically in Spanish.
I have compiled a debug version of ScummVm where everytime an actor talks, a name for a wave file is generated depending on the actor number and the text.
In the same place of the code, a part that loads and plays this wave (or mp3) could be added, an also, a hack for the delay time for the text so it waits for the mp3 to finish.
I can do the speech pack. The actors and actresses part is not a problem. The problem is the tecnical part.
There is no hurry to do this project, I have been going to it for several years. But it could be great to try.
So, maybe I could go to IRC channel to seek for help?
- dreammaster
- ScummVM Developer
- Posts: 559
- Joined: Fri Nov 04, 2005 2:16 am
- Location: San Jose, California, USA
Ah, that explains it. I wasn't really aware of the other thread; I've probably seen it in passing and only skimmed over it. Sounds like an interesting project, although the Scumm engine is (from what I gather) one of the more complicated engines, which is probably partly why you've had trouble finding any interested parties. I honesty can't say if you'll find anyone on IRC either, but it certainly couldn't hurt.cisco17 wrote:Well, I'm sorry you found this request incredibly vague. Probably it is, but in the other thread I'm asking for the same with more explanation, I have been waiting and trying again for like 5 years with no luck or much interest.
- dreammaster
- ScummVM Developer
- Posts: 559
- Joined: Fri Nov 04, 2005 2:16 am
- Location: San Jose, California, USA
- eriktorbjorn
- ScummVM Developer
- Posts: 3561
- Joined: Mon Oct 31, 2005 7:39 am
I guess it would be just a matter of opening the file, using the Common::File class. That class inherits from Common::SeekableReadStream, which can be used to create an MP3 stream, using the Audio::makeMP3Stream() method. That can then be played using the mixer's playStream() method.cisco17 wrote:By the way, with what I said, do you think as a developer that maybe you can help me with a little piece of code that just loads and play (or streams) and mp3 file?
Of course, there's a bit more to it than that, since some of those functions take a few more parameters. Also, note that makeMP3Stream() will only be available if USE_MAD is defined.
Instead of using the File class and makeMP3Stream() method, I guess you could also use the Audio::SeekableAudioStream::openStreamFile() method, which should look for any supported compressed format. But the original question was about MP3 specifically...
I can't test any of this at the moment, but you should be able to find examples by searching through the ScummVM source code.
This is very helpful!
But I'm stuck because I'm not really sure of what I'm doing with the code. Everytime I look for something related with sound and paste it trying it to work on the file I'm modyfing (string.cpp inside engines/scumm) I got messages when compiling like things not declared on this scope, logically.
At this point I'm on the code place where I can "freeeze" the time counter for the talkdelay, and here is where I want to load and send to the mixer the mp3 (or ogg, maybe better).
Maybe I have to declare at the start of string.cpp the audio before beeing able to load and play it, or something
This is what I tried the last:
I'm trying to just make a test.mp3 play, before trying to locate for specific filenames, but I have no luck because I'm kinda blind here. But I think the way must be not very different from this....
What I get here when trying to compile is:
'_musicHandle' was not declared in this scope
'loops' was not declared in this scope
But I can't replace them with another thing because I don't know what I have or can put there
But I'm stuck because I'm not really sure of what I'm doing with the code. Everytime I look for something related with sound and paste it trying it to work on the file I'm modyfing (string.cpp inside engines/scumm) I got messages when compiling like things not declared on this scope, logically.
At this point I'm on the code place where I can "freeeze" the time counter for the talkdelay, and here is where I want to load and send to the mixer the mp3 (or ogg, maybe better).
Maybe I have to declare at the start of string.cpp the audio before beeing able to load and play it, or something
This is what I tried the last:
Code: Select all
Audio::SeekableAudioStream *stream = Audio::SeekableAudioStream::openStreamFile("test.mp3");
if (stream) {
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, Audio::makeLoopingAudioStream(stream, loops ? 0 : 1));
return;
}
What I get here when trying to compile is:
'_musicHandle' was not declared in this scope
'loops' was not declared in this scope
But I can't replace them with another thing because I don't know what I have or can put there
You need a sound handle to play a sound. 'loops' refers to sound looping. The file name refers to the base file (without the extension).
Try:
Try:
Code: Select all
Audio::SeekableAudioStream *stream = Audio::SeekableAudioStream::openStreamFile("test");
Audio::SoundHandle speechHandle;
if (stream) {
_mixer->playStream(Audio::Mixer::kSFXSoundType, &speechHandle, Audio::makeLoopingAudioStream(stream, 1));
return;
}
It's done! It was JUST what I need!
Now it plays perfectly a test.ogg (missing a test.flac and test.fla before) everytime a text phrase is said, so I can rework that with what I have done and make it play the specific ogg file for each phrase!
Some things that could help me now, if you want to help me a little more, are:
- Make the program directly look for OGG files instead of first trying flac and fla.
- There is a way to check if the sound is still playing and another one to stop it?
THANK YOU VERY MUCH!!!
Now it plays perfectly a test.ogg (missing a test.flac and test.fla before) everytime a text phrase is said, so I can rework that with what I have done and make it play the specific ogg file for each phrase!
Some things that could help me now, if you want to help me a little more, are:
- Make the program directly look for OGG files instead of first trying flac and fla.
- There is a way to check if the sound is still playing and another one to stop it?
THANK YOU VERY MUCH!!!
- eriktorbjorn
- ScummVM Developer
- Posts: 3561
- Joined: Mon Oct 31, 2005 7:39 am
Well, then you're back to creating the specific kind of audio stream I mentioned earlier, I guess.cisco17 wrote: - Make the program directly look for OGG files instead of first trying flac and fla.
When you started playing the audio stream, you presumably passed a SoundHandle to the mixer as one of the parameters to playStream(). If you still have that sound handle available, you should be able to use the isSoundHandleActive() and stopHandle() methods in the mixer.cisco17 wrote: - There is a way to check if the sound is still playing and another one to stop it?