glutanimate / MoodyRain

Generate custom ambient soundscapes on Linux
GNU General Public License v3.0
43 stars 4 forks source link

use oggdec and sox for lower memory consumption #3

Closed kosivantsov closed 8 years ago

kosivantsov commented 8 years ago

Every instance of mpv by itself uses over 30MB RAM (mpv - with empty input), which isn't much by modern standards, but can easily sum up to a considerable amount for a more or less sound-rich soundscape. On the other hand, sox (play) can be used for gapless and endless playback with a defined volume with much lower memory consumption. Sox's play only uses over 4MB per instance (play - with empty input). Something like this can be used: oggdec $FILE -o - | while play -v $VOLUME -; do : ; done

glutanimate commented 8 years ago

Thanks for the input on both of these issues. I really appreciate it. I'll have to take a closer look at this when I have more time, but your suggestions definitely make sense. I'll try to implement them as soon as I find the opportunity.

glutanimate commented 8 years ago

I just looked into this: The main issue with all the audio players I've tried outside of mpv is that they don't seem to be able to repeat the streams seamlessly. As this is very important for the ambience to sound good, I will have to stay with mpv for now.

kosivantsov commented 8 years ago

Right. In the example I gave (which was wrong anyway, sorry, while should have been before the whole clause, not before play), the problem is that play respawns after each playback, thus creating the gap. It turns out that play can play oggs directly, without oggdec'ing them first. To get the gapless playback, one can use play $FILE repeat 1999999999, which will play the file 1999999999 times (for 1 sec file that's over 63 years of playback). Volume range for play is from 0.0 upward, with 1.0 being 100%

glutanimate commented 8 years ago

I've just given play a try and it's working perfectly. It's just as seamless as mpv while consuming far less memory. I'll be updating the repo soon with a new release of the scipt that drops mpv in favor of sox.

Thanks again for pointing me to this alternative. It's a major enhancement to MoodyRain, definitively.