We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 701 - Add ability to set Sound playback from an offset
Summary: Add ability to set Sound playback from an offset
Status: ASSIGNED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86 Other
: P2 API change
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL: http://www.sf.net/projects/opensebj
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-14 15:50 UTC by Sebastian Gray
Modified: 2009-10-11 00:48 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Gray 2009-02-14 15:50:35 UTC
Hi,

I've been porting an audio composition and mixing tool called OpenSebJ (http://www.sf.net/projects/opensebj) to use the SDL audio libraries (Through the SDL.Net and the taoframework wrappers) and have been successful in removing all the previous propitiatory dependencies which were supplied through Managed DirectX. 

However there is one function that I was hoping you would be willing to consider implementing in the SDL library which would greatly assist me. Could you add the ability to play a sample from a specified offset; I don't think it would matter if the offset is stored in samples or in milliseconds, it would be easy enough to work out either one based of the format of the sample. Or being able to specify a position while playback is occurring. i.e. like the Pause function on a specified location, then set any position and then resume - I'm not really sure how this works within the buffers and how much pre allocation of streams occurs but if it is possiable it would be a great addition. As having this function would allow for a lot more flexibility when mixing samples.

Thanks for the great work with this Library; it certainly makes cross-platform development many times more attainable.

Cheers,
Sebastian
Comment 1 Ryan C. Gordon 2009-02-18 23:33:49 UTC
Just to be clear: are you using SDL_sound or SDL_mixer (or just SDL by itself)?

--ryan.
Comment 2 Sebastian Gray 2009-02-27 13:42:54 UTC
I use Mixer and Sound. I don't / didn't know you could use them independently of each other and achieve the same result however I am also not sure if any of this is to do with the SDL.Net wrapper I am using.

I'll put in a sample of the code that I am using so you can see what I use, hope this makes it clearer:

// I open the mixer and define channels
Mixer.Open(44100, AudioFormat.Default, (int)SoundChannel.Stereo, 1024);
Mixer.ChannelsAllocated = channels * subChannels; 

// Then load samples in to an array of Sounds
aSound[position] = new Sound(fileName);

// Then find a free channel for the sample and play the sample
ch[position][p].Play(aSound[position], false);

// I use the instance of the sound directly to control behaviour once playing has started.
aSound[position].Stop();

Hope that clarify's what you were looking for, in effect I was hoping for a method on the Sound class like aSound.SetPosition(Position); just as I use the stop or volume methods to control playback.

Thanks, let me know if you need anything more.
Comment 3 Ryan C. Gordon 2009-10-10 22:57:03 UTC
Changing product: pretty sure this was meant to be the SDL_mixer add-on library, not the SDL_sound add-on.

--ryan.
Comment 4 Sam Lantinga 2009-10-11 00:48:16 UTC
This seems pretty useful, although you can simulate this yourself by creating a new Mix_Chunk structure that points at the data of another chunk at an offset.