Exemple #1
0
    def add_track(self, track_type, is_hidden=False):
        """ 
        Creates a MLT playlist object, adds project
        data and adds to tracks list.
        """
        new_track = mlt.Playlist()

        self._add_track_attributes(new_track, track_type)
        new_track.is_sync_track = False

        # Connect to MLT multitrack
        self.multitrack.connect(new_track, len(self.tracks))
        
        # Add to tracklist and set id to list index
        new_track.id = len(self.tracks)
        self.tracks.append(new_track)
        
        # Mix all audio to track 1 by combining them one after another 
        # using an always active field transition.
        if ((new_track.id > AUDIO_MIX_DOWN_TRACK) # black bg or track1 it's self does not need to be mixed
            and (is_hidden == False)): # We actually do want hidden track to cover all audio below, which happens if it is not mixed.
            self._mix_audio_for_track(new_track)
        
        # Add method that returns track name
        new_track.get_name = lambda : utils.get_track_name(new_track, self) 
        
        return new_track
Exemple #2
0
def _display_no_audio_on_video_msg(track):
    dialogutils.warning_message(
        _("Can't put an audio clip on a video track."),
        _("Track ")
        + utils.get_track_name(track, current_sequence())
        + _(" is a video track and can't display audio only material."),
        gui.editor_window.window,
    )
Exemple #3
0
def track_lock_check_and_user_info(track, calling_function="this ain't used anymore", actionname="this ain't used anymore"):
    if track.edit_freedom == appconsts.LOCKED:
        track_name = utils.get_track_name(track, current_sequence())

        # No edits on locked tracks.
        primary_txt = _("Can't edit a locked track")
        secondary_txt = _("Track ") + track_name + _(" is locked. Unlock track to edit it.")
        dialogutils.warning_message(primary_txt, secondary_txt, gui.editor_window.window)
        return True

    return False
Exemple #4
0
def download_songs(download_directory, song_list, aggressive=False):
    songs = []
    init()
    getToken()
    if not aggressive:
        time.sleep(3)
    try:
        for song in song_list:
            print "Searching for: %s by %s" % (song['title'], song['artist'])
            s = getResultsFromSearch("%s %s" % (song['title'], song['artist']))
            stream = getStreamKeyFromSongIDEx(s[0]["SongID"])
            for k, v in stream["result"].iteritems():
                stream = v
            title = s[0]["SongName"]
            artist = s[0]["ArtistName"]
            track_path = os.path.join(download_directory,
                                    get_track_name(title, artist))
            start_time = datetime.datetime.now()
            if not os.path.exists(track_path):
                wait_flag = True
                wgets = wget_template % (_useragent, _referer,
                                stream["streamKey"], track_path, stream["ip"])
                p = subprocess.Popen(wgets, shell=True)
                p.wait()
                try:
                    id3info = ID3(track_path)
                    id3info['TITLE'] = title
                    id3info['ARTIST'] = artist
                    id3info.write()
                    print 'ID3 tags written'
                except InvalidTagError, message:
                    print "Invalid ID3 tag:", message
            else:
                print 'File %s already exists' % track_path
            wait_flag = False
            if not aggressive and song != song_list[-1]:
                if wait_flag:
                    track_length = datetime.timedelta(
                                seconds=get_song_length(track_path))
                    end_time = datetime.datetime.now()
                    to_wait = track_length - (end_time - start_time)
                    to_wait = to_wait.total_seconds() + 2
                if not wait_flag:
                    to_wait = random.randrange(2, 6)
                print "Sleeping for %d seconds" % to_wait
                time.sleep(to_wait)
            songs.append({'path': track_path, 'name': title, 'artist': artist})

    except TypeError:
        print "Just got banned by grooveshark, stopping download "

    return songs
Exemple #5
0
def _track_is_locked(track):
    global drag_disabled
    if track.edit_freedom == appconsts.LOCKED:
        track_name = utils.get_track_name(track, current_sequence())
        # No edits on locked tracks.
        primary_txt = _("Can't do edit on a locked track")
        secondary_txt = _("Track ") + track_name + _(" is locked. Unlock track to edit it.\n")
        dialogutils.warning_message(primary_txt, secondary_txt, gui.editor_window.window)
        
        drag_disabled = True
        return True

    return False
Exemple #6
0
def _track_is_locked(track):
    global drag_disabled
    if track.edit_freedom == appconsts.LOCKED:
        track_name = utils.get_track_name(track, current_sequence())
        # No edits on locked tracks.
        primary_txt = _("Can't do edit on a locked track")
        secondary_txt = _("Track ") + track_name + _(
            " is locked. Unlock track to edit it.\n")
        dialogutils.warning_message(primary_txt, secondary_txt,
                                    gui.editor_window.window)

        drag_disabled = True
        return True

    return False
Exemple #7
0
def get_add_compositor_panel(current_sequence, data):
    clip, track, compositor_index, clip_index = data
    track_combo = Gtk.ComboBoxText()
    
    default_track_index = -1
    for i in range(current_sequence.first_video_index, track.id):
        add_track = current_sequence.tracks[i]
        text = "Track " + utils.get_track_name(add_track, current_sequence)
        track_combo.append_text(text)
        default_track_index += 1
    track_combo.set_active(default_track_index)
    track_combo.set_size_request(HALF_ROW_WIDTH, 30)

    vbox = Gtk.VBox(False, 2)
    vbox.pack_start(get_two_column_box(Gtk.Label(label=_("Composite clip on:")), track_combo), False, False, 0)
    return (vbox, track_combo)
Exemple #8
0
def get_add_compositor_panel(current_sequence, data):
    clip, track, compositor_index, clip_index = data
    track_combo = Gtk.ComboBoxText()
    
    default_track_index = -1
    for i in range(current_sequence.first_video_index, track.id):
        add_track = current_sequence.tracks[i]
        text = "Track " + utils.get_track_name(add_track, current_sequence)
        track_combo.append_text(text)
        default_track_index += 1
    track_combo.set_active(default_track_index)
    track_combo.set_size_request(HALF_ROW_WIDTH, 30)

    vbox = Gtk.VBox(False, 2)
    vbox.pack_start(get_two_column_box(Gtk.Label(label=_("Composite clip on:")), track_combo), False, False, 0)
    return (vbox, track_combo)
def _set_sync_parent_clip(event, frame):
    child_clip, child_index, child_clip_track = parent_selection_data
    parent_track = tlinewidgets.get_track(event.y)

    if parent_track != current_sequence().tracks[current_sequence().first_video_index]:
        dialogutils.warning_message(
            _("Sync parent clips must be on track V1"),
            _("Selected sync parent clip is on track ")
            + utils.get_track_name(parent_track, current_sequence())
            + _(".\nYou can only sync to clips that are on track V1."),
            gui.editor_window.window,
            True,
        )
        return

    # this can't have parent clip already
    if child_clip.sync_data != None:
        return

    if parent_track == None:
        return
    parent_clip_index = current_sequence().get_clip_index(parent_track, frame)
    if parent_clip_index == -1:
        return

    # Parent and child can't be on the same track.
    # Now that all parent clips must be on track V1 this is no longer shoild be possible.
    if parent_track == child_clip_track:
        print "parent_track == child_clip_track"
        return

    parent_clip = parent_track.clips[parent_clip_index]

    # These cannot be chained.
    # Now that all parent clips must be on track V1 this is no longer shoild be possible.
    if parent_clip.sync_data != None:
        print "parent_clip.sync_data != None"
        return

    data = {
        "child_index": child_index,
        "child_track": child_clip_track,
        "parent_index": parent_clip_index,
        "parent_track": parent_track,
    }
    action = edit.set_sync_action(data)
    action.do_edit()
Exemple #10
0
def _set_sync_parent_clip(event, frame):
    child_clip, child_index, child_clip_track = parent_selection_data
    parent_track = tlinewidgets.get_track(event.y)

    if parent_track != current_sequence().tracks[
            current_sequence().first_video_index]:
        dialogutils.warning_message(
            _("Sync parent clips must be on track V1"),
            _("Selected sync parent clip is on track ") +
            utils.get_track_name(parent_track, current_sequence()) +
            _(".\nYou can only sync to clips that are on track V1."),
            gui.editor_window.window, True)
        return

    # this can't have parent clip already
    if child_clip.sync_data != None:
        return

    if parent_track == None:
        return
    parent_clip_index = current_sequence().get_clip_index(parent_track, frame)
    if parent_clip_index == -1:
        return

    # Parent and child can't be on the same track.
    # Now that all parent clips must be on track V1 this is no longer shoild be possible.
    if parent_track == child_clip_track:
        print "parent_track == child_clip_track"
        return

    parent_clip = parent_track.clips[parent_clip_index]

    # These cannot be chained.
    # Now that all parent clips must be on track V1 this is no longer shoild be possible.
    if parent_clip.sync_data != None:
        print "parent_clip.sync_data != None"
        return

    data = {
        "child_index": child_index,
        "child_track": child_clip_track,
        "parent_index": parent_clip_index,
        "parent_track": parent_track
    }
    action = edit.set_sync_action(data)
    action.do_edit()
Exemple #11
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.connect("delete-event", lambda w, e:close_audio_monitor())
        
        seq = editorstate.current_sequence()
        meters_count = 1 + (len(seq.tracks) - 2) # master + editable tracks
        self.gain_controls = []
        
        self.meters_area = MetersArea(meters_count)
        gain_control_area = gtk.HBox(False, 0)
        seq = editorstate.current_sequence()
        for i in range(0, meters_count):
            if i == 0:
                name = _("Master")
                gain = GainControl(name, seq, seq.tractor, True)
            else:
                name = utils.get_track_name(seq.tracks[i], seq)
                gain = GainControl(name, seq, seq.tracks[i])
            if i == 0:
                tmp = gain
                gain = gtk.EventBox()
                gain.add(tmp)
                bg_color = gtk.gdk.Color(red=0.8, green=0.8, blue=0.8)
                if editorpersistance.prefs.dark_theme == True:
                    bg_color = gtk.gdk.Color(red=0.4, green=0.4, blue=0.4)
                gain.modify_bg(gtk.STATE_NORMAL, bg_color)
            self.gain_controls.append(gain)
            gain_control_area.pack_start(gain, False, False, 0)

        meters_frame = gtk.Frame()
        meters_frame.add(self.meters_area.widget)

        pane = gtk.VBox(False, 1)
        pane.pack_start(meters_frame, True, True, 0)
        pane.pack_start(gain_control_area, True, True, 0)

        align = gtk.Alignment()
        align.set_padding(12, 12, 4, 4)
        align.add(pane)

        # Set pane and show window
        self.add(align)
        self.set_title(_("Audio Mixer"))
        self.show_all()
        self.set_resizable(False)
        self.set_keep_above(True) # Perhaps configurable later
Exemple #12
0
    def __init__(self):
        GObject.GObject.__init__(self)
        self.connect("delete-event", lambda w, e:close_audio_monitor())
        
        seq = editorstate.current_sequence()
        meters_count = 1 + (len(seq.tracks) - 2) # master + editable tracks
        self.gain_controls = []
        
        self.meters_area = MetersArea(meters_count)
        gain_control_area = Gtk.HBox(False, 0)
        seq = editorstate.current_sequence()
        for i in range(0, meters_count):
            if i == 0:
                name = _("Master")
                gain = GainControl(name, seq, seq.tractor, True)
            else:
                name = utils.get_track_name(seq.tracks[i], seq)
                gain = GainControl(name, seq, seq.tracks[i])
            #if i == 0:
            #    tmp = gain # for bg color ?
            #    gain = Gtk.EventBox() # for bg color ?
            #    gain.add(tmp) # for bg color ?
            self.gain_controls.append(gain)
            gain_control_area.pack_start(gain, False, False, 0)

        meters_frame = Gtk.Frame()
        meters_frame.add(self.meters_area.widget)

        pane = Gtk.VBox(False, 1)
        pane.pack_start(meters_frame, True, True, 0)
        pane.pack_start(gain_control_area, True, True, 0)

        align = Gtk.Alignment.new(0.5, 0.5, 1.0, 1.0)
        align.set_padding(12, 12, 4, 4)
        align.add(pane)

        # Set pane and show window
        self.add(align)
        self.set_title(_("Audio Mixer"))
        self.show_all()
        self.set_resizable(False)
        self.set_keep_above(True) # Perhaps configurable later
Exemple #13
0
    def __init__(self):
        GObject.GObject.__init__(self)
        self.connect("delete-event", lambda w, e: close_audio_monitor())

        seq = editorstate.current_sequence()
        meters_count = 1 + (len(seq.tracks) - 2)  # master + editable tracks
        self.gain_controls = []

        self.meters_area = MetersArea(meters_count)
        gain_control_area = Gtk.HBox(False, 0)
        seq = editorstate.current_sequence()
        for i in range(0, meters_count):
            if i == 0:
                name = _("Master")
                gain = GainControl(name, seq, seq.tractor, True)
            else:
                name = utils.get_track_name(seq.tracks[i], seq)
                gain = GainControl(name, seq, seq.tracks[i])
            #if i == 0:
            #    tmp = gain # for bg color ?
            #    gain = Gtk.EventBox() # for bg color ?
            #    gain.add(tmp) # for bg color ?
            self.gain_controls.append(gain)
            gain_control_area.pack_start(gain, False, False, 0)

        meters_frame = Gtk.Frame()
        meters_frame.add(self.meters_area.widget)

        pane = Gtk.VBox(False, 1)
        pane.pack_start(meters_frame, True, True, 0)
        pane.pack_start(gain_control_area, True, True, 0)

        align = guiutils.set_margins(pane, 12, 12, 4, 4)

        # Set pane and show window
        self.add(align)
        self.set_title(_("Audio Mixer"))
        self.show_all()
        self.set_resizable(False)
        self.set_keep_above(True)  # Perhaps configurable later
Exemple #14
0
def _display_no_audio_on_video_msg(track):
    dialogutils.warning_message(
        _("Can't put an audio clip on a video track."),
        _("Track ") + utils.get_track_name(track, current_sequence()) +
        _(" is a video track and can't display audio only material."),
        gui.editor_window.window)