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

#1 2012-02-04 15:08:21

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Don't convert sound to mono?

Hey scratch modders  tongue

Just a quick question: does anyone of you know of a way to prevent Scratch from converting audio tracks to mono when importing?


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#2 2012-02-04 15:16:10

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Don't convert sound to mono?

I think what you're looking for is in Scratch-Objects > SoundMedia > accessing > loadFile:.

Offline

 

#3 2012-02-04 17:47:18

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Don't convert sound to mono?

Nice, I managed to cut out the converting-to-mono part which is awesome. But maybe it'd be good to have a prompt asking whether I want to convert it or not. (just one of those context menus maybe?) How would I do that?


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#4 2012-02-04 18:06:27

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Don't convert sound to mono?

JSO wrote:

Nice, I managed to cut out the converting-to-mono part which is awesome. But maybe it'd be good to have a prompt asking whether I want to convert it or not. (just one of those context menus maybe?) How would I do that?

To prompt the user before converting:

Code:

snd ifNotNil: [
            snd isStereo ifTrue: [
            t1 _ DialogBoxMorph ask: 'Convert sound to mono?'.
            t1 ifTrue:["merge stereo to mono"
                bar value: 'Converting ', sndName, 'to mono...'.
                mergedBuf _ snd sounds first samples.
                mergedBuf mixIn: snd sounds second samples.
                snd _ SampledSound
                    samples: mergedBuf
                    samplingRate: snd sounds first originalSamplingRate]].

and at the top:

Code:

| snd errorString sndName mergedBuf t1 |

Last edited by jvvg (2012-02-04 18:24:27)


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#5 2012-02-04 19:02:44

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Don't convert sound to mono?

Thanks so much jvvg! It worked  smile

I was experimenting in the official 1.4 image so the arguments were named differently but everything went well  smile

Edit: hmm; I added dialogboxes for both the downsampling and the mono conversion, and it seems to skip the conversion steps. (It doesn't show 'converting to mono...' for example, so I'm guessing it's succeeding.)

However, the sound is still heavily reduced in quality - the result remains the same no matter what I select. It always becomes mono  sad  Any idea? Doesn't Scratch allow stereo playback?

edit2: 'Scratch-Objects > SoundMedia > scratch ops > playFrom:To:' says something about mono  sad  any help would be greatly appreciated.


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#6 2012-02-04 19:46:42

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Don't convert sound to mono?

JSO wrote:

Thanks so much jvvg! It worked  smile

I was experimenting in the official 1.4 image so the arguments were named differently but everything went well  smile

Edit: hmm; I added dialogboxes for both the downsampling and the mono conversion, and it seems to skip the conversion steps. (It doesn't show 'converting to mono...' for example, so I'm guessing it's succeeding.)

However, the sound is still heavily reduced in quality - the result remains the same no matter what I select. It always becomes mono  sad  Any idea? Doesn't Scratch allow stereo playback?

edit2: 'Scratch-Objects > SoundMedia > scratch ops > playFrom:To:' says something about mono  sad  any help would be greatly appreciated.

Yeah, I think Scratch just doesn't support stereo audio, which is why it converted to mono.  sad


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#7 2012-02-05 03:19:29

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Don't convert sound to mono?

Seems to be true. The code does seem to support a "pan" or "balance" feature, that would allow you to play a mono sound through only one speaker (or louder through one speaker than through another). If I could turn this into a block somehow, I could just split up my stereo song, and import both 'sides' in Scratch in different sprites.

And 'balance' sound blocks would be awesome for many reasons :p


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#8 2012-02-05 13:23:53

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Don't convert sound to mono?

JSO wrote:

Seems to be true. The code does seem to support a "pan" or "balance" feature, that would allow you to play a mono sound through only one speaker (or louder through one speaker than through another). If I could turn this into a block somehow, I could just split up my stereo song, and import both 'sides' in Scratch in different sprites.

And 'balance' sound blocks would be awesome for many reasons :p

Yeah, I was looking into removing the mono-ising and downsampling a while back and found there isn't really anything you can do  hmm


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#9 2012-02-05 15:36:34

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Don't convert sound to mono?

I did manage to create (balance) and 'set balance to ()'  smile  Everything is already in there, it's quite easy.

At first I wanted to make it exactly like the volume blocks, so I added 'balance _ 50' in scriptablescratchmorph>initialization>initialize, but it refused to save saying 'variable undefined'. Isn't that where you *declare* variables? :S Why does it refuse to do it?

I made it work by having the 'balance' and 'setbalanceto:' methods reference the properties of the actual sound object thing. That's different from the way the volume blocks work but, I could pan sounds across my speakers  big_smile   big_smile   big_smile

So now I can just import the left and right track separately, play them in different sprites: 1 with balance set to 0, the other with balance set to 100.

They should fix that in Scratch 2.0  tongue

edit: here's a link to what I have now  smile
http://www.mediafire.com/?zbyt59l9tm8u7ns

Last edited by JSO (2012-02-05 15:43:40)


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#10 2012-02-05 15:51:39

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Don't convert sound to mono?

It's a good idea. Unfortunately Scratch is well known for its inability to process sounds at exact speeds, which means your left and right tracks, now independent of each other could quite quickly end up out of sync. This will obviously cause problems.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#11 2012-02-05 16:34:23

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Don't convert sound to mono?

JSO wrote:

IAt first I wanted to make it exactly like the volume blocks, so I added 'balance _ 50' in scriptablescratchmorph>initialization>initialize, but it refused to save saying 'variable undefined'. Isn't that where you *declare* variables? :S Why does it refuse to do it?

Usually, it offers to declare it as an instance variable for you, but, failing that, you can open another browser on the class (don't select a method or category) and add an item to the "instanceVariables: '...' " section in the editor pane.


nXIII

Offline

 

#12 2012-02-05 17:32:43

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Don't convert sound to mono?

ah - confusing. why is "instanceVariables: '...'" empty when browsing then?


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#13 2012-02-05 17:48:18

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Don't convert sound to mono?

JSO wrote:

ah - confusing. why is "instanceVariables: '...'" empty when browsing then?

Sorry, it should look something like this:

ScriptableScratchMorph subclass: #ScratchSpriteMorph
    instanceVariableNames: 'scalePoint rotationDegrees rotationStyle rotatedForm offsetWhenRotated draggable penDown penSize penColor penHue penShade <insert additional space-separated instance vars here>'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Scratch-Objects'

Change whatever you want about the class, then accept your changes (like you would when editing a method).

Last edited by nXIII (2012-02-05 17:49:08)


nXIII

Offline

 

#14 2012-02-05 18:21:13

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Don't convert sound to mono?

Oh I see now. Thanks so much for the help! (although it works - would it be useful to give scriptablescratchmorph a balance instance variable?)

Also (sorry for being such a source code noob :p) why does squeak change my named local variables to t1 t2 t3 etc when I click accept? fairly annoying actually :S


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#15 2012-02-05 18:33:39

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Don't convert sound to mono?

JSO wrote:

Oh I see now. Thanks so much for the help! (although it works - would it be useful to give scriptablescratchmorph a balance instance variable?)

The only reason I could see to do this is if you wanted to retain a local volume even if some other object changed the sound's balance.

Also (sorry for being such a source code noob :p) why does squeak change my named local variables to t1 t2 t3 etc when I click accept? fairly annoying actually :S

This is because Squeak is discarding the actual method source (it doesn't have anywhere to put it; you can add a .sources file to fix this) and decompiling the compiled (bytecode) method when you view it.


nXIII

Offline

 

Board footer