MIDI keyboard

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

MIDI keyboard // Scriptorium

1  2  |  

Post by Wigand // Jan 26, 2007, 11:39am

Wigand
Total Posts: 462
pic
So, my next project is ready to test.

It's a virtual-keyboard, to play MIDI-Notes on the screen

and hear the sound from your standard MIDI-device.



Some questions I still have:


1. I must go into the keys-object to play the keyboard. why?




2. I can see the keyboard (as recorded file) in TruePlay but can not play



3. Where is my object in modeler-mode?


TrueBlue! What is the trick?




The very important thing is the following:

You must register the MIDIClasse.dll into your registry.

The other way is, you must compile the MIDIClasse.vbp project.

It is written in VB6. I found it on http://www.vb-fun.de/vb/tipps/tip0325.shtml


I changed some things and compiled it as an ActiveXDLL.


I hope you are familiar with registering.

And I hope it works on your PC too.


This is the command for registering:


regsvr32 /i "YOURPATH\MIDIClasse.dll"


YOURPATH is where you copied the DLL.

Please let me know what happened.

But you test it on your own risk!

Post by trueBlue // Jan 26, 2007, 12:17pm

trueBlue
Total Posts: 1761
pic
1.) I was not able to play your scene because I received the following error:
RegSvr32
C:\Keyboard\MIDIClass.dll was loaded, but the DllInstal entry point was not found.
This file can not be registered.

2.) In your Objket.Name script Keyboard/T does not exist in your scene.

If (Objektname = scene +"/Keyboard/T") Then ' Change to /Keys/T64
Space.Select(System.ThisName())
End If

Post by Wigand // Jan 27, 2007, 4:03am

Wigand
Total Posts: 462
pic
I am sorry for this troubles, but it seems there is no way without

installation by a setup. It's now more like trial and error. :(

And this is one reason I put this thread into scriptorium. So I need

your help, to test this MIDI-interface on other systems.

On my PC there are already all these VB6 stuff and so I did not

realise all these problems you got.

Unfortunately the setup package is realy big.

Post by trueBlue // Jan 27, 2007, 7:44am

trueBlue
Total Posts: 1761
pic
I ran the setup but I do not understand German and so I am not sure if it is setup right. First picture is from setup and is the only one I was able to capture. Second picture is tS711 error when first loading the scene and selecting anything within the LE. Not sure what to do here Wigand. Maybe Emma can help in the translation and instructions on how to setup.

Post by Wigand // Jan 27, 2007, 9:11am

Wigand
Total Posts: 462
pic
Oh :o .

First Picture is MIDIClasse Setup

you must say "OK" . (the other option is "close Setup")

The next picture is a little confuse:


First you can choose a path


Then

you must select the quadratic Icon in the left upper corner

it's the picture with the computer in it.


This is all.

Post by trueBlue // Jan 27, 2007, 9:50am

trueBlue
Total Posts: 1761
pic
Okay I think :confused: I have it set up now because I can select keys without getting tS7 errors and I can see that they are being choosen in your panels but no sound. O Name does not seem to work though.

Post by trueBlue // Jan 27, 2007, 10:09am

trueBlue
Total Posts: 1761
pic
Yes I tried to re register the dll and get same error.

As for not being able to select keys without going inside Keys, it is working but you have Deactivate Widgets in code. Remember? To test that it works export SResult out and you can see that keys are being selected.

Post by Wigand // Jan 27, 2007, 10:17am

Wigand
Total Posts: 462
pic
Here are some of my registry keys. Please look in your regedit and search for

"MIDI_Out"


The first position is the following listed.

Here you must find the path where the DLL is.

If not, then the DLL is not registered.


If you have any other programming language where you can select

components (or Verweise?) you must find this new object in the list.

The name of the class is MIDIs.




[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}]

@="MIDIs.MIDI_Out"

"AppID"="{36CF3827-36F0-475D-AA2C-63318461297C}"


[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\Implemented Categories]


[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\Implemented Categories\{40FC6ED5-2438-11CF-A3DB-080036F12502}]


[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\InprocServer32]

@="H:\\Programme\\MIDIClasse\\MIDIClasse.dll"

"ThreadingModel"="Apartment"


[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\ProgID]

@="MIDIs.MIDI_Out"


[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\Programmable]


[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\TypeLib]

@="{D0CAF98D-9A10-434F-B989-73C3C48CD701}"


[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\VERSION]

@="3.0"

Post by Wigand // Jan 27, 2007, 10:21am

Wigand
Total Posts: 462
pic
Yes I tried to re register the dll and get same error.



As for not being able to select keys without going inside Keys, it is working but you have Deactivate Widgets in code. Remember? To test that it works export SResult out and you can see that keys are being selected.


I'm sorry, but I do not really understand you. ( It's my english)

Post by trueBlue // Jan 27, 2007, 10:26am

trueBlue
Total Posts: 1761
pic
I have same registry keys except last one reads Version 2.0

Post by Wigand // Jan 27, 2007, 10:48am

Wigand
Total Posts: 462
pic
Ok then you have registered it.

Is it possibel on your PC to hear MIDI-Files?

Did you select the right standard Midi device?


Maybe: "Microsoft GS Wavetable SW Synth"

(It's not possible on my pc because my onboard soundcard is corrupt"

Post by trueBlue // Jan 27, 2007, 11:06am

trueBlue
Total Posts: 1761
pic
Your Setup.exe installed to: C:\Program Files\MIDIClasse
Register path is: regsvr32 /i "C:\Program Files\MIDIClasse\MIDIClasse.dll"
Error:

Post by trueBlue // Jan 27, 2007, 11:09am

trueBlue
Total Posts: 1761
pic
Ok then you have registered it.
Is it possibel on your PC to hear MIDI-Files?
Did you select the right standard Midi device?

Maybe: "Microsoft GS Wavetable SW Synth"
(It's not possible on my pc because my onboard soundcard is corrupt"
Yes I can hear mid files
I have "Microsoft GS Wavetable SW Synth"

Post by Wigand // Jan 27, 2007, 11:11am

Wigand
Total Posts: 462
pic
can find an entry c:\WINXP\System32\MIDIClasse.dll


that is exactly what I find


Hast Du das in der Registry gefunden, in dem gleichen Registrypfad wie bei mir? Die anderen Schlüssel und werte müssten auch bei Dir drin stehen.

Kann natürlich noch sein, dass Dein MIDI-Gerät noch nicht richtig

aktiviert ist. In Multimedia bei Audio/Musikwiedergabe/Standardgerät

muss etwas funktionierendes drin stehen. Versuch mal das SambaPati-File

zu starten. Da müsstest du etwas hören. Bei mir öffnet sich der RealPlayer.

Bei dem weiß ich allerdings nicht ob der nicht vielleicht selbst einen

MIDI-Synthesizer enthält und nicht den "Microsoft GS Wavetable SW Synth" verwendet

Post by Wigand // Jan 27, 2007, 11:31am

Wigand
Total Posts: 462
pic
I'll check that - pruefe ich


Did convert Objekt.Name into jScript to have a chance checking the parameters


This is done with System.Alert(xxxxxxx)


Is ther anything similar in vBScript ?



Yes. You can also use a trace function to see parameters changing.



The value for scene is: /Project/Keyboard0


is that correct ?


Yes,I think so




function Execute(params)

{

scene = Space.CurrentScene()

Objektname = Node.FirstSelected()

params.conValue("N_Name") = Objektname;

Widgets.DeactivateDefaultWidgets();

System.Alert("Szene:"+scene);

penelay = scene +"/Keys/T64";

If (Objektname == penelay)

{ Space.Select(System.ThisName()); }

}



Now I found some other problems. The notes do not stop.

There is a


Pause =100 / 1000

t = Timer

Do

Loop Until Timer > t + Pause



MIDI.SendMIDIOut Zahl,0,144,0


This should set the velocity of the note to 0. Maybe there is a problem

with the timer in VBScript. I must test that.

Post by trueBlue // Jan 27, 2007, 12:36pm

trueBlue
Total Posts: 1761
pic
I'm sorry, but I do not really understand you. ( It's my english)
Here is what I was trying to show you.
I Exported SResult so that you could see Keys being selected without entering the Keys node.
I also added a cube to scene and changed the two scripts to select the Cube instead of Key T64. I was assuming that Key T64 has a MID note attached and so you most likely do not want that selected.

Note even though Registry shows correct keys, running the Registration script still shows error about DLLInstall Entry point. May be the key to why we can not here sound.

Post by trueBlue // Jan 28, 2007, 12:39am

trueBlue
Total Posts: 1761
pic
I just commented out what you did Emma and I get this error.

Post by Wigand // Jan 28, 2007, 2:37am

Wigand
Total Posts: 462
pic
There are some things about MIDI I have to mention.


1. TrueBlue: The message means, that the MIDI-Mapper is not

correct installed or already in use.

But it is send from the ActiveXDll, so it is already on your PC and works. :-)


2. If a Midi-note is send to a device it is done by

sending the note number (there is a little bug in my keyboard, the

c3 should have the number 60 I used 64 by fault, but it is not important

for the sound)


3. The velocity is send


4. The channel is send


In our program the parameters are in an other sequence:


MIDI.SendMIDIOut Notenumber,Velocity,NoteOn,Channel


5.Each NoteOn should have it's own NoteOff. This should be

done after the duration. (This is the problem Emma had.

The timer did not work, so the note was switched on and off

in such a short time that Emma could not hear the sound.)


MIDI.SendMIDIOut Notenumber,Velocity,NoteOff,Channel


There is also a command to switch off every note. I tried it, but

with no effort.

In the sript there is no possible way to play more than one note

at the same time. I think it is not really possible by

mouseclicking. ;)


Emma: how did you managed the installation, that now you hear the sound?

Post by Wigand // Jan 28, 2007, 3:06am

Wigand
Total Posts: 462
pic
Please try this one. I managed the problem with the NotesOff

Post by trueBlue // Jan 28, 2007, 5:45am

trueBlue
Total Posts: 1761
pic
Still no sound here. I see the trace though.

CRcActvPause::SetTimer
Start Tone
27736.25
27737.28
End Tone

Post by Wigand // Jan 28, 2007, 6:04am

Wigand
Total Posts: 462
pic
Still no sound here. I see the trace though.



CRcActvPause::SetTimer

Start Tone

27736.25

27737.28

End Tone



Do you have any other MIDI Software which works?

Did the MIDI-file play I posted?


If you got no more (german) errors by opening the device, I think the script

sents its data to the device. But something in your system could be wrong.

Post by trueBlue // Jan 28, 2007, 6:12am

trueBlue
Total Posts: 1761
pic
I turned up the volume all the way and still no sound.
Mid's play fine here.

Post by Wigand // Jan 28, 2007, 7:03am

Wigand
Total Posts: 462
pic
It is always important to close the MIDI before opening again.

If you stop the program between these two command, it can

happen that MIDI is still open.

Post by trueBlue // Jan 28, 2007, 7:16am

trueBlue
Total Posts: 1761
pic
Hey Wigand,
I have been messing around and using some of the code from Norm's VBLabyrinth script with your script and was wondering if this might be helpfull for you in your project. Also his MDarrayExample using ActiveXObject. May hold some important information there for you.
Here is the link for VBLabyrinth:
http://forums1.caligari.com/truespace/showthread.php?t=1390 (http://forums1.caligari.com/truespace/showthread.php?t=1390)

I can imagine when your project works like you hope that this could lead to all types of great senarios, like hooking up lights to your keyboard and changing the colors etc.. ect...etc... Can't wait!
Thanks for Sharing:jumpy:

Post by Wigand // Jan 28, 2007, 8:39am

Wigand
Total Posts: 462
pic
Hi Emma


Could it be, that you play MIDI with the internal MIDI-Player of your PC?

Maybe the volume setting is the main volume setting of the whole

MIDI-System.


There is also a command to change the master-volume, but it is not

implemented. You can change the volume of each tone by changing


MIDI.SendMIDIOut Zahl,100,144,0


to


MIDI.SendMIDIOut Zahl,127,144,0

Post by Wigand // Jan 28, 2007, 9:17am

Wigand
Total Posts: 462
pic
Hmm, is a bit mysterious, just have been away for the Abendessen and now the MIDI won't say anything. Had to start again the mediaplayer to get it back to work. Now mediaplayer is shut off and it works.

Had to change only the first 100, the one in the lower part of your script doesn't seem to influence this.


Is there possibly some kind of SYNc necessary ? shouldn't this be inside the DLL ?


The first one is the NoteOn command with the 144

The second is the NoteOff command with the 128


It doesn't matter how loud you stop the tone.


Do you use this script?


Dim Pause

Dim t

' OnComputeOutputs

' Called to compute values of all output connectors

Sub OnComputeOutputs(params)

Zahl = params.conValue("Zahl")


params.conValue("Ergebnis") = 1 ' Only to see wether it done something




If Zahl>42 and Zahl< 84 Then ' To limit the objects and to

'eliminate a tone with the number 0


Set MIDI= createobject("MIDIs.MIDI_Out") ' Create the object



MIDI.OpenMIDI ' Open MIDI

system.Trace("Start Ton") ' To see in Output Console

MIDI.SendMIDIOut Zahl,100,144,0 ' start the Note (command=144)

'number=Zahl

' With volume=100

' Channel=0

' MIDI.CloseMIDI




system.Trace(Timer) ' What does the timer


Pause =1

t = Timer

Do



Loop Until Timer > t + Pause


system.Trace(Timer) ' What does the timer



'MIDI.OpenMIDI


MIDI.SendMIDIOut Zahl,0,128,0 ' Stop the note(command=128)

'number=Zahl

'volume=0

'channel=0


MIDI.CloseMIDI ' Close MIDI

system.Trace("End Tone")

End If


params.conValue("Ergebnis") = 0 ' To show it is finished


End Sub



I am not sure about MIDI.Open and MIDI.Close.

But we should not leave MIDI open. But how it is possible, that an other

application (mediplayer) could use the same MIDI-Device. Usually it is

not possible I think. Maybe mediaplayer opens an other device.

You can also play with the channelnumber. There are 16 channels.

Each channel could be an other instrument.


The last version of the script had a bug. So the NoteOff did not work.

If it does not work correct it could overload the device. Because there are

only a limited count of notes to play simultan.

Post by trueBlue // Jan 28, 2007, 10:46am

trueBlue
Total Posts: 1761
pic
Emma I tried what you suggestion but I have yet to hear any sounds coming from the Keyboard and I have my volume all the way up.
The only thing I can think of is the error I get when I register the dll about the entry point.
If I understood the language when installing then I might be able to get this to work.

Post by trueBlue // Jan 28, 2007, 12:15pm

trueBlue
Total Posts: 1761
pic
Still no go!
Wigand disconnect the Pause Activity and see if it still works without the pause. Trace seems faster.

Post by trueBlue // Jan 28, 2007, 12:44pm

trueBlue
Total Posts: 1761
pic
Yahoo I have sound!

Post by trueBlue // Jan 28, 2007, 2:20pm

trueBlue
Total Posts: 1761
pic
Okay I am not 100% sure because I have been doing many things trying to get this to work but this is what I know for sure.

1.) Copied MIDIClasse.dll to C:\WINDOWS\SYSTEM32
2.) Registered MIDIClasse.dll to C:\WINDOWS\SYSTEM32.
Registry reads:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}]
@="MIDIs.MIDI_Out"
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\Implemented Categories]
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\Implemented Categories\{40FC6ED5-2438-11CF-A3DB-080036F12502}]
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\InprocServer32]
@="C:\\WINDOWS\\SYSTEM32\\MIDIClasse.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\ProgID]
@="MIDIs.MIDI_Out"
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\Programmable]
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\TypeLib]
@="{D0CAF98D-9A10-434F-B989-73C3C48CD701}"
[HKEY_CLASSES_ROOT\CLSID\{36CF3827-36F0-475D-AA2C-63318461297C}\VERSION]
@="2.0"

3.) Not only does Windows Media Player have to be opened you must play a MID file and then stop it but not close it. If you close WMP it does not work. If you open WMP without playing a MID file it does not work.

Note: I have disconnected the Pause Activity as well.
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn