SDL_Mixer and speed/pitch shift |
SDL_Mixer and speed/pitch shift |
David Olofson
Guest
|
On Monday 06 August 2007, Sylvain Beucler wrote:
Well, I do (in Kobo Deluxe, which uses un unnamed predecessor to Audiality) - but I wouldn't really recommend using either of those engines for anything serious at this point. They're both effectively dead, and I'm working on some rather different solutions to replace them. (PicoSound for basic streaming/playback/mixing, new Audiality based on a real time scripting engine for advanced synthesis and ChipSound for more retro style and less CPU hungry synthesis.) Depending on what you need though, you might be able to find some useful code in there. Maybe ripping the resampler (voice) code, and using SDL_sound for music? Or, if you're in no particular hurry, you can wait for me to get PicoSound done. ;-) //David Olofson - Programmer, Composer, Open Source Advocate .------- http://olofson.net - Games, SDL examples -------. | http://zeespace.net - 2.5D rendering engine | | http://audiality.org - Music/audio engine | | http://eel.olofson.net - Real time scripting | '-- http://www.reologica.se - Rheology instrumentation --' |
|||||||||||||
|
SDL_Mixer and speed/pitch shift |
James Haley
Guest
|
Hi,
You're correct that SDL_mixer itself doesn't have support for pitch-shifting sounds. However, since it does give you direct access to the sound stream buffer via the mixing callback functions (such as the post-mix callback), you can implement it yourself. My Eternity Engine Doom port has a rudimentary pitch shifting ability. Looking at it might give you an idea on what would be involved. Link to the file: http://eternity.mancubus.net/svn/trunk/eternity/source/sdl/i_sound.c EE just does all its own digital sound mixing and then pipes it through SDL_mixer, which we use mainly for playing music. I should probably note that our sound engine crashes on some x86 Mac machines due apparently to some mysterious bug in SDL_mixer or its interaction with some particular sound driver (it sends us a bad buffer seemingly at random). As of the latest release, this is still a problem for one of my users, so watch out for that when accessing the stream buffer directly. Yours, James Haley
_________________________________________________________________ More photos, more messages, more storage?get 2GB with Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_2G_0507 |
|||||||||||||||
|
SDL_Mixer and speed/pitch shift |
Sam Lantinga
Guest
|
Can you enter a bug in bugzilla with as much info as possible? http://bugzilla.libsdl.org Thanks! -Sam Lantinga, Lead Software Engineer, Blizzard Entertainment |
|||||||||||||
|
SDL_Mixer and speed/pitch shift |
Sylvain Beucler
Guest
|
Hi,
I was thinking that was not possible; for example, if you want to play a sound slower, it takes a bigger buffer to store it, and the callback works with a fixed-length buffer. So at first glance I believe SDL_Mixer will stop the pitch-shifted sound before it ends. Do you think it is possible to bypass this limitation? Thanks for the link. -- Sylvain On Mon, Aug 06, 2007 at 12:27:19AM -0500, James Haley wrote:
|
|||||||||||||||||
|
SDL_Mixer and speed/pitch shift |
E. Wing
Guest
|
One alternative is OpenAL (+ SDL_sound to decode?). Pitch shifting is easy in OpenAL, e.g. alSourcef(mySource1, AL_PITCH, pitch_multiplier); -Eric |
|||||||||||||
|
SDL_Mixer and speed/pitch shift |
Sylvain Beucler
Guest
|
Errata: after a little research it appears I aim at "pitch
transposition" / "sample rate conversion" (which changes the length of the buffer) rather than actual "pitch shifting" (which does not change the length of the buffer). Maybe that better explains my worries about implementing it via a SDL_Mixer callback :) -- Sylvain On Mon, Aug 06, 2007 at 07:59:02AM +0200, Sylvain Beucler wrote:
|
|||||||||||||||||||
|
SDL_Mixer and speed/pitch shift |
Sylvain Beucler
Guest
|
On Sun, Aug 05, 2007 at 11:55:15PM -0700, E. Wing wrote:
Thanks. I had seen OpenAL, though it does not support MIDIs. Do you know if it is possible to mix 'n match several sound libraries at once (like alSourcef and MIX_PlayMUS in the program)? Or maybe I should just try to implement rate conversion in SDL_Mixer.. :) -- Sylvain |
|||||||||||||||
|
SDL_Mixer and speed/pitch shift |
Torsten Giebl
Guest
|
Hello !
SDL_mixer is really meant to be a simple play music in the background and some samples in the foreground. It was never meant to be a Sound System. Have you tried Ryan's SDL Sound ? CU |
|||||||||||||
|
SDL_Mixer and speed/pitch shift |
Sylvain Beucler
Guest
|
On Mon, Aug 06, 2007 at 10:47:57PM +0200, Torsten Giebl wrote:
Sorry, I meant that I need the audio library to play unmodified MIDIs as background and play WAVs at various rates (I don't plan to apply rate conversion on MIDIs). I'll see what I can do with using different libraries for those 2 tasks. -- Sylvain |
|||||||||||||||
|
SDL_Mixer and speed/pitch shift |
E. Wing
Guest
|
I believe SDL_sound does the same technique of WAV conversion for MIDI
as SDL_mixer does so you could still use OpenAL. I don't know if using both SDL_mixer and OpenAL simultaneously is going to work consistently across platforms. I have flashbacks to old Win95 (and 3.1 era) where you would get 'Resource already in use' errors. I do know that libmikmod is not reentrant and if SDL_mixer and SDL_sound are both active and using it, you will have serious problems. 'Native' MIDI is usually a different device/resource on systems, but all SDL_mixer and SDL_sound are doing is converting them to be played back like a WAV. I've always had a soft spot for MIDI, but the truth is that MIDI is pretty much dead outside the musician realm. In my opinion, if all you care about is background music, you're much better off dropping MIDI and not worrying about it. If you use MIDIs, you will be at the mercy of the quality of samples SDL_sound and SDL_mixer's converters use which aren't stellar. If there are MIDIs you really like and want to use, you are much better off getting an old Roland Sound Canvas or Yamaha MU (or both) and recording the song to WAV (or MP3, Ogg, etc) and just using that and shipping the recording ensuring everybody gets a high quality sound track. (Some old games at the end of the MIDI era shipped both MIDI support and recorded music. The recorded music was often a recording of the MIDI playback on the Roland Sound Canvas SCC-1 or SC-55. Recorded music was enabled if you kept the CD in the drive so everybody could experience a higher quality of music and didn't require you to own a Sound Canvas. Warcraft 2 did it this way.) Conversely, you could also write or find something that accesses the MIDI device directly so MIDI gets played back on the separate/native device. (PortMusic/PortMIDI might do this.) And FYI, native MIDI would give you incredible control over 'rate conversion' as you can dynamically change the key (e.g. octave) and tempo independently without requiring one affecting the other. But for instrument/playback quality, you will be at the mercy of the built in MIDI device on the system, and a lot of them are really bad. This is why MIDI has such a bad reputation among the mainstream. -Eric On 8/6/07, Sylvain Beucler <beuc at beuc.net> wrote:
|
|||||||||||||||||
|
AntTheAlchemist
|
I'm still searching for a pitch / speed option for SDL_Mixer. Are there any recent developments?
I know some of you have written your own mixers; something that's beyond my scope of ability without investing a lot of time to understand how to do the same. Surely, if the music part of SDL_Mixer can play samples at different pitches to produce the correct notes, can't the same effect be applied to samples? |
|||||||||||
|