. anyone using direct_media_change?
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    . anyone using direct_media_change?

    by anomad » Mon Jul 14, 2008 3:58 am

    . hello again!

    . i've been working on a module that takes a keyword via OSC and looks for images in a directory based on that keyword. if there are images in there, i want to load the images in banks 7 and 8.

    . i have the full path and filename, but don't understand how direct_media_change is supposed to work.

    . when i print tuple (called loadData) it looks like this:

    ('/Users/vj/google_images/keyword/010.jpg', 96)

    . 96 being the id of the upper left media slot of bank 7 (right?) and try to load the image:

    modul8.setValue('direct_media_change',loadData)

    . but nothing happens. any ideas, modul8 gurus? am i using the new keyword correctly? did i mess up my tuple?

    . thanks!

    -james
    (a nomad. )
  • videomasta
    member
    Posts: 24
    Joined: Thu Apr 05, 2007 5:35 pm

    by videomasta » Mon Jul 14, 2008 10:57 am

    modul8.setValue('direct_media_change',[theMediaPos, theFilePath],0)

    theMediaPos is the number inthe media set
    theFilePath ist the path of the new media

    hope it helps ;-)


    hey modul8 guys. we need a documentaion of the python codebase.
    it takes hours with trial and error to find out how it works.
    you are wasting our time ....

    you totally forgot to document the new keywords
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    by anomad » Tue Jul 15, 2008 5:08 am

    . brilliant! it works! :)

    . (and i agree about the documentation, too )

    . thank you for the quick answer.

    -james
    (a nomad. )
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    by anomad » Thu Jul 17, 2008 1:20 am

    . ok, it works - once.

    . i created a simple module, with a load button (loadImg) and a text entry area for the full path to the image directory (loadPath)

    . my goal is to load banks 7 and 8 with up to 31 images from the directory specified.

    . in Init() i import os, and set defaults for 'loadImg' and 'imgPath'

    . in MessageEvent() i have the following :

    Code: Select all

    if msg == 'loadImgs' :
       if param['value'] :
          # change debug to 1 to print info...
          debug = 1
          imgCount = 0
          if debug : print "looking for directory :", loadPath
          if os.path.isdir(loadPath) :
             for fn in os.listdir(loadPath):
                if imgCount < 32 :
                   loadData = (96 + imgCount),loadPath+"/"+fn
                   if debug : print "Found Image : ", loadData
                   modul8.setValue('direct_media_change',loadData,0)
                   imgCount+=1
    elif msg == 'loadPath' :
       loadPath = str(param['text'])

    . so, it checks if the path is a directory and then loads up to 31 images from it.

    . the first time i run the module (click my load button) - the images are loaded correctly in the correct positions

    . if i change to another directory, and click load, only the first image in that directory is loaded, although the print statements show that it sees all the files.

    . if i change to a third directory, all the images from the second directory get loaded into the media window and subsequently disappear!

    . if i click load again (attempting to load the third directory) the images thumbnails load in (but all have the red dot on them) and disappear right away.

    . if i re-compile and run the module, it exhibits the same 'briefly show the last requested images and then they disappear' behavior

    . is modul8 caching some of the data? a bug? if i quit modul8 and restart it, it will work once, but then not load anything else.

    . anyone have any ideas what's causing this?

    . thanks!
    -james
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    by anomad » Thu Jul 17, 2008 5:10 am

    . update!

    . ok, the code above seems to error out b/c i try and load bank 8, last media spot.

    . if i change

    Code: Select all

    loadData = (96 + imgCount),loadPath+"/"+fn


    . to

    Code: Select all

    loadData = imgCount,loadPath+"/"+fn


    . (load into bank 1 and 2, rather than 7 and 8 ) it works just fine!

    . now i know. :)
  • User avatar
    aalex
    junior Member
    Posts: 6
    Joined: Wed Jul 16, 2008 4:50 pm
    Location: Montréal, Québec, Canada
    Contact:

    by aalex » Thu Jul 17, 2008 5:48 am

    Hi!
    Thanks for this nice piece of code. Helps me get started.

    Did you get relative paths to work? I tried both "./images" and "images" with no success. I also tried this :

    Code: Select all

    import os

    tmp_path = "images"
    os.path.normpath(os.path.join(os.getcwd(), tmp_path))


    ...but it still doesn't work. It works in a standalone Python app, though. Maybe there is a Modul8 way to do it ?

    a
  • anomad
    master
    Posts: 412
    Joined: Sun Oct 21, 2007 10:07 pm
    Location: north cakalacky, usa
    Contact:

    by anomad » Fri Jul 18, 2008 12:03 am

    . nah... i used the absolute path (too many years as a linux admin, i guess :)

    . /Users/userid/images/ (where userid is the login id you're running Modul8 from)
  • User avatar
    aalex
    junior Member
    Posts: 6
    Joined: Wed Jul 16, 2008 4:50 pm
    Location: Montréal, Québec, Canada
    Contact:

    by aalex » Fri Jul 18, 2008 12:36 am

    Hello,
    I finally got it :

    Code: Select all

    import os
    print os.getenv('HOME')

    Yeah !

    :idea:

Who is online

Users browsing this forum: No registered users and 27 guests