2021-04-06 12:56:53

Hi.
I have a question, how can I do stop the sound if I play it  as a loop.
for examble i have play music in my game, and i made option for stop that music, how i can tell to python if press on that option music will stop, also there any way to control the music volume?
Greetings.

2021-04-06 14:06:36

sound.stop()

best regards
never give up on what ever you are doing.

2021-04-06 14:57:46

If you need good sound support, I recommend using literally anything else. Lucia's sound handling is so broken that it's the main reason I avoid it. But to actually answer your question, it depends if you're using a lucia.audio_backend.sound I think it's called, haven't used it in ages, or a sound pool object. For a standard sound object, sound.stop(), and I think sound.set_volume(value). For a sound pool p.destroy(sound_id).

2021-04-06 16:03:39

if you are going to use something other than lucias sound pool i'd recommend pygame.mixer, it supports wav,mp3 and ogg and I really like the control it gives you over everything while stil keeping it easy to learn and use

Unpleasant, something unusual, the barrier between dreams and reality has been broken, and the most frightening of dreams have leaked to the realm of reality, is it just another nightmare?
my github!

Thumbs up

2021-04-07 08:51:47

but pygame's mixer does not allow you to pan sounds

best regards
never give up on what ever you are doing.

2021-04-07 09:07:02

it does allow you to pan sounds
from pygame import mixer
mixer.init()
sound=mixer.Sound()
channel=mixer.find_channel()
channel.set_volume(0.2,0.9)#first number is left volume second number is right volume
channel.play(sound)#plays the sound and resets channel volume to defults so make sure to set_volume again if you want to pan another sound

Unpleasant, something unusual, the barrier between dreams and reality has been broken, and the most frightening of dreams have leaked to the realm of reality, is it just another nightmare?
my github!

Thumbs up

2021-04-07 10:41:18

Ok, then this is interesting... i would like to write some kind of rapper for this at some point...

best regards
never give up on what ever you are doing.

2021-04-07 10:43:08

@7 this will be pritty cool, I can contribute or colabirate with you if you wish, also just a note, pygame.mixer only support playing wav, mp3 and ogg

Unpleasant, something unusual, the barrier between dreams and reality has been broken, and the most frightening of dreams have leaked to the realm of reality, is it just another nightmare?
my github!

Thumbs up

2021-04-07 16:52:14

Yeah, just need to figure out some kind of formulae for the panning to make it work with units of 1...

best regards
never give up on what ever you are doing.

2021-04-07 19:30:01

@9 I am also stuck at that, I am very dumb at math, I can ask my syster but I just can't get the idea into her so she could understand

Unpleasant, something unusual, the barrier between dreams and reality has been broken, and the most frightening of dreams have leaked to the realm of reality, is it just another nightmare?
my github!

Thumbs up

2021-04-07 20:14:53

Not sure how SDL_Mixer's panning works, but I'm assuming 0.9 would pan it very far to the right, so maybe something like just remove the period, like 1.0 would become 10, 0.1 would become 01, etc. I could be completely off though, this kind of stuff is not where I shine, at all.

2021-04-07 20:49:25

yeah so, if you don't need ogg there's Synthizer (and 0.9 will work with ogg, with Mac coming shortly after).  But assuming that you will in fact be going pygame, then the formula you want is (off the top of my head, might be slightly wrong):

l = math.cos(math.pi * pan / 2)
r = math.sin(math.pi * pan / 2)

Where pan ranges from 0.0 to 1.0.

Why this works is because power is the square of gain, you want constant power across the field because humans perceive volume as power and not gain, and sin(x)^2+cos(x)^2 = 1 for all x.  Alternatively, it's magic secret math sauce, if you prefer.

My Blog
Twitter: @camlorn38

2021-04-07 21:10:14

Ok, thanx for the formulae, will try it out.
But if Ogg support is coming with synthizer, no probs at all, then i think i'd just stick to it.

best regards
never give up on what ever you are doing.

2021-04-07 21:28:48

You'll have to distribute libsndfile.dll alongside it because I can't integrate that due to licensing compatibility and have to load it on your request, but yes.

But I really, really don't get why ogg is such a deal-breaker.  I really don't.  Mostly I'm doing it at this point because I'm sick of hearing about it, and will never use it myself.

My Blog
Twitter: @camlorn38

2021-04-07 21:36:09

I mean... Ogg would be nice, but like, it shouldn't be a deal breaker. That's yet another BGTIsm, I suppose. Why would you need libsndfile though? Could you use dr_vorbis? I have no idea how stable it is, but still, I would think it would be enough to work.

2021-04-07 21:53:51

@14
you don't have to listen to people who keep requesting unneeded features. If someone says "where's ogg support?" you could say something along the lines of "as stated many times before, ogg support is a low priority, further issues regarding this feature request will be ignored." Your the dev and its your choice if you would like to work on it or not. If it were me I'd say "unless your coding it, stop asking." As you may have realized from your time in the community, blind people are demanding, you shouldn't give in based on how many people ask for something that doesn't matter

aliquando solem e caelo capiam, et libere volabit anima mea

Thumbs up

2021-04-07 22:29:22

yeah, but honestly it's going to take me 2 hours once I'm past a certain point and this is the number 2 feature request I get, for some reason.  One of the big focuses of 0.9 is supporting custom streams and similar things like that, which will finalize the internals of those subsystems.  Libsndfile also offers like 20 other formats anyway, so it is at least a way to get a lot of features.

I'm not touching dr_vorbis because by his own admission it's really alpha quality.  I'm not touching stb_vorbis because it's the kind of broken that is "this does not work at all, here is a pr" and then said pr doesn't get merged for months.  I'm not touching libvorbis because it's BSD and if I'm going to support dynamically loading a dll, I'm going to support loading the one that gives you a ton of formats.  As I've put to many people, anything that makes it into Synthizer is something I'm promising to maintain, so anything low quality is off the table; and not requiring binary attribution is important to me, so anything BSD/MIT is off the table unless I dynamically load it on your request.  I might investigate ffmpeg dlls instead, not sure, but if those worked for what I need they'd probably lift a couple restrictions that libsndfile has while offering even more formats.

My guess is that a lot of people have committed the cardinal sin of not keeping their lossless originals and are now stuck on ogg for that reason.

My Blog
Twitter: @camlorn38

2021-04-08 00:22:41

Ogg is just useless, IT laggs the windows file explorer like shit, I used to like it yes, But after i used mp3, I realised it's better and will save me a lot of stuff and yay, No stupid explorer lagg because um, Microsoft weirdness?

no matter what programing language you use... You are the one to make it stronger.
regards
follow me at twitter

2021-04-08 00:42:44

Ogg and MP3 are a toss-up.  Ogg is better on some benchmarks but MP3 works everywhere.  But I'm not producing a library for general purpose media players, so as far as I'm concerned "these 3 formats are what we support" should have been fine.  But apparently not.

My Blog
Twitter: @camlorn38

2021-04-08 09:17:29

Nah, i'm also completely fine with mp3 and wav, never use flaq... Instead, I wouldn't want to be able to make use of ogg formats, since it also lags my windows explorer. I don't know why

best regards
never give up on what ever you are doing.