[Bf-python] Sequence API adding Audio (RAM)

Glen Pike glen at engineeredarts.co.uk
Tue Nov 17 17:33:05 CET 2009


Hi,

    I am trying to work with some scripts that bulk import audio and add 
these files as Audio RAM strips.

    I can successfully add Audio HD strips, but when I try to add a 
loaded sound object, it does not appear to work.

    From looking at the source code in 
source\blender\python\api2_2x\sceneSequence.c I am assuming that I 
should just be able to pass the sound object returned by Sound.Load as 
the first parameter to seq.new
   
    It does not work though - can anyone tell me if I am doing something 
wrong, or if this does not work?

    Thanks

Glen

    Here is my code...

def loadSound(filename, library):
    global track
    sep = Blender.sys.sep
   
    sce = Scene.GetCurrent()
    seq = sce.sequence
    start = 1
  
    dirname = Blender.sys.dirname(library)
   
    audio_dir = Blender.sys.cleanpath(Blender.sys.expandpath(dirname + 
sep + ".." + sep + "audio files"))
    #print "loadSound ", dirname, " Audio dir ", audio_dir
   
    if 2 == Blender.sys.exists(audio_dir):
        to_load = audio_dir + sep + filename
        if 1 == Blender.sys.exists(to_load):
           
           #seq_data = ( filename, audio_dir, to_load, "audio_hd" )
           
            snd = Sound.Load(to_load)
            #This is the bit I am unsure about...
            seq_data = snd
            strip = seq.new(seq_data, start, track)
            strip.name = filename
            track = track + 1
            print "Strip ", strip
            #print "Sound ", type(snd), ":", dir(snd)
        else:
            print "File Does not exist ", to_load
    else:
        print "Audio dir does not exist ", audio_dir



More information about the Bf-python mailing list