Re: [pygame] Some way to pickle or otherwise save a pygame.mixer.Sound object?

2018-06-07 Thread Alec Bennett
On Thu, Jun 7, 2018 at 4:21 AM, Greg Ewing 
wrote:

> Alec Bennett wrote:
>
>> 16 bit wav files. 1411 kbps. About 5 megs each but one is very long (a 13
>> minute medley of all of them, 133 megs).
>>
>
> Okay, I didn't realise they were that big -- I was thinking
> short horn sounds, not substantial pieces of music!


It's a "musical horn" in the ice cream truck sense. Plays this for example:

https://www.youtube.com/watch?v=zzodaDCD798

Uses this keypad with a Raspberry Pi:

https://learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-devices/read-4x4-matrix-keypad



> You bring up a good point, I can certainly make them mono.
>>
>
> Also maybe 8 bit -- a horn probably doesn't need terrifically
> high sound fidelity.


True, but it does seem a shame to have to degrade the sound quality. I'm
calling the project "music box" since I'd like to be able to use it as a
general music clip trigger, like the classic Dr. Sample:

https://www.amazon.com/BOSS-SAMPLE-SP-303-PHRASE-SAMPLER/dp/B0002J1NE6



>
>
> But surely there must be some way to save a preloaded state?
>>
>
> That's over 200MB altogether, which may be why it takes so
> long. Have you tried simply reading all the files to see
> how long it takes?
>

Very good point.


>
> If that takes just as long, then reading a preloaded state
> isn't going to gain you anything -- you've still got over
> 200MB of data to read in.
>
> You could also try using a compressed format such as
> mp3 or ogg/vorbis to see if it loads any faster.
>

I tried MP3, but unfortunately the pygame.mixer.Sound doesn't support it.
The pygame.mixer.music does support MP3, but it doesn't support polyphony.

I wonder if it would be possible to modify pygame.mixer.Sound so it
supports MP3?

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?


> Another thought -- instead of loading the medley as a
> separate file, could you assemble it on the fly from
> parts of the others?
>

Yup, should definitely do that. But again, part of me is thinking about
this as larger than just my project. It seems a shame that playing a 13
minute sound file with polyphony should take so long to preload. I get that
in games that's not usually a factor but Pygame is useful for so much other
than games.


>
> Another other thought -- instead of storing entire tunes
> as sound files, just use samples of the horn sounds and
> write a sequencer to play the tunes with them.


Here's a playlist of the old ice cream truck jingles we're playing. This is
for a cart that sells oysters by the way.

https://www.youtube.com/watch?v=zzodaDCD798=PLxDFYmPWdF3DqMkFxwnKPr22r_15-GWne=2s=2


>
>
> --
> Greg
>


Re: [pygame] Some way to pickle or otherwise save a pygame.mixer.Sound object?

2018-06-07 Thread Greg Ewing

Alec Bennett wrote:
16 bit wav files. 1411 kbps. About 5 megs each but one is very long (a 
13 minute medley of all of them, 133 megs).


Okay, I didn't realise they were that big -- I was thinking
short horn sounds, not substantial pieces of music!


You bring up a good point, I can certainly make them mono.


Also maybe 8 bit -- a horn probably doesn't need terrifically
high sound fidelity.


But surely there must be some way to save a preloaded state?


That's over 200MB altogether, which may be why it takes so
long. Have you tried simply reading all the files to see
how long it takes?

If that takes just as long, then reading a preloaded state
isn't going to gain you anything -- you've still got over
200MB of data to read in.

You could also try using a compressed format such as
mp3 or ogg/vorbis to see if it loads any faster.

Another thought -- instead of loading the medley as a
separate file, could you assemble it on the fly from
parts of the others?

Another other thought -- instead of storing entire tunes
as sound files, just use samples of the horn sounds and
write a sequencer to play the tunes with them.

--
Greg


Re: [pygame] Some way to pickle or otherwise save a pygame.mixer.Sound object?

2018-06-07 Thread Alec Bennett
16 bit wav files. 1411 kbps. About 5 megs each but one is very long (a 13
minute medley of all of them, 133 megs).

You bring up a good point, I can certainly make them mono.

But surely there must be some way to save a preloaded state?



On Wed, Jun 6, 2018 at 11:32 PM, Greg Ewing 
wrote:

> Alec Bennett wrote:
>
>> since it needs to load each of the 20 sounds on startup it takes about 30
>> seconds to load. I'm running it on a Raspberry Pi, which doesn't help of
>> course.
>>
>
> How big are the sound files? Unless they're really enormous,
> that sounds excessive, even for an R. Pi.
>
> What format are they in? If they're in some kimd of compressed
> format, try saving them as .wav files. That might be faster
> to load even though the file is bigger.
>
> --
> Greg
>


Re: [pygame] Some way to pickle or otherwise save a pygame.mixer.Sound object?

2018-06-07 Thread Greg Ewing

Alec Bennett wrote:
since it needs to load each of the 20 sounds on startup 
it takes about 30 seconds to load. I'm running it on a Raspberry Pi, 
which doesn't help of course.


How big are the sound files? Unless they're really enormous,
that sounds excessive, even for an R. Pi.

What format are they in? If they're in some kimd of compressed
format, try saving them as .wav files. That might be faster
to load even though the file is bigger.

--
Greg