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

#1 2008-08-13 07:21:32

SonicPopsDad
Scratcher
Registered: 2008-07-30
Posts: 41

Scratch's sound processing... how much polyphony?

I've noticed that I can run into problems when playing two or more sounds simultaneously... sometimes 'play instrument' seems to miss out notes, if there's a lot going on, and more obviously I can get problems like weird noises... chirps, static crackles etc... when playing two sound samples at the same time.

What are the technical limitations, and what can I do to mitigate them?   Is it likely a fuure version of Scratch will have a more robust sound engine?

Last edited by SonicPopsDad (2008-08-13 07:22:01)

Offline

 

#2 2008-08-13 07:39:25

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

Re: Scratch's sound processing... how much polyphony?

That's interesting. Could you perhaps post a (link to a) project with such problems, like missing out notes, weird noises and such? I'd like to have a look these. Thanks!


Jens Mönig

Offline

 

#3 2008-08-13 07:50:04

SonicPopsDad
Scratcher
Registered: 2008-07-30
Posts: 41

Re: Scratch's sound processing... how much polyphony?

Ah, if you've not noticed it, it might be down to my hardware!

My laptop is a 1.4ghz C2D with on-board sound, and my main pc is 3.2ghz C2D... with on-board sound.  Maybe my sound systems aren't quite up to the job :]

I've got two projects... one is a Music sound-loop mixer I started last night, which is trying to play 2 instruments and two drums simultaneously.   
The other is Defender, and I get static and chirps when playing the laser firing sound over the top of the thrust sound.   
Neither project is in a publishable state yet, but I'll load 'em up at yousendit.com tonight so you can download them  smile

Offline

 

#4 2008-08-13 07:54:31

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

Re: Scratch's sound processing... how much polyphony?

Actually, I have experienced some distortions when using Scratch's midi. Sometimes it seems as if the volume is too loud (sounds like the old overdrive effect in a tube amp)...


Jens Mönig

Offline

 

#5 2008-08-13 08:03:32

SonicPopsDad
Scratcher
Registered: 2008-07-30
Posts: 41

Re: Scratch's sound processing... how much polyphony?

Yeah, I had to add a volume slider for each instrument because of that.  But I quite liked the effect.   
And I particularly like some of the effects given when playing notes that are 'too low' for the instruments, they're really great!

Offline

 

#6 2009-01-07 09:31:01

emedlin
Scratcher
Registered: 2009-01-04
Posts: 2

Re: Scratch's sound processing... how much polyphony?

I've looked through the documentation, FAQ and the forums and can't seem to find the answer to the following question.  So if it has already been asked and answered, please point me in the right direction and I apologize in advance.

What is the maximum number of notes the sound engine can place simultaneously?  It obviously can play cords but what is the limit.  Is it cable of doing a dozen guitar strings at once while also generating several drum sounds?  Is it capable of simulating a 100 piece orchestra?

I was thinking of creating a program that would allow music students to graphically enter a score of music with multiple instruments and parts and then be able to play it back to help them learn the composition.  This would be great for a band student to use for practice at home.  They wouldn't be just playing solo, they would have a whole band to play with.

Offline

 

#7 2009-01-07 18:16:57

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Scratch's sound processing... how much polyphony?

emedlin wrote:

I've looked through the documentation, FAQ and the forums and can't seem to find the answer to the following question.  So if it has already been asked and answered, please point me in the right direction and I apologize in advance.

What is the maximum number of notes the sound engine can place simultaneously?  It obviously can play cords but what is the limit.  Is it cable of doing a dozen guitar strings at once while also generating several drum sounds?  Is it capable of simulating a 100 piece orchestra?

I was thinking of creating a program that would allow music students to graphically enter a score of music with multiple instruments and parts and then be able to play it back to help them learn the composition.  This would be great for a band student to use for practice at home.  They wouldn't be just playing solo, they would have a whole band to play with.

I think Jens can probably answer the polyphony question the best...he has done a number of music projects and has expert knowledge of Scratch itself. 

As for the music program...that would be wonderful.  Here is one that I have been working on for entering and editting a single voice.  Maybe it will give you a starting point for your more ambitious vision!

http://scratch.mit.edu/projects/Paddle2SeeFixIt/363514


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#8 2009-01-07 20:01:05

coraman2u2
Scratcher
Registered: 2008-10-31
Posts: 8

Re: Scratch's sound processing... how much polyphony?

ok but the reading of the manual won't do anybody good because it doesn't stay on topic with scratch.

Offline

 

#9 2009-01-08 02:54:46

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

Re: Scratch's sound processing... how much polyphony?

Hi emedlin,

your Idea to create a polyphonic music editor in Scratch sounds very excting, I can't wait to try it! As Paddle2See has pointed out, polyphony can be achieved rather easily in Scratch (as compared to other programming languages), because concurrent threads in Scratch can simply be achieved by creating several scripts which are triggered by the same message-event.

As far as I foresee it, the main problem for such a project will not so much lie in the total amount of notes playable at one time (I've experimented with a couple of polyphonic projects with lots of parallel notes/drums without noticing any limitation), but in the fact, that as of now Scratch doesn't have truly dynamic capabilites, i.e. you cannot create threads at "runtime" (in presentation mode or on in the java player) in Scratch. This forces you to set up all your possible voices, even though you might not actually need some of them depending on what the users edit.

Another limitation of Scratch concerning more complex polyphonic musical projects is the absence of complex data types (i.e. classes and multi-dimensional lists). Instead of being able to define a data structure for a "chord" or a "note" you need to work with (mostly global) lists and variables and huge amounts of (public) broadcast messages to synchronize everything. In my experience this clutters up project code pretty soon and rather severely.

I'd therefore suggest to start out with a simpler project design. In my polyphonic projects I usually specify the following "instruments":

   - some "voices" (different sprites with 1 to 3 threads)
   - a "chords" sprite with 3-5 threads for simple to complex chords
   - a "bass" sprite (1 thread)
   - 2 to 5 drum threads (bass, snare, hi-hat, drums, percussion)

This usually allows for some simple, straight-forward composition excercises, and is probably good enough to get students started with orchestration arrangements.


Jens Mönig

Offline

 

#10 2009-01-08 14:41:36

xaby
Scratcher
Registered: 2008-02-13
Posts: 49

Re: Scratch's sound processing... how much polyphony?

What about Mario Paint Composer for Scratch?

Offline

 

#11 2009-01-09 12:12:43

emedlin
Scratcher
Registered: 2009-01-04
Posts: 2

Re: Scratch's sound processing... how much polyphony?

Thanks Paddle2See and Jens for the reply.

This does give me some good ideas.

I've been playing around a little to test the limits and one thing I noticed already was that more than one sprite can play the same note at the same time and not impact the other.  You can also have 1 sprite play different notes at the same time with out impacting each note.  However if you try to have 1 sprite play more than one instance of the same note it seams to not recognize the latter notes until the first finishes.  Check out the polyphonic test I created http://scratch.mit.edu/projects/emedlin/375509.

So if you want to simulate a polyphonic instrument, such as a guitar or a piano, in one sprite; I guess you would be OK since the same note would not be played more than once at the same time.  But if you wanted to represent multiple parts and players of a monophonic instrument, such as a trumpet or flute, you would have to do that in separate sprites because at some point multiple players/parts are likely to play the same note with varying duration.

Does this make sense?

My next test will be to see how many sprites I can create with each playing varying notes and instruments before something breaks.  I'll let you know what happens.

Offline

 

Board footer