Just to be clear, you need to play two different multi-minute sounds at
once?

Because your example has one 13-minute track and one 3-second track. If
those are the sounds you need to play at the same time, why don't you just
preload the 3-second one into a pygame.mixer.Sound object and play it
whenever you need it, and play the 13-minute one with pygame.mixer.music?

On Fri, Jun 8, 2018 at 7:48 PM Alec Bennett <wrybr...@gmail.com> wrote:

> I see that pygame.mixer.Sound supports OGG, I guess I should try that.
>> I've never used OGG before, and I wonder if it supports OGG if MP3 would be
>> an easy addition?
>>
>
> Well so much for using OGG (and probably MP3) to speed up preloading. With
> my 13 minute mono soundfiles, it takes 7.3 seconds to preload the wav file
> (44.1hz, 16 bit, mono) and 43.6 seconds to preload the OGG file... I have a
> feeling it's uncompressing it during preload.
>
>>
> My project needs polyphony, but really only the ability to play two sounds
> at once. I'm currently using this method because it supports that:
>
>>
> channel = 1 # or 2
>
>> sound_obj = pygame.mixer.Sound("whatever.wav") # long preload at this step
>
>> channel = pygame.mixer.Channel(channel)
>
>> channel.play(sound_obj)
>
>>
> This method of playing MP3 works beautifully without preloading, but can
> only play one sound at a time:
>
>>
> pygame.mixer.init()
>
>> pygame.mixer.music.load("whatever.mp3")
>
>> pygame.mixer.music.play()
>
>> pygame.event.wait()
>
>>
> I don't imagine anyone knows of a way to play two sound files
> simultaneously using  pygame.mixer.music? Or some other solution in Python
> under Linux that would do it reliably? I suppose I could slave two
> instances of mplayer, but I'd of course prefer to not be forking out
> processes.
>
> If anyone's curious about the files I'm trying to load, I posted some test
> files here:
>
> sinkingsensation.com/dropbox/icecream.zip
>
>
>
>
> On Thu, Jun 7, 2018 at 2:30 PM, Alec Bennett <wrybr...@gmail.com> wrote:
>
>>
>>
>> On Thu, Jun 7, 2018 at 7:59 AM, Christopher Night <cosmologi...@gmail.com
>> > wrote:
>>
>>> I recommend saving the sound as a raw buffer. First in a separate script:
>>>
>>> sound = pygame.mixer.Sound("music1.wav")
>>> open("music1.buf", "wb").write(sound.get_raw())
>>>
>>> Then in your game:
>>> sound = pygame.mixer.Sound(buffer=open("music1.buf", "rb").read())
>>>
>>> I found about 4x speedup of reading a large file on my desktop using
>>> this method. That may or may not be enough for you, especially if you
>>> combine with other tips in this thread.
>>>
>>
>>
>> Very interesting. Will try this when I'm working on this tonight.
>>
>>
>>
>>
>>
>

Reply via email to