Sound glitches

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: Sound glitches

#16 Post by wizzardx » Sat Mar 21, 2009 12:43 am

Hi, I seem to have found another sound glitch! (sorry :-))

If I play a 44,100 hz mp3 (background music, default volume), and then fade it out for 5 seconds, it will very often glitch during the 5-second fadeout. This is without any other sounds being played at the same time.

I think the glitches usually happen after a few seconds, so it's safe if you make sure the fade-out is less than that time (which is why my 1s fadeouts don't scratch). But this is still a problem since there are places in the chapter where I wanted to fade out the music for longer.

My test app which causes the scratches looks like this:

Code: Select all

label start:

    play music "music.mp3"
    e "Started music track 1."

    stop music fadeout 5
    e "Fading out for 5 s"
    
    jump start
Any thoughts on this?

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Sound glitches

#17 Post by PyTom » Sat Mar 21, 2009 3:39 am

Hm... Do you (or anyone) have a short example bit of code that glitches a lot? I have an idea for a fix that might be easy, but to try it I need reliably glitchy code.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: Sound glitches

#18 Post by wizzardx » Sat Mar 21, 2009 4:39 am

Here's a project which glitches almost every time for me, although I can't guarantee it will for you:

http://m0hr.com/uploads/TestSoundGlitches.7z

I converted illurock from ogg to mp3 because ogg didn't glitch.

User avatar
wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: Sound glitches

#19 Post by wizzardx » Sat Mar 21, 2009 6:08 am

Another sound problem, although not a glitching one.

Sorry if this is a very nooby question. I can't get sound queuing to work properly.

This works:

Code: Select all

    queue music ["1.mp3", "2.mp3"]
As expected, it plays 1.mp3, then 2.mp3, then repeats.

But this doesn't work:

Code: Select all

    queue sound ["1.mp3", "2.mp3"]
No sound is played at all

Also, this doesn't play any sound either:

Code: Select all

    queue sound ["1.mp3"]
But this does:

Code: Select all

    queue sound "1.mp3"
I've also tried using the $ renpy.sound.queue() function, and it doesn't seem to work at all.

What does seem to work, is this:

Code: Select all

    queue sound "1.mp3"
    e "Sound 1 started"
    queue sound "2.mp3"
    e "Sound 2 will play next"
    queue sound "3.mp3"
    e "And sound 3"
But I want to do something like this:

Code: Select all

    queue sound ["1.mp3", "2.mp3", "3.mp3"]
    e "Sound 1 started"
    e "Sound 2 will play next"
    e "And sound 3 afterwards"
However, that plays no sound at all. What is the correct method to setup the sound queue, so that the sounds actually play? I'm probably missing something obvious...

I also tried this variation:

Code: Select all

    queue sound "1.mp3"
    queue sound "2.mp3"
    queue sound "3.mp3"
    e "Sound 1 started"
    e "Sound 2 will play next"
    e "And sound 3 afterwards"
But only the 3rd sound was played. I understand this is (probably) because the "queue sound" statement clears the sound queue each time (with renpy.sound.queue's default "clear_queue" parameter value of True), but it is a bit counterintuitive.

EDIT: I have another sound question, but I don't want to double post.

Will Ren'Py support looping sound effect channels in the future?

I've figured out you can use the music channel to loop sound effects, but this means that your looping sound effect sound level will change when the user sets the music volume. Also, I want to set my music volume lower globally, but don't want that to affect the looping sound effects.

Should I use the "renpy.sound.set_queue_empty_callback()" function instead?

EDIT 2: Another update on the sound glitches.

Looks like there are also a few glitches if renpy code sets the music volume lower (at start of the game), and then later fades music (eg: for 1 s), while playing sound effects. This is with both the music and the sound effects being 44,100 hz mp3s.

Should I try converting all my sounds and music to 44,100 hz oggs? It seems like oggs might have less glitches (when it comes to fading out music). But they might also have problems with "non-integer frame endings" that PyTom mentioned earlier.

User avatar
Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

Re: Sound glitches

#20 Post by Jo'ogn » Sat Mar 21, 2009 9:03 am

wizzardx wrote:Here's a project which glitches almost every time for me, although I can't guarantee it will for you: http://m0hr.com/uploads/TestSoundGlitches.7z
It does too on my PC with (unpatched) renpy 6.9.0g.

I checked it also in WAV and ogg. Its only the mp3 that has severe random cracks and glitches during fadein/out o_0;

Didn't PyTom mention issues with a new mp3 lib he was using?


Mind: Illurock.mp3 has 24ms of silence at start and end, logically resulting in a 50ms gap during loop cycles.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

User avatar
wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: Sound glitches

#21 Post by wizzardx » Sat Mar 21, 2009 9:11 am

Another update on the sound glitches.

It looks like converting from mp3 to ogg does in fact fix the glitches I was having with fadeouts (longer fades, and fades that occur when the music has been set to a lower volume). I've converted all my files to ogg, and haven't had any glitches so far. Also, this fixes issues I was having with looping MP3s where there's an unwanted gap at the end. As a bonus, the files are a bit smaller too. I haven't checked oggs with different frequencies yet.

Do most Ren'Py games use ogg instead of mp3? That might explain why nobody else seems to have these problems.

Any idea why MP3 support is so buggy?

User avatar
yummy
Miko-Class Veteran
Posts: 733
Joined: Fri Jul 07, 2006 9:58 pm
Projects: Suna to Majo
Location: France
Contact:

Re: Sound glitches

#22 Post by yummy » Sat Mar 21, 2009 9:37 am

wizzardx wrote:Any idea why MP3 support is so buggy?
Possible reasons:
- Bad MP3 encoding/bitrate
- Hardware problem
- OS problem
- Ren'Py library that is used to read mpeg flux

I'd tend to say that it's the library because a swapping to ogg vorbis flux seems ok...
But there are too many things to consider (see above) so I can't give you a straight answer.

Watercolorheart
Eileen-Class Veteran
Posts: 1314
Joined: Mon Sep 19, 2005 2:15 am
Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
Organization: Watercolorheart Studios
IRC Nick: BCS
Tumblr: adminwatercolor
Deviantart: itsmywatercolorheart
Github: Watercolordevdev
Skype: heartnotes
Soundcloud: Watercollider
itch: watercolorheart
Location: Florida
Contact:

Re: Sound glitches

#23 Post by Watercolorheart » Sat Mar 21, 2009 3:47 pm

I switched to ogg, but it's very tinny. What can I do to help it along? I converted using Audacity from very high bit-rate mp3s. Also, when renpy.movie displayable comes up, it cancels the music! Just stops it dead and then the queue won't play again.

Please help ...

This is the relevant code. Since there are no indentations, I'm using /quote.
renpy.music.queue(["hyrulefieldnight.ogg", "midnastheme.ogg", "twilightrealm.ogg", "sacredgrove.ogg"], loop=True)
scene prettyface with dissolve
t "Her beautiful face ..."
scene black with dissolve
t "I'm dizzy with potential."
t "It doesn't need a time or a place. {w=.3} It could be a dream, for all that it mattered."
n "The time: {w} sunset."
scene sky with dissolve
n "The place: {w} the edge of the world, {w} for all that it mattered."
scene field with dissolve
n "The cast: {w} just the two of us."
show midnasit at centerupper with dissolve
n "Below, a tea-colored sinuous ribbon winds it way off a cliff to feed into Lake Hylia."
n "She's defined by the fading sunlight."
n "A dark haze has settled over the land."
show movie at Position(xpos=0, ypos=0, xanchor='left', yanchor='top')
$ renpy.movie_start_displayable('sky.mpg', (800, 600), loops=-1)
The music stops here.
n "Whether it's night or day, that barrier hangs in the sky. {w} A constant reminder."
I'm not even the same person anymore

User avatar
JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Sound glitches

#24 Post by JQuartz » Sat Mar 21, 2009 4:53 pm

BCS wrote:Also, when renpy.movie displayable comes up, it cancels the music! Just stops it dead and then the queue won't play again.
I think it had already been mentioned here:http://lemmasoft.renai.us/forums/viewto ... f=8&t=4840
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

User avatar
Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

Re: Sound glitches

#25 Post by Jo'ogn » Sat Mar 21, 2009 7:48 pm

BCS wrote:I switched to ogg, but it's very tinny. What can I do to help it along? I converted using Audacity from very high bit-rate mp3s.
What is 'tinny' supposed to mean. What's the ogg quality setting? Unless it's below Q=2, I doubt that you'll hear any difference to an mp3 - whatever bitrate it might have.
BCS wrote:Since there are no indentations, I'm using /quote.

Code: Select all

That's
  what
   the 
    "code" 
     tag is for.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

User avatar
JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Sound glitches

#26 Post by JQuartz » Sat Mar 21, 2009 8:10 pm

I think it's just because he want to bold/change font size of the code for emphasis for certain parts. It's not doable if you use code.

Code: Select all

renpy.music.queue(["hyrulefieldnight.ogg", "midnastheme.ogg", "twilightrealm.ogg", "sacredgrove.ogg"], loop=True)
[b]scene prettyface with dissolve[/b]
t "Her beautiful face ..."
scene black with dissolve
t "I'm dizzy with potential."
t "It doesn't need a time or a place. {w=.3} It could be a dream, for all that it mattered."
n "The time: {w} sunset."
scene sky with dissolve
n "The place: {w} the edge of the world, {w} for all that it mattered."
scene field with dissolve
n "The cast: {w} just the two of us."
show midnasit at centerupper with dissolve
n "Below, a tea-colored sinuous ribbon winds it way off a cliff to feed into Lake Hylia."
n "She's defined by the fading sunlight."
n "A dark haze has settled over the land."
show movie at Position(xpos=0, ypos=0, xanchor='left', yanchor='top')
$ renpy.movie_start_displayable('sky.mpg', (800, 600), loops=-1)
The music stops here.
n "Whether it's night or day, that barrier hangs in the sky. {w} A constant reminder."
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

Watercolorheart
Eileen-Class Veteran
Posts: 1314
Joined: Mon Sep 19, 2005 2:15 am
Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
Organization: Watercolorheart Studios
IRC Nick: BCS
Tumblr: adminwatercolor
Deviantart: itsmywatercolorheart
Github: Watercolordevdev
Skype: heartnotes
Soundcloud: Watercollider
itch: watercolorheart
Location: Florida
Contact:

Re: Sound glitches

#27 Post by Watercolorheart » Mon Mar 23, 2009 3:48 am

Correct. I couldn't think of a good way of highlighting the important parts in context ...
I'm not even the same person anymore

Watercolorheart
Eileen-Class Veteran
Posts: 1314
Joined: Mon Sep 19, 2005 2:15 am
Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
Organization: Watercolorheart Studios
IRC Nick: BCS
Tumblr: adminwatercolor
Deviantart: itsmywatercolorheart
Github: Watercolordevdev
Skype: heartnotes
Soundcloud: Watercollider
itch: watercolorheart
Location: Florida
Contact:

Re: Sound glitches

#28 Post by Watercolorheart » Mon Mar 23, 2009 3:49 am

Jo'ogn wrote:
BCS wrote:I switched to ogg, but it's very tinny. What can I do to help it along? I converted using Audacity from very high bit-rate mp3s.
What is 'tinny' supposed to mean. What's the ogg quality setting? Unless it's below Q=2, I doubt that you'll hear any difference to an mp3 - whatever bitrate it might have.

My Ogg quality is set to 5 from Audacity. I find that the mp3s I encode in Audacity are tinny ... by tinny, they crackle slightly and sound very poor ... I suppose I could convert them to WAV and *then* Ogg using Oggdrop, but I was afraid it would compress it/introduce even more audio artifacts ...

I just tried Oggdrop and it was a little better (curiously, the files are even smaller). Is sound playback in 6.9g any better than 6.9b?
I'm not even the same person anymore

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Sound glitches

#29 Post by Jake » Mon Mar 23, 2009 6:02 am

BCS wrote: by tinny, they crackle slightly and sound very poor ...
As I understand it, usually when people say 'tinny', they mean that the frequency range is constrained to/compressed into a very narrow set of frequencies, usually cutting out lower freqs... IIRC it happens with MP3 encoding in particular because MP3 compresses the file by cutting out frequencies it thinks are unnecessary because humans can't hear them (or can't hear them so well) anyway... and the lower the quality the more aggressive it is at cutting those freqs out.


As it goes, though, the WAV format generally isn't compressed at all, so there shouldn't be any quality losses when saving stuff to WAV
Server error: user 'Jake' not found

User avatar
Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

Re: Sound glitches

#30 Post by Jo'ogn » Mon Mar 23, 2009 9:16 am

BCS wrote:My Ogg quality is set to 5 from Audacity.
160kbit/s are more than enough. Did you have any EQs or other plug-ins in your edit chain? I don't use Audacity (1.3.3.) but made a quick test just now and it converted my audio file from 44,1 to 48kHz, because this is my setting in Audacity... Otherwise the sound is absolutely fine.
Jake wrote:As I understand it, usually when people say 'tinny', they mean that the frequency range is constrained to/compressed into a very narrow set of frequencies, usually cutting out lower freqs...
Yes, that's how I would understand it too.

However neither mp3, nor OGG remove low frequencies from the spectrum. Most certainly not to and above any bitrate that is considered 'near CD' quality as 128kbit/s for mp3 and 80-96kbit/s in the case of OGG Voribis.
Jake wrote: IIRC it happens with MP3 encoding in particular because MP3 compresses the file by cutting out frequencies it thinks are unnecessary because humans can't hear them (or can't hear them so well) anyway... and the lower the quality the more aggressive it is at cutting those freqs out.
Yes, but this mainly applies to high frequencies. Including lowering the sample rate the lower the bitrate, in case you go below 128kbit/s with mp3.
BCS wrote:by tinny, they crackle slightly and sound very poor
Crackling should not happen unless you add gain to the signal causing it to clip. What you describe shouldn't be a problem with the OGG Vorbis format. Which in my experience is superior to mp3. Even if you re-encode - which you likely will not do often enough to create audible artefacts in that process. If they weren't already there due to mp3 encoding to begin with.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Hojoo