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

#1 2011-12-11 09:43:19

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Midi to Scratch Convertor wanted

Just in case anyone's a bit bored and looking for a challgenge I'm looking for a program (any language but must run in windows XP - its be amazing if it could be done in Scratch or BYOB itself!) that will take a .mid file and convert it into a series of sprites containing set instrument to x, play note y for z beats, (and rests of course).

I'm going to try getting a class of  pupils to use their netbooks as a e-orchestra and it would nice to setup the main computer with a real midi keyboard and midi-in recorder to record short sequences and then edit them in Scratch and thne play them back out all together with a conductor at the front of the class.

Simon

Offline

 

#2 2011-12-11 09:57:34

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Midi to Scratch Convertor wanted

you could just go here or here wait, I found another one  lol  here and here

Last edited by flashgocrazy (2011-12-11 10:04:00)


◕‿◕

Offline

 

#3 2011-12-11 12:26:19

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Midi to Scratch Convertor wanted

flashgocrazy wrote:

you could just go here or here wait, I found another one  lol  here and here

1) That's not what he wanted
2) That's not what he wanted
3) I just got rick roll'd
4) I have the strange urge to obey you!


Fork Clamor on GitHub!

Offline

 

#4 2011-12-11 13:04:41

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Midi to Scratch Convertor wanted

Um… try recording the file?

Offline

 

#5 2011-12-11 13:11:04

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Midi to Scratch Convertor wanted

I doubt this is gonna be easy... maybe you should put a C++ coded converter as a middle step, for the processing power...

Offline

 

#6 2011-12-11 15:44:00

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

@flashgocrazy - this is the advanced section  smile
@LS97 - i don't have the time/skill to do it - I'm looking for someone who's bored and capable  smile

I think it will have to written in a "grown-up" language  smile  but in concept it could be failry simple - read midi file - split into midi tracks - and then the hard bit - write it out as a Scratch sprite!

Simon

Offline

 

#7 2011-12-11 18:08:23

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Midi to Scratch Convertor wanted

SimpleScratch wrote:

I think it will have to written in a "grown-up" language  smile  but in concept it could be failry simple - read midi file - split into midi tracks - and then the hard bit - write it out as a Scratch sprite!

Writing it out as a Scratch sprite is definitely the hardest part. I'm not sure if it's possible to do it in something like Python and not in Squeak itself, but I might go have a look!  big_smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#8 2011-12-11 18:40:25

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Midi to Scratch Convertor wanted

I'll (mildly) attempt this.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#9 2011-12-12 02:10:51

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

Go blob8108 and bobbybee !
[edit]daft info removed  smile  [/edit]
Simon

Last edited by SimpleScratch (2011-12-12 02:17:23)

Offline

 

#10 2011-12-12 08:21:11

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Midi to Scratch Convertor wanted

SimpleScratch wrote:

Go blob8108 and bobbybee !
[edit]daft info removed  smile  [/edit]
Simon

I assume this is the relevant thread...

It'd be really useful to have a MIDI file and corresponding Scratch .sprite file to demonstrate precisely what it is you're looking for.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#11 2011-12-12 15:56:35

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

I'll get onto it.  smile
Simon

Offline

 

#12 2011-12-13 02:23:33

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

Here is a simple midi file generated in Anvil Studio
http://dl.dropbox.com/u/1173161/scratch/Frere%20Jaques.mid

and first half of it in Scratch
http://dl.dropbox.com/u/1173161/scratch/frere.PNG

Si

Offline

 

#13 2011-12-13 03:25:41

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

Scratch has a built-in MIDI player. It is inherited from Squeak.
You need to Shift-Click-R before play.
Then open "file list" from "World" menu and select the midi file.
To play it, choose "play midi file" from right button menu.
https://twitter.com/#!/abee2/status/146 … 24/photo/1
It requires some mods to convert it into blocks.

Offline

 

#14 2011-12-13 04:52:29

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

@abee - good find - very interesting what you can find under the hood  smile

Simon

Offline

 

#15 2011-12-15 06:01:24

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

I've thought that actually I could get 80% of what I'd like by just having a midi reader program produce a text file like

Set Instrument to 1
Play Note 48 for 0.5 beats
Play Note 50 for 0.5 beats
Play Note 52 for 0.5 beats
Play Note 48 for 0.5 beats

etc

regards
Simon

Offline

 

#16 2011-12-15 07:13:50

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Midi to Scratch Convertor wanted

SimpleScratch wrote:

I've thought that actually I could get 80% of what I'd like by just having a midi reader program produce a text file like

Set Instrument to 1
Play Note 48 for 0.5 beats
Play Note 50 for 0.5 beats
Play Note 52 for 0.5 beats
Play Note 48 for 0.5 beats

etc

regards
Simon

You'd still have to write the script yourself, though, wouldn't you?  hmm

Last edited by blob8108 (2011-12-15 08:41:14)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#17 2011-12-15 09:38:18

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

Offline

 

#18 2011-12-15 16:57:46

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

blob8108 wrote:

You'd still have to write the script yourself, though, wouldn't you?  hmm

Yes, but at least my pupils could just write them by hand.

My plan is to record short 1 or 2 bar repeating sections with a midi keyboard and then convert them into scratch loops so getting the instrument, note and duration would let me start my after school clubs  smile

Simon

Offline

 

#19 2011-12-16 09:24:44

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Midi to Scratch Convertor wanted

One way would be to make a parser within BYOB (Scratch would be too hard) that reads a string (generated by a "grown-up" language) and plays it in Scratch language. It would have to work something like this:

Get a string that looks like this:
P(1,A,2,B)G(1,R,2,B)
from a Java/C file.

Read it as: INSTRUMENT(DURATION,NOTE,DURATION,NOTE...)INSTRUMENT(DURATION,NOTE...)...

Parse into a list of lists of lists, with arrangement:
Each item in the "big" list is an instrumental track. Each instrumental track is a list of notes. Each note is a two-object list of a duration and a note.

Finally, you'll need to convert that into a list of scripts rather than instruments, then launch each script.

It'll probably take a while, but it'll simplify the "to Scratch" conversion to a "to String" conversion.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#20 2011-12-17 06:23:26

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

Done. Here it is.
http://squeakland.jp/abee/tmp/midi2script.zip
Use midi2script.image instead of Scratch,image.
Then choose "import midi file" menu in the script area, See midi2script.png.
There are some restrictions.
- cannot get instruments
- take a long time when import a big file
- tempo is not reliable
- etc.
Cheers.

Last edited by abee (2011-12-17 06:24:10)

Offline

 

#21 2011-12-18 19:25:39

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

@abbe - great effort :-)

Seems to work on the Frere Jacques but  struggling to get it to work on others  sad

I'll try more variations and see when it hits problems

But fantastic work !  smile

Simon

Offline

 

#22 2011-12-20 12:16:25

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

I tried another simple 2 bar one I recorded so its probably good enough for the main job required  smile

Simon

Offline

 

#23 2011-12-21 12:05:17

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Midi to Scratch Convertor wanted

That's great to hear!

Offline

 

#24 2011-12-22 10:42:18

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: Midi to Scratch Convertor wanted

Almost 3 years ago, I converted the midi to lists that could be read by this scratch program.   smile   Does that help?


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

Board footer