sugarlabs / musicblocks

Music Blocks -- A musical microworld
https://musicblocks.sugarlabs.org/
GNU Affero General Public License v3.0
585 stars 811 forks source link

Morse Code rhythms #3667

Closed walterbender closed 7 months ago

walterbender commented 9 months ago

In the overture of the movie Mission Impossible (MI), the rhythm begins with a mapping of the Morse Code for MI.

dah dah (M) dit dit (I) --> 1/4 1/4 1/8 1/8

It would be fun to have a MB project that lets you generate Rhythms by typing in letters that generate rhythmic patterns.

richardshaju commented 9 months ago

That's Interesting. I want to work on this. The project aims to translate alphabets to Morse code right?

walterbender commented 9 months ago

The goal is to use Morse code to generate rhythmic patterns.

AviGawande commented 9 months ago

Hello @walterbender for this year gsoc how can we proceed for adding the games in the sugar,means how can we start with it. I am bit confused..

walterbender commented 9 months ago

For this particular issue, I think it would be a Music Blocks project. That said, we have developed a lot of games in Music Blocks. It might be a cool project to port some of them to Sugar activities. (This would involve essentially rewriting them from scratch in Python, but it would be a nice addition to the Sugar activity collection.)

richardshaju commented 9 months ago

Where can we find the sugar activities?

walterbender commented 9 months ago

GitHub com/sugarlabs

falgun143 commented 9 months ago

@walterbender We only have to use the existing components(Notes,pitches etc...) for generating rhythms right? ,Should I have to create a new project and publish it in global of planet? . And also when i type M we should listen dah and when i type I we should listen dit ,Then I have to add eventlistener and where should i make changes ,Should i create a new file in the repo like MI.js?

richardshaju commented 9 months ago

GitHub com/sugarlabs

Should I add an issue at help-activity or submit a PR directly?

walterbender commented 9 months ago

Feel free to create issues directly

walterbender commented 9 months ago

A project on the planet would make the most sense. I think there are adequate existing blocks to make this app.

falgun143 commented 9 months ago

@walterbender I am under work see the below video

https://github.com/sugarlabs/musicblocks/assets/105922142/3e7c03d0-4612-4082-a10a-1f08c1b3b218

i have a small doubt i have created this using simple blocks(Will make changes for better quality).Now i will add keyboard event letters for M and I .When users press these letters music should come up,Please tell me should i create a new js file which will handle this evenlisteners and then publish this on the global ,And then make a pr or anything else?

walterbender commented 9 months ago

I would approach this differently:

make a set of actions named by the alphabet, where each action plays a rhythmic pattern defined by that letter's code. then in a loop, use the input block to get letters to use with the do block.

falgun143 commented 9 months ago

@walterbender like this? https://github.com/sugarlabs/musicblocks/assets/105922142/b5d48b2b-1f58-4afb-a213-ed2f4242eee7

walterbender commented 9 months ago

That is a good start. I think it might be more obvious if there were a bigger difference between the note values as well. And you'll want to accumulate the letters onto a heap so that you can play back a rhythmic pattern. (This might even be a case of where we want to use the make block block, but that can be a separate step.)

falgun143 commented 9 months ago

@walterbender what about this sir?

https://github.com/sugarlabs/musicblocks/assets/105922142/20fea362-a628-4aa4-a18b-e1825df9170b

walterbender commented 9 months ago

That is more fun. But we'll want to define an action for each letter of the alphabet, not just M and I. You probably want to use the "do" block, using the input as the name of the action.

falgun143 commented 9 months ago

@walterbender morse code is mapped to MI ,So why we will need to assign each letter of the alphabet to a particular action ,And even if we do that what should each letter of the alphabet be mapped as an action?

walterbender commented 9 months ago

Screenshot from 2024-01-31 14-01-00

Something like this...

falgun143 commented 9 months ago

image @walterbender As you can see in the above picture that M is mapped to a action which reprsents long note with certain pitch.And I is mapped to a action which seems complex as compared to action of M.

The the rythm pattern is image

Now the logic which i used is that when, I I comes for the first time the pitch is high then low in one way and again when ,I I comes for the second time the pitch is high then low in other way.

See the below video for reference.

https://github.com/sugarlabs/musicblocks/assets/105922142/57894e7a-7877-4d4d-8fff-4de1810c49d5

As shown in the rhythm pattern picture first two I's comes at index 2,3 and the second two I's comes at index 6,7 .So we need a counter to identiy these index's.And by listening to original music we want the music to be same at index 2 and 6,And a bit lower pitch at index 3 (As compared at index 2).And lower pitch at index 7 (As compared to index 6).

Initially the box1 value is set to zero and heap is empty.(As there might be a value already store in the box1 due to previous actions) So i used a box.And as the loop run's we incremet the box value ,And when the user types I for the first time the value of box is 2 ,For the second time value is 3 ,For the 3rd time value is 6 ,For the third time value is 7.So according to the requirements i have set the action for I.And also I have stored the action values in the heap.And again set block's value to zero.

Now when we play the whole pattern using heap .First we have to reverse the heap as to get the original sequence.,As to run the I action correctly we again have to increment the value of box (As we have done in the start block).

If there are any suggestions please let me know.

walterbender commented 9 months ago

The goal is not to transcribe the Mission Impossible theme music. That as just the inspiration for the project idea. The goal is to be able to type ASCII and have it converted into a rhythmic Morse code.

falgun143 commented 9 months ago

@walterbender so each letter of the alphabet should have to mapped to a action ,And i should assign action to each letter of the alphabet so that a rhythm is generated right?

walterbender commented 9 months ago

Yes. My example is one simple approach. There are other ways as well.

falgun143 commented 9 months ago

@walterbender please review it ,Then i will publish it in global section

https://github.com/sugarlabs/musicblocks/assets/105922142/b1c5c9bf-23d6-4cd2-a53e-8deac00a159b

walterbender commented 9 months ago

This is getting pretty good. Can you add a button play back the heap? When you play it back, since it is a FILO, you'll need to reverse it first. And the instructions on the input could be a bit more to the point... type in a character. Perhaps some message at the start to explain what is going on?

falgun143 commented 9 months ago

@walterbender plz review it.

https://github.com/sugarlabs/musicblocks/assets/105922142/28b2d6e3-c224-4e8a-bab9-1fab37e692f5

walterbender commented 9 months ago

Screenshot from 2024-02-04 14-52-40

I was thinking of a play button like ^^

falgun143 commented 9 months ago

@walterbender there is a problem with that .The new start block(Play button start block) is a different world from the first start block(Mouse start block),The play action in the second start block assumes that thre is noting being push into the heap(But actually was pushed in the first start block) and give's a message of empty heap.

https://github.com/sugarlabs/musicblocks/assets/105922142/d4b16a6c-5f7c-4b71-8212-f81022d10453

walterbender commented 9 months ago

On the ensemble block there is a way to access the heap of a different start block, as long as you give that start block a name.

falgun143 commented 9 months ago

@walterbender Done,Plz review it. https://github.com/sugarlabs/musicblocks/assets/105922142/aec3d316-cb78-4fc4-b2d3-701f8aaf3752

walterbender commented 9 months ago

Excellent. So maybe the empty heap should be a button too? And a show heap button? Then I think it is solid.

falgun143 commented 9 months ago

image @walterbender I tried to do like the above one but the problem is that in Ensemble block we only have .The below block image So we can only get the value at the particular index,But the Use of the show heap is to print all the values at a given time.Like this image

And similarly we cannot empty the whole heap using the above startegy. I think we can do it without buttons ?

walterbender commented 9 months ago

You can have those buttons broadcast events that the startblock that "owns" the heap can listen for.

falgun143 commented 9 months ago

@walterbender I have tried it but didn't work https://github.com/sugarlabs/musicblocks/assets/105922142/c4008c89-d933-4c9a-bfc7-314b3fdd0e9c

walterbender commented 9 months ago

Can you upload your project here or to the planet?

falgun143 commented 9 months ago

FINALMORSECODE (2).zip Click on initialze action to start the project.Show below image

walterbender commented 9 months ago

Check out this version... morse.zip

falgun143 commented 9 months ago

@walterbender When i click on Play button it is able to broadcast the event play but PlayAll action is not triggered from mouse1.Hence not able to listen the complete music rhythm similarly for other buttons.

https://github.com/sugarlabs/musicblocks/assets/105922142/7814f1a9-27f0-4d9d-b0fa-3800f17674cf

walterbender commented 9 months ago

Hmm. It was working for me. I'll look again.

walterbender commented 9 months ago

I added a print to the play for debugging. Works fine for me. Fedora/Chromium morse.zip

falgun143 commented 9 months ago

@walterbender I thought of a solution that can't we make the heap block global that is every start block will use the same heap block,What do you think?

walterbender commented 9 months ago

There is no reason to have more than 1 heap, controlled by just one mouse. We can use event handling.

falgun143 commented 9 months ago

@walterbender I am telling that if heap is suppose ["T","T","T"] with respect to mouse1 then when we print the heap with respect to other mouse(let's say PlayAll),Then we will see Empty heap[](without help of broadcast).So we can make a common heap so that other mouse will also give heap as ["T","T","T"] . https://github.com/sugarlabs/musicblocks/assets/105922142/ddf24ece-6412-40f6-bb05-f8013eb3b4f6

walterbender commented 9 months ago

Please look at the code I shared once again. Using one mouse/heap with events is the simpler solution.

falgun143 commented 9 months ago

@walterbender I have installed chromium and ran the project still doesn't work,It might be a problem in my browser.Can u confirm it from some one or should I ask some one to check if it works in their browser?

walterbender commented 9 months ago

Are you sure you are running the correct file? I pushed my version to the planet. https://musicblocks.sugarlabs.org/index.html?id=1707347782903764

Try adding prints to the broadcast actions to make sure they are getting triggered. And prints to the event handlers.

falgun143 commented 9 months ago

Are you sure you are running the correct file? I pushed my version to the planet. https://musicblocks.sugarlabs.org/index.html?id=1707347782903764

Try adding prints to the broadcast actions to make sure they are getting triggered. And prints to the event handlers.

@walterbender yes.

https://github.com/sugarlabs/musicblocks/assets/105922142/00588706-cd17-4818-bb50-044ff439a9f6

walterbender commented 9 months ago

Why are you clicking on the playall stack instead of clicking on the button?

walterbender commented 9 months ago

When you do that, you no longer have the event handlers active since you are running a new mouse.

falgun143 commented 9 months ago

Why are you clicking on the playall stack instead of clicking on the button?

@walterbender now even the broadcastplay doesn't work.

https://github.com/sugarlabs/musicblocks/assets/105922142/0c92efd2-060f-4d6d-bc7c-4e5db6c3a7bc

If you don't mind can you please show a video at your end.

harshuttamchandani commented 7 months ago

is this issue being worked upon? if not I would like to give it a try :-)