mcjMidiKit



Introduction

This page will host 2 or 3 scripts for Daz Studio 

which help you create animations based on the content of a midi file




History



July 5th 2015 - new version with Inspector panel and better handling of extremely brief midi ebvents like those on drums
download MCJMIDILOADSUPERSECRETBETAJULY05.DSA and 
MCJMIDILOADSUPERSECRETBETAJULY05.DSA.png
and place them in your scripts/mcasual folder 

April 19th 11:30 PM Release of version 001
April 20th 0:38AM Release of version 002 - v1 was sometimes unable to find bones other than the hip
April 20th 2:28AM Release of version 003 - v2 
- under DS4.7 i had to very clearly typecast the times returned by getTimeStep() and getKeyTime(i) as numbers
- under DS4.x the obj and its morphs of DzBones are owned by the skeleton
- fixed the case where the scene does not have a pre-existing midi node , else the "notess" combo-box was not created






Installation



Pre-requisite: the midi-to-text utility mf2t.exe

My Daz Scripts ( at least for now ) don't directly read the content of midi ( *.mid) files
instead they expect to be fed text files ( .txt ) 
produced by the free midi-to-text converter utility named mf2t

the windows PC version can be downloaded here:

http://mf2t-win32.sourceforge.net/

there's a Mac/OSX version here
 
https://code.google.com/p/midi2text/downloads/detail?name=MacMIDIt2mf_v1.5.0.zip&can=2&q=

but i cant promise my script will be able to handle their text files 

i installed ( unzipped ) mine in c:\Program Files\mf2t

it's easy to remember,

After installing it, use Explorer to make sure the files ( most of all mf2t.exe )

did end up in c:\Program Files\mf2t, not in c:\Program Files\mf2t\mf2t-win32-20110205

note that this is a Windows 32 bit version so technically it should go under C:\Program Files (x86)

but it works fine in C:\Program Files


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


The Daz Scripts


The zip package is found at the bottom of this page

unzip it in your daz content folder, typically 


C:\Program Files\DAZ\Studio\content\ 
or

C:\Program Files (x86)\DAZ\Studio\content\


once installed, it will appear in your content library, under Studio / Scripts / mcasual 


or


C:\Users\Public\Documents\My DAZ 3D Library\


once installed, it will appear in your content library, under My DAZ 3D Library / Scripts / mcasual
 





Use



A step by step demonstration

i go to http://sourceforge.net/projects/mf2t-win32/?source=directory

i download mf2t-win32-20110205.zip

i unzip this into C:\Program Files (x86)

using explorer i go see what happened

i see the folder mf2t-win32-20110205

i rename the folder to mf2t

i open DS 4.7

i create a primitive Cylinder, 1ft diameter, 6ft tall

i select the cylinder with my mouse

i start the script mcjMidiLoad.dsa

now i must tell mcjMidiLoad the location of mf2t.exe

i click the Locate Converter button and i browse up to C:\Program Files (86)/mf2t/

i select the mf2t(.exe) file and click Open





i click the Convert Midi to Text button

i browse to and select c:\windows\media\town(.mid)


I click open

mcjMidiLoad told mf2t.exe to convert town.mid to town.mid.txt

i think i saw something flash on screen but i’m not sure if it worked !

i click the Load Text button

mcjMidiLoad expects to find town.mid.txt in the same folder as town.mid

but it’s not there

why?

maybe because that folder is only writable to by programs with high administrative privileges

so

i copy town.mid to ....... C:\Users\Public\Music

i click the Convert Midi to Text button

i browse to and select C:\Users\Public\Music\town(.mid)



i click the Load Text button

tada! the town.mid.txt file was created!


i click the open button, wait a few seconds ( it's a script not a plug-in so it's not extremely fast )

and we can see mcjMidiLoad deciphered the town.mid.txt file

and found music sheets for a lot of instruments


before we go into animation, lets get the audio track

i download Polysoft Solutions' Free Midi To Mp3 converter

http://download.cnet.com/Free-MIDI-to-MP3-Converter/3000-2140_4-75211970.html

i carefully avoid installing any extras which are often packaged with freeware

i drag and drop town.mid , which is in a Public folder and convert the midi to mp3 format

Then i use the freeware Audacity to convert it to town.wav

http://download.cnet.com/Audacity/3000-2170_4-10058117.html

File/Open town.mp3 

File/Export town.wav 

is all you need to learn ! to convert it


Then i set town.wav as the audio track in Daz Studio 4.7 using the Edit / Audio menu

make sure town.wav is set to start at frame 0


While we're not in the script if we go in the Scene tab

we discover that mcjMidiLoad created a node named midi - Town.mid

and it contains 11 midi channel nodes which contain all the notes and timings for town.mid


if you inspect one of the channel nodes, you can see for instance 
that the slap bass plays note F# of the second octave at full velocity (127) at frame 518
Accidentally here the Daz Studio frame rate was 12 fps but 24 or 30 fps is recommended


Ok lets get back to animation

i select the 6ft tall cylinder

i start mcjMidiLoad

from the list of midi channels, i select the Slap Bass


I could select  a specific note as the source of animation

but instead i'll select the whole range of possible notes

So i leave the Notes/Drums selection at "Only In Range"

and i leave the note range at 0 to 127


The target is indeed the 6ft tall cylinder

and we decide to select the YScale of the cylinder as the property to animate

when the note velocity on the slap bass is 0% we want the YScale to be 50%
when the note velocity on the slap bass is 100% we want the YScale to be 150%


i press the "Assign channel to instrument" button and it's done

If i insist i'm pretty sure you'll agree that precise timing is essential, so we take extra care of it.

In Daz Studio we did set a frame rate of 30 fps

if we render frames 0 to 1350 as an .avi video and open it in virtualDub we discover that the real frame rate in the .avi file is 

30.303 ! wrong

In VirtualDub's "Video/Frame Rate" menu, we get to change it to exactly 30 fps

if in the  VirtualDub's  "Video"  menu, we set the "Direct Stream Copy" option, then saving this modified version of the video will take only a few seconds

else we could set the "Video / Compression" to a codec like DivX and obtain a good quality video and a smaller file


When i watch that video, yes i do see the cylinder move when the Slap Bass plays, 
but the notes are interfering with each other and its not clear what's happening
mcjMidiLoader version 004 will introduce the "OR" method, so the influence of each not will be cumulative
if note1 is on or note2 is on, the cylinder is scaled up, the cylinder scale goes down only if note 1 and note 2 are off 

Now lets do something fancy

Maybe you notice mf2t.exe came with t2mf.exe

we can build a midi file from a text file !

so i take town.mid.txt and delete all the tracks, except the first one and the Slap Bass track

and save this as townSlapBass.mid.txt


now i use a plain-text editor, notepad and create the following batch file named convertTextToMidi.bat


i drag and drop the  townSlapBass.mid.txt file onto convertTextToMidi.bat

and this created a midi file with just the slap-bass track!

and here's the result of all that work :)

You Shirley Will Be Elated ‎( mcjMidiLoad )‎




License

//===================================================================
// by mCasual/Jacques
//===================================================================
// Copyright (c) <2015> <mCasual/Jacques>
// You may use for commercial and non-commercial renders
// You may not sell, resell or lease or sublicense the script.
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//===================================================================

ċ
mcjMidiLoad - SuperSecretBetaJune0500h11.dsa
(64k)
mCasual Jacques,
Jun 4, 2015, 9:13 PM
ċ
mcjMidiLoad - SuperSecretBetaJune3.dsa
(64k)
mCasual Jacques,
Feb 24, 2018, 5:45 PM
ċ
mcjMidiLoad.zip
(16k)
mCasual Jacques,
Apr 19, 2015, 11:28 PM
ċ
mcjMidiLoadSuperSecretBetaJuly05.dsa
(71k)
mCasual Jacques,
Jul 5, 2015, 12:10 PM
ą
mCasual Jacques,
Jul 5, 2015, 12:10 PM
ċ
superSecretPreBetaLabUnitmcjMidiLoad.dsa
(50k)
mCasual Jacques,
May 20, 2015, 10:53 AM
ċ
mCasual Jacques,
May 20, 2015, 10:53 AM
Comments