Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

sampler offset option

Dear experts,

Is there a way to provide an offset to the sampler object, using inline code?

Many thanks in advance,

Jan-Bernard

Comments

  • edited February 22

    Hi Jan-Bernard,

    What do you mean exactly with an offset? Do you mean that you want to start playback only after a certain delay? If so, then you might want to look at coroutines which allow you to specify timing in a more flexible (and less sequential) way than sequence items:

    Or is that not what you mean?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Hi Sebastiaan,

    Sorry, that is not what we want. With offset, we mean : start playing the track at a certain moment of the track (start at 1:01 for instance...)

    Thanks, JB

  • Hi JB,

    Ah, I see. No, the pygame mixer doesn't allow you to seek through the stream. There's a few options.

    • The easy option is of course to create separate audio files, each with a different offset. If you require only a few offsets, that's what I would do.
    • Use the wave module to open the audio files (in .wav format), and write only the part from a certain moment onward to a new wave file, which you then use in the sampler.
    • Use a more advanced library such as pyaudio that does allow you to seek through files.

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.