Blender as a Vj-ing tool

Game Engine, Players & Web Plug-in, Virtual Reality, support for other engines

Moderators: jesterKing, stiv

levon
Posts: 0
Joined: Thu Jul 31, 2003 6:06 am
Location: adelaide

Post by levon »

hey pildanovak, ive tried your updated script, and it works fine for me in 2.33, but ofcourse someone has gone and changed something in 2.34 so it doesnt work now :P

one thing that might be a bug is that most the layers are doubled, like the ball on the 3 key, there are 2 of them and they are reversed ie, when one is in the bottom left the other is in the top right and so forth. and they are half transparent. not sure if that is a bug or wether it is intended.

do you have any plans of what you will be developing further?

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

for an answer to this, see http://www.blender.org/pipermail/bf-com ... 07163.html

(Pildanovak is using a property called 'position', which is built-in / reserved in 2.34 (i didn't know that either, but luckily had been using position1, position2 etc. - there's one other bug affecting my system though that we are trying to solve))

~Toni

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

i isolated the problem with 2.34 game-engine and my vjing system, the problem is in the object initializations. here's a minimal test case that demonstrates what seems to me like a bug, http://www.kyperjokki.fi/tools/inittest.blend (instructions included)

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

as discussed in the game-engine issues thread, that test case didn't work for other reasons (my misconception, thought that objects in hidden layers would be inited too but they aren't).

the problem was that using the addObject actuator with names fails in 2.34, which is problematic when the object-to-add is only in a hidden layer (even the newly added Scene module does not seem to give reference to those). the good news is that in the current CVS version and recent testing builds it works again, hence that mover thing does too.

Pildanovak, do you have some (working) version of BlenderVJ available? the link i found on your page was broken.

~Toni

pildanovak
Posts: 18
Joined: Fri Oct 25, 2002 9:32 am
Contact:

Post by pildanovak »

http://www.ffa.vutbr.cz/~novak/dwnflz/BlenderVj.zip

the pack contains:
blender directory with libraries, which should be copied in your blender directory.
BlenderVjClean.blend
Scenes directory with libraries.

to run BlenderVj, open BlenderVjClean, run the "append" script(loads correctly all .blend files from the Scenes directory), then run the engine(with the !1 scene active)

this is the link to the newest version.
the updates are>


the presets don't work now.

text input support. Look at the text library how to make scenes with text.
when pressing home key, the text input mode starts, with F1-f11 keys you can swich which text (of an text array, defined in the InitMidi script) is active, the keys now aren't active for sceneswitching, just for text input. Press home again to get back to the normal mode.

if there are more scenes then the keyboard covers, you can press F1-F11 keys to switch between libraries, Enter key writes the current key-scene mapping.

if you have no MIDI installed, try to install some virtual midi driver(MIDI YOKE is which i use). through this, you can use any virtual midi controller(PD, EYESWEB,Bomes midi keyboard http://www.bome.com/midi/keyboard/)
In InitMidi you can change the number of the device(in the midi section)

bobix
Posts: 0
Joined: Tue Mar 01, 2005 1:41 pm

Post by bobix »

Hello,
I am very interested with this research. I am student in master "art and numerical technology" and I works with "pure data" and "Blender".

I wish to carry out in real-time a character with an armature in 3d with blender which will be handled by information "midi" coming from "pure data".

I have to test "blendervjClean.blend" but I do not understand how to control in midi "blendervjClean.blend". I do not arrive at knowing with which channel and which controller I can control an animation.

could you specify this part of your research?

can be that you could help me on another problem. Would you know how one uses this script and to connect it to a sript "midi" in blender?

setChannel(channel, matrix, mode=0)
Parameters:
channel - A string specifying the name of the bone channel.
(type=string)
matrix - A 4x4 matrix specifying the overriding transformation as an offset from the bone's rest position.
(type=list [[float]])
mode - True for armature/world space, False for bone space
(type=boolean)
With this script I can normally handle a bone in real time.

I hope that my english is not too much bad... :oops:

bobix

levon
Posts: 0
Joined: Thu Jul 31, 2003 6:06 am
Location: adelaide

Post by levon »

its been a while sence ive touched this but i got midi into the GE with this code

Code: Select all

import midipy
import GameLogic
from types import ListType

#init midi
midi=midipy.getMidiInDevice()
#midipy.stopInDevice(midi[4])
#midipy.closeInDevice(midi[4])

#find how many midi devices there are
num_dev=midipy.getNumMidiInDevices()
if(num_dev<1):
	print "no midi devices found"

#finds what there called

midipy.openInDevice(midi[4])
midipy.startInDevice()


msg=midipy.returnMidiMsg()

# To get a controller:
co = GameLogic.getCurrentController()
own = co.getOwner()
# To get the game object associated with this controller:
obj = co.getActuator("act")
obj.setProperty("a")
if type(msg) is ListType:
	print msg[3]
	a = msg[3]/10
	own.a(a)

#print int(msg[3])
#print msg
#print dir(obj)
#obj.setDRot(0,3,0,1)
#print obj.getDRot()

midipy.stopInDevice(midi[4])
midipy.closeInDevice(midi[4])
though its been a while sence ive looked at the code, so i cant quite remeber how/what it does.

hope it is some help for you.

bobix
Posts: 0
Joined: Tue Mar 01, 2005 1:41 pm

Post by bobix »

thank you for your fast answer.
I will study the code.

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

i guess Pildanovak will be here to explain his work (BlenderVJ), but the idea there is that the provided clean .blend has the midi code and some other framework for controlling, and then the actual scenes are in other blends which are linked to the vj tool one, and then receive the controller values (that originate from midi, mouse etc.) via message actuators, that can then be made to control IPOs or whatever in that blend.

originally BlenderVJ did not have character animations, but i think Pildanovak has targeted them later, and with the framework you can surely control them.

the old KyperMover i made earlier, on the contrary, was focusing solely on character animations, and includes some nice trickery that enables using a basically unlimited amount of character animations (actions) in a single scene, of which a specified number can be run simultaneously.

KyperMover could be remade as a BlenderVJ module, but i haven't had the time.. dunno if will at some point. http://studio.kyperjokki.fi/engine/LiveBlender has a little on that .. i.e both BlenderVJ and KyperMover and the idea of unification

and under there http://studio.kyperjokki.fi/engine/kyperjokki.py has the CharacterAnimation class which does the dynamic allocation and re-use of animation actuators (in CharacterAnimation.begin() it seems). there is also a preliminary usage of the setChannel you mentioned. .. the code is from August 2003 when i was learning Python (well, still .. and hopefullyalways am *knocked-on-wood*) so it's kinda embarrassing, but hopefully helpful .. the documentation at http://an.org/gradu2/ includes an explanation of that CharacterAnimation class if it's useful, in chapter 'The Animation System --- working around GameBlender peculiarities' it seems :)

~Toni

pildanovak
Posts: 18
Joined: Fri Oct 25, 2002 9:32 am
Contact:

Post by pildanovak »

Hello, i haven't been here for a long time, so that's why i didn't reply.
I managed to get midi to Blender from eyesweb, with a very simple way, I'll find the file when i'm at home and will post it here too, you can then try out and look how it works. look at midipy help, which is somewhere on the net, you just need to read a midi message, which is a field of 5 numbers.

levon
Posts: 0
Joined: Thu Jul 31, 2003 6:06 am
Location: adelaide

Post by levon »

bobix: here is some more code i have been screwing round with, will probably help you understand it a bit better.

Code: Select all

import midipy 
import Blender
MidiChannel = 1
MidiInStop = 0
#for i in 5:
cubeob = Blender.Object.Get("Cube")

NameDefault = 'MidiWeb Client'

MidiInDevice = midipy.getMidiInDevice()
NumMidiInDevices = midipy.getNumMidiInDevices()
def MidiInDeviceRead(MidiIn):
    
    global MidiInStop
    global message
    global MidiInDevice
    
    midipy.openInDevice(MidiInDevice[MidiIn])
    midipy.setChannel('ALL')
    midipy.startInDevice()
    
    while 1:
        if MidiInStop == 1: break
        message=midipy.returnMidiMsg()
        if (message != -1):
			x,y,z = cubeob.getLocation()
			print message
			if message[2] == 14:
				cubeob.setLocation((message[3]/10),y,z)
			elif message[2] == 15:
				cubeob.setLocation(x,(message[3]/10),z)
			elif message[2] == 16:
				cubeob.setLocation(x,y,(message[3]/10))
			Blender.Redraw()
    midipy.stopInDevice()
    midipy.closeInDevice() 

def MessageParse(self, message):

    m = re.findall('\[([0-9,\sA-Za-z]+)\]', message)

def clear():

	midipy.stopInDevice()
	midipy.closeInDevice()
	print "clear"
	print "-------"
	print " "
	print " "
def main():

    MidiInDeviceRead(4)
    
    while 1:
    	while data:
    		MessageParse(self, data)
        	return message
        print "Lost connection\n"
clear()
main()
clear()
some times the clear function doesnt work so i have another script that does this:

Code: Select all

import midipy
midipy.stopInDevice()
midipy.closeInDevice()
print "clear"
print "-------"
print " "
print " "
and run that if it comes up with an error about line 18 being an unsubscriptable object. what the script will do is make the default cube 3d position be controlled but the midi controllers 14,15 and 16.

pildanovak have you had trouble with the refresh rate of the midi signal in your scripts?? in mine if i am moving more then 1 controller at a time one of them will refresh but the otherone wont.

bobix
Posts: 0
Joined: Tue Mar 01, 2005 1:41 pm

Post by bobix »

thanks for your reply!

...but... I'm novice and I don't know how it works!

1 - I open the script ".txt" in blender.
2 - I save this ".blend" in a folder with "midi.py"
3 - I launch "game blender"

And... nothing. what i need more to do ?

Can you explain me what I need exactly for that script works?

I 've install pyhon and blender. midi.py is in the blender's folder.

levon
Posts: 0
Joined: Thu Jul 31, 2003 6:06 am
Location: adelaide

Post by levon »

oh my script doesnt use the game engine, just create a new txt file in blender, paste my code into it and run it with ALT P.

and of course you will need the midipy .pyd in the blender dir. to exit the script you will have to open the console and press CTRL C

bobix
Posts: 0
Joined: Tue Mar 01, 2005 1:41 pm

Post by bobix »

that doesn't work with me...
however it is not complicated!
:(
'import site' failed; use -v for traceback
No installed Python found.
Only built-in modules are available. Some scripts may not run.
Continuing happily.
File "blendmidi.txt", line 57
return message
^
SyntaxError: invalid syntax

levon
Posts: 0
Joined: Thu Jul 31, 2003 6:06 am
Location: adelaide

Post by levon »

bobix wrote:that doesn't work with me...
however it is not complicated!
:(
'import site' failed; use -v for traceback
No installed Python found.
Only built-in modules are available. Some scripts may not run.
Continuing happily.
File "blendmidi.txt", line 57
return message
^
SyntaxError: invalid syntax
make sure you check the tabs and spaces, python doesnt like when you use both, and posting it in the web browser might have screwed them up.

Post Reply