On Thu, Jun 7, 2018 at 4:21 AM, Greg Ewing <greg.ew...@canterbury.ac.nz> 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&list=PLxDFYmPWdF3DqMkFxwnKPr22r_15-GWne&t=2s&index=2 > > > -- > Greg >