This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-11-22 11:19:12

welshrearbit
Scratcher
Registered: 2007-10-18
Posts: 1

How to use mp3's in scratch

Is it possible to use mp3s as a continuous background track in scratch?

Offline

 

#2 2007-11-22 11:45:34

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: How to use mp3's in scratch

Hi welshrearbit,

you can import mp3s as sounds in to Scratch, and then play them in a continous loop like this:
[blocks]
<when green flag clicked>
<forever>
<play sound[ mp3 ]and wait>
<end>[/blocks]

It will automatically be 'background' music, because in Scratch you can have your project do several things simultaneously, using 'event hats'.

For example you can have an additional script (even in the same sprite) that also starts when the green flag is pressed, something like this:
[blocks]
<when green flag clicked>
<forever>
make the sprite or the stage do something else
<end>[/blocks]

Since both of these scripts will run in parallel, your mp3 music-loop will behave just like background music.

Hope that helps....

P.S. I moved this post to ehe "All About Scratch" forum section


Jens Mönig

Offline

 

#3 2007-11-22 11:55:22

bobbysq
Scratcher
Registered: 2007-06-26
Posts: 100+

Re: How to use mp3's in scratch


originals forever!

Offline

 

#4 2007-11-22 12:08:53

bobbysq
Scratcher
Registered: 2007-06-26
Posts: 100+

Re: How to use mp3's in scratch

Jens wrote:

Hi welshrearbit,

you can import mp3s as sounds in to Scratch, and then play them in a continous loop like this:
[blocks]
<when green flag clicked>
<forever>
<play sound[ mp3 ]and wait>
<end>[/blocks]

It will automatically be 'background' music, because in Scratch you can have your project do several things simultaneously, using 'event hats'.

For example you can have an additional script (even in the same sprite) that also starts when the green flag is pressed, something like this:
[blocks]
<when green flag clicked>
<forever>
make the sprite or the stage do something else
<end>[/blocks]

Since both of these scripts will run in parallel, your mp3 music-loop will behave just like background music.

Hope that helps....

P.S. I moved this post to the "All About Scratch" forum section

i did not c your post,so i made the other post. sad  sad  sad  sad  sad  sad


originals forever!

Offline

 

#5 2007-11-24 16:54:48

Draakx
Scratcher
Registered: 2007-08-24
Posts: 11

Re: How to use mp3's in scratch

hey, i get the background music, but how would i program a sprite to turn it on/off when i click it?

Last edited by Draakx (2007-11-24 16:55:32)

Offline

 

#6 2007-11-24 18:23:07

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: How to use mp3's in scratch

two sprites: "on" and "off"

when on clicked
     forever
        play sound <> and wait



when off clicked
    stop all sounds

Offline

 

#7 2007-12-01 12:13:08

mijet97
Scratcher
Registered: 2007-05-27
Posts: 24

Re: How to use mp3's in scratch

um... when i tried importing the mp3, it said "unrecognized audio file format". HELP

Offline

 

#8 2007-12-02 20:13:13

andresmh
Scratch Team at MIT
Registered: 2007-03-05
Posts: 1000+

Re: How to use mp3's in scratch

It is possible that the mp3 file is not encoded in the standard MPEG-3 format. Try  using Audacity (free download) to convert your file to a real mp3 file perhaps?


Andres Monroy-Hernandez | Scratch Team at the MIT Media Lab
on identi.ca and  twitter

Offline

 

#9 2007-12-03 20:52:18

Draakx
Scratcher
Registered: 2007-08-24
Posts: 11

Re: How to use mp3's in scratch

kevin_karplus wrote:

two sprites: "on" and "off"

when on clicked
     forever
        play sound <> and wait



when off clicked
    stop all sounds

the problem with this is that once the music would have normally finished it plays again

Offline

 

#10 2007-12-04 01:44:36

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: How to use mp3's in scratch

Then just play the sound without the forever-loop. You can still turn it off within another script.


Jens Mönig

Offline

 

#11 2007-12-04 18:45:15

Draakx
Scratcher
Registered: 2007-08-24
Posts: 11

Re: How to use mp3's in scratch

but then it wont loop when it finishes, which is the whole point of background music

Offline

 

#12 2007-12-05 02:35:52

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: How to use mp3's in scratch

Ah, now I think I understand. Why don't you try using a flag variable:

one single sprite "music"
"music" variable: "on"

[blocks]
<when green flag clicked>
<set{ on }to( 1
<forever if><( <{ on }> <=> 1 )>
<play sound[ mp3 ]and wait>
<end>

<when[ music ]clicked>
<if><( <{ on }> <=> 1 )>
<set{ on }to( 0
<stop all sounds>
<else>
<set{ on }to( 1
<end>
[/blocks]

(What am I doing wrong here, these forum blocks look awful, maybe I should revert to text mode, like Kevin...)


Jens Mönig

Offline

 

#13 2007-12-05 09:08:32

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: How to use mp3's in scratch

I've found the blocks mode on the website to be pretty useless---the blocks are not carefully enough done to fit together well and look right, so it is probably clearer to type text.

Thanks, Jens, for correcting my suggestion.  Draakx was right in pointing out that what I had first proposed would keep on restarting the music.

Perhaps I'm unusual, but I find repeat loops of music extremely irritating, so I never put them in any of my projects.

Offline

 

#14 2008-01-01 11:18:31

SmeAnd
Scratcher
Registered: 2007-12-10
Posts: 17

Re: How to use mp3's in scratch

mijet97 wrote:

um... when i tried importing the mp3, it said "unrecognized audio file format". HELP

Same problem here, Scratch ver. 1.2.1. And even a major crash trying various mp3. From Audacity and Magix Music Maker 14

from dumpfile....
---------------------------------------
Exception code: C0000005
Exception addr: 67E04016
Access violation (read access) at 00000014
EAX:00000000    EBX:00000000    ECX:00000001    EDX:00000000
ESI:108DC5B8    EDI:101617C0    EBP:67E01378    ESP:0006FB84
EIP:67E04016    EFL:00010202
FP Control: FFFF027F
FP Status:  FFFF0120
FP Tag:     FFFFFFFF
VM Version: Squeak 3.4.3 / Tea 1.9 VM (release) from Apr  8 2003
Compiler: gcc 2.95.2 19991024 (release)

Current byte code: 243
Primitive index: 117

Loaded plugins:
    Mpeg3Plugin 27 October 2000 (e)
------------------------------------------------------------------------------

Plugin old? Or what...

//Anders


Anders
Smedjebacken, in the middle of nowhere... Sweden

Offline

 

#15 2008-01-01 13:04:55

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: How to use mp3's in scratch

Jens wrote:

Ah, now I think I understand. Why don't you try using a flag variable:

one single sprite "music"
"music" variable: "on"

[blocks]
<when green flag clicked>
<set{ on }to( 1
<forever if><( <{ on }> <=> 1 )>
<play sound[ mp3 ]and wait>
<end>

<when[ music ]clicked>
<if><( <{ on }> <=> 1 )>
<set{ on }to( 0
<stop all sounds>
<else>
<set{ on }to( 1
<end>
[/blocks]

(What am I doing wrong here, these forum blocks look awful, maybe I should revert to text mode, like Kevin...)

The exact same script I had in my Weather Simulator project! ^_^


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#16 2008-01-02 10:47:59

johnm
Scratcher
Registered: 2007-03-08
Posts: 100+

Re: How to use mp3's in scratch

Hi, SmeAnd.

It sounds like your MP3 files are either corrupted or in a format that Scratch cannot read. The MP3 code is based on some open-source code that is not entirely robust in the face of MP3 file formats that it doesn't like.

Your sound software may be creating mp4 formatted files rather than true mp3 files. You may be able to do a "save as" or set the preferences to export the sounds in a format that Scratch can read. If you can save or convert your files as uncompressed WAV files, Scratch should be able to import them. (Note: There are no space savings for importing MP3 files as opposed to WAV files. The sound gets stored internally in the same format no matter what the original sound file format was.)

Good luck!

  -- John

Last edited by johnm (2008-01-02 10:51:52)

Offline

 

#17 2010-01-19 09:36:36

tomi_nko
Scratcher
Registered: 2009-04-10
Posts: 5

Re: How to use mp3's in scratch

If you need a converter here it is
http://www.box.net/shared/vuqqyp9ze7

IT IS FREE AND MADE BY ME, YOU WILL NO LONGER RECEIVE ERRORS


http://img42.imageshack.us/img42/9514/myownsignature.jpg

Offline

 

#18 2010-01-19 09:47:33

BWOG
Scratcher
Registered: 2008-09-19
Posts: 1000+

Re: How to use mp3's in scratch

tomi_nko wrote:

If you need a converter here it is
http://www.box.net/shared/vuqqyp9ze7

IT IS FREE AND MADE BY ME, YOU WILL NO LONGER RECEIVE ERRORS

Please don't bump old threads.

Offline

 

Board footer