Discuss Scratch

VideogamerMale
Scratcher
8 posts

How do you pause and resume a sound?

Is it possible to pause a sound file and then resume it where it ended like a YouTube video?

Imagine something like this:

play sound [((MY MP3 FILE HERE) + (the specific second I want it to play at)) v] until done
deck26
Scratcher
1000+ posts

How do you pause and resume a sound?

Not possible. Best you can do is split the sound into smaller bits to get more control.
VideogamerMale
Scratcher
8 posts

How do you pause and resume a sound?

deck26 wrote:

Not possible. Best you can do is split the sound into smaller bits to get more control.

Okay then. Does the pitch block cheat by speeding up the sound instead of actually pitching it up? Then I could create a system that fast fowards to where you previously left off.
change (pitch v) effect by (10)

Last edited by VideogamerMale (Nov. 20, 2019 12:59:18)

deck26
Scratcher
1000+ posts

How do you pause and resume a sound?

VideogamerMale wrote:

deck26 wrote:

Not possible. Best you can do is split the sound into smaller bits to get more control.

Okay then. Does the pitch block cheat by speeding up the sound instead of actually pitching it up? Then I could create a system that fast fowards to where you previously left off.
change (pitch v) effect by (10)
I don't use sound much so can't answer that but suspect it would take a bit of managing.

Last edited by deck26 (Nov. 20, 2019 13:29:50)

Monna-Uka
Scratcher
1000+ posts

How do you pause and resume a sound?

VideogamerMale wrote:

deck26 wrote:

Not possible. Best you can do is split the sound into smaller bits to get more control.

Okay then. Does the pitch block cheat by speeding up the sound instead of actually pitching it up? Then I could create a system that fast fowards to where you previously left off.
change (pitch v) effect by (10)
[/quote]
With that there will be a chance to skip sounds. I haven't tried doing it, but I think you need to calculate a lot. :)
Wainggan
Scratcher
500+ posts

How do you pause and resume a sound?

I just tested this:

set [pitch v] effect to (-999999999) :: sounds

This almost works, but the song would still be playing, just veeeerrry ssslooooowwly.
colinmacc
Scratcher
1000+ posts

How do you pause and resume a sound?

You could try this suggestion someone made a few months ago?

https://scratch.mit.edu/discuss/topic/74670/?page=4#post-3602802

I haven’t tried it myself, so would be interested in seeing if it works..
VideogamerMale
Scratcher
8 posts

How do you pause and resume a sound?

colinmacc wrote:

You could try this suggestion someone made a few months ago?

https://scratch.mit.edu/discuss/topic/74670/?page=4#post-3602802

I haven’t tried it myself, so would be interested in seeing if it works..

Ay thanks buddy

Last edited by VideogamerMale (Nov. 20, 2019 20:44:58)

_THEBOSS_
Scratcher
57 posts

How do you pause and resume a sound?

HEY someone here? i need help with creating a mute button
deck26
Scratcher
1000+ posts

How do you pause and resume a sound?

_THEBOSS_ wrote:

HEY someone here? i need help with creating a mute button
Please create your own topic.

Just create a button and set volume to 0 when it is clicked on.
_THEBOSS_
Scratcher
57 posts

How do you pause and resume a sound?

THANKS!!!
qucchia
Scratcher
100+ posts

How do you pause and resume a sound?

Yes, it is possible, however, it may take some time for it to “load” (eg wait for the sound to reach the desired second)

define Play Sound [sound] starting from second [start second]
set volume to (0) %
set [pitch v] effect to (360)
play sound (sound)
wait ((start second)/(8)) secs
set [pitch v] effect to (0)
set volume to (100) %

Why set the pitch to 360? The maximum pitch effect is 360. Any higher values set it to 360 anyway.
Why wait (start second/8) seconds? When the pitch effect is set to 360, the sound is played eight times as fast. For this reason, the program should wait an eighth of the time it starts.

If you have any questions feel free to ask me! I've followed this topic so I'll get notified if anyone does.
Boomer001
Scratcher
1000+ posts

How do you pause and resume a sound?

For pausing a sound:
define pause
set volume to (0)%
set [pitch v] effect to ((-1) / (0)) :: sound // sets pitch to -Infinity
For resuming a sound:
define resume
set volume to (100)%
set [pitch v] effect to (0) :: sound
It's not perfect, but still useful.

Last edited by Boomer001 (Nov. 21, 2019 18:25:46)

Wainggan
Scratcher
500+ posts

How do you pause and resume a sound?

deck26
Scratcher
1000+ posts

How do you pause and resume a sound?

Boomer001 wrote:

For pausing a sound:
define pause
set volume to (0)%
set [pitch v] effect to ((-1) / (0)) :: sound // sets pitch to -Infinity
For resuming a sound:
define resume
set volume to (100)%
set [pitch v] effect to (0) :: sound
It's not perfect, but still useful.
Can't see how that guarantess the sound restarting at the right place - it'll be completely random, won't it?

Last edited by deck26 (Nov. 21, 2019 19:20:36)

Wainggan
Scratcher
500+ posts

How do you pause and resume a sound?

deck26 wrote:

Boomer001 wrote:

For pausing a sound:
define pause
set volume to (0)%
set [pitch v] effect to ((-1) / (0)) :: sound // sets pitch to -Infinity
For resuming a sound:
define resume
set volume to (100)%
set [pitch v] effect to (0) :: sound
It's not perfect, but still useful.
Can't see how that guarantess the sound restarting at the right place - it'll be completely random, won't it?
That is true. I used this method, and pause a song, then I wait for 7 seconds, but then the song wasn't in the same place as when I paused it.
qucchia
Scratcher
100+ posts

How do you pause and resume a sound?

Boomer001 wrote:

For pausing a sound:
define pause
set volume to (0)%
set [pitch v] effect to ((-1) / (0)) :: sound // sets pitch to -Infinity
For resuming a sound:
define resume
set volume to (100)%
set [pitch v] effect to (0) :: sound
It's not perfect, but still useful.
I believe my method works better
cdjLessines
Teacher
16 posts

How do you pause and resume a sound?

Boomer001 wrote:

For pausing a sound:
define pause
set volume to (0)%
set [pitch v] effect to ((-1) / (0)) :: sound // sets pitch to -Infinity
For resuming a sound:
define resume
set volume to (100)%
set [pitch v] effect to (0) :: sound
It's not perfect, but still useful.

Excellent, Boomer001. Your trick for pausing a sound and unpausing it, works pretty well.
Genious idea to use -Infinity.
Setting volume to 0 or 100, is not even necessary.

DP

Last edited by cdjLessines (Nov. 21, 2019 22:56:18)

cdjLessines
Teacher
16 posts

How do you pause and resume a sound?

cdjLessines wrote:

Boomer001 wrote:

For pausing a sound:
define pause
set volume to (0)%
set [pitch v] effect to ((-1) / (0)) :: sound // sets pitch to -Infinity
For resuming a sound:
define resume
set volume to (100)%
set [pitch v] effect to (0) :: sound
It's not perfect, but still useful.

Excellent, Boomer001. Your trick for pausing a sound and unpausing it, works pretty well.
Genious idea to use -Infinity.
Setting volume to 0 or 100, is not even necessary.

DP

Btw, test avl here.
aw3s0me8
Scratcher
24 posts

How do you pause and resume a sound?

Wainggan wrote:

I just tested this:

set [pitch v] effect to (-999999999) :: sounds

This almost works, but the song would still be playing, just veeeerrry ssslooooowwly.
Actually, you don't need to do -9999999999. you can do this:
set pitch effect to ( ([ log] of (leave this space blank)))

Powered by DjangoBB