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

#1 2009-10-17 16:39:04

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Can a project remember a randomly played musical note?

Following an example from a project by The-Whiz, a sprite could *randomly* choose its x-position and then by using the variable "my-x" could say, "Set (my-x) to (x position)". So it would then remember where it had been at that particular point in case it wanted to go back there.  Now, I would like to do the same thing with a randomly selected musical note.  But there's no built-in "note position" expression the way there is for X and Y positions.  So I can't say, "Set (my-note) to (note position)".  I would like to randomly get a note and then build on it by being able to remember whatever that note had been. Is there a way to do that?  Thanks for any suggestions!

Offline

 

#2 2009-10-17 16:42:24

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Can a project remember a randomly played musical note?

Maybe use a list... the first note is the first item and so on.

As for the location analogy, that's how mouse recorders work. Each position is recorded in a list, so it would make sense if this worked...


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#3 2009-10-17 16:45:58

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

Re: Can a project remember a randomly played musical note?

Maybe
set [my note] to (pick random (60) to (80)
play note (my note) for (0.1) beats

???


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

Offline

 

#4 2009-10-17 16:49:46

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Can a project remember a randomly played musical note?

JSO wrote:

Maybe
set [my note] to (pick random (60) to (80)
play note (my note) for (0.1) beats

???

Well, he wants like a random song, that can be played over... I think...  hmm


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#5 2009-10-17 16:52:16

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Can a project remember a randomly played musical note?

Following your suggestion I built a quick test: I made a List called "Note Box" (because that was where I'd store the notes I wanted to remember) and then had Cat choose to play Instrument #1 (piano) and "play note (pick random (50) to (80)". 

But, now I don't know how to "pick up" that note to put it in the Note Box!!  I can't guess what random note it played, and don't know how to get it to tell me!!  :-/

I had built "Record a Tune" with a keyboard interface. When one pressed a black or white key the Script said "play note (55)" and then my variable "Note Played" picked it up....but I had to tell it!!  The next command after the "play note" command was "Set (note played) to (55)" but I had to type "55" into the script.  And then the next command added the 55 to the List.

So I don't want to record a whole song now.  I just want to randomly generate a single note and have the project remember it (for whatever purpose).

A list sounds great, but I can't figure out how the List could ever know what note had been randomly chosen!!!

Is this making sense?

Last edited by Larry828 (2009-10-17 17:01:24)

Offline

 

#6 2009-10-17 17:00:01

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Can a project remember a randomly played musical note?

Here you go:
http://i37.tinypic.com/riwvo4.jpg

it involves a trick with a variable, but it works very easily:

You need a randomly chosen number stored temporarily in a variable. The current value of the variable is added to the list and the note is played. the variable now picks a new value, and so on...



Here's how to play the song back:

http://i38.tinypic.com/ic45ew.jpg

You need a new variable for this. And don't forget to clear the list when the project starts either...


Any Questions?  smile

Last edited by greenflash (2009-10-17 17:09:36)


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#7 2009-10-17 17:13:04

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Can a project remember a randomly played musical note?

greenflash wrote:

Here you go:
http://i37.tinypic.com/riwvo4.jpg

it involves a trick with a variable, but it works very easily.

Here's how to play the song back:

http://i38.tinypic.com/ic45ew.jpg

You need a new variable for this.

Any Questions?  smile

You're RIGHT, greenflash!!  I built the script you described and added 7 notes to the List.  Then I said that when Spacebar was pressed it should play Item 6, and right after that should play "Item 6 + (12)". 

I pressed the Spacebar and it played the note and then a note one octave higher!!

That's *exactly* what I wanted!  A project could remember a note, and then I could build on that particular note any way I wanted to.  And return to it anytime to start again. And so on.

Thanks so much!  Really great. 
You're a very helpful "Scratch Friend" to have!
Thanks, Larry828

Offline

 

#8 2009-10-17 17:16:06

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Can a project remember a randomly played musical note?

Larry828 wrote:

greenflash wrote:

Here you go:
http://i37.tinypic.com/riwvo4.jpg

it involves a trick with a variable, but it works very easily.

Here's how to play the song back:

http://i38.tinypic.com/ic45ew.jpg

You need a new variable for this.

Any Questions?  smile

You're RIGHT, greenflash!!  I built the script you described and added 7 notes to the List.  Then I said that when Spacebar was pressed it should play Item 6, and right after that should play "Item 6 + (12)". 

I pressed the Spacebar and it played the note and then a note one octave higher!!

That's *exactly* what I wanted!  A project could remember a note, and then I could build on that particular note any way I wanted to.  And return to it anytime to start again. And so on.

Thanks so much!  Really great. 
You're a very helpful "Scratch Friend" to have!
Thanks, Larry828

No problem! I'm glad it worked  big_smile


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#9 2009-10-17 17:16:47

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Can a project remember a randomly played musical note?

PS

That's a very funny expression you created, by the way.

"Play note (note)"

At least it seems amusing to *me*...

Thanks again!
Larry828

Offline

 

Board footer