Search in sources :

Example 1 with SubtimelineAudioClip

use of com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip in project tactview by helospark.

the class ReplaceTimelineWithSubtimelineCommand method execute.

@Override
public void execute() {
    synchronized (timelineManagerAccessor.getFullLock()) {
        SubtimelineVisualClip newVideoClip = null;
        SubtimelineAudioClip newAudioClip = null;
        if (projectRepository.isVideoInitialized()) {
            newVideoClip = subtimelineFromTimelineFactory.createSubtimelineVideoClipFromCurrentTimeline(exposedDescriptors);
        }
        if (projectRepository.isAudioInitialized()) {
            newAudioClip = subtimelineFromTimelineFactory.createSubtimelineAudioClipFromCurrentTimeline(exposedDescriptors);
        }
        for (var id : timelineManagerAccessor.getAllClipIds()) {
            TimelineChannel channel = timelineManagerAccessor.findChannelForClipId(id).get();
            TimelineClip clip = timelineManagerAccessor.findClipById(id).get().cloneClip(CloneRequestMetadata.fullCopy());
            clipsRemoved.add(new ChannelClipPair(channel, clip));
            timelineManagerAccessor.removeClip(id);
        }
        if (newVideoClip != null) {
            timelineManagerAccessor.addClip(timelineManagerAccessor.getChannels().get(0), newVideoClip);
            addedIds.add(newVideoClip.getId());
        }
        if (newAudioClip != null) {
            timelineManagerAccessor.addClip(timelineManagerAccessor.getChannels().get(1), newAudioClip);
            addedIds.add(newAudioClip.getId());
        }
        if (newVideoClip != null && newAudioClip != null) {
            linkClipRepository.linkClip(newVideoClip.getId(), newAudioClip.getId());
        }
    }
}
Also used : TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip)

Example 2 with SubtimelineAudioClip

use of com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip in project tactview by helospark.

the class TemplateSaveAndLoadHandler method queryAdditionalDataToSave.

protected void queryAdditionalDataToSave(Map<String, Object> result, SaveMetadata saveMetadata, SaveTemplateRequest saveTemplateRequest) {
    if (projectRepository.isVideoInitialized()) {
        SubtimelineVisualClip videoClip = subtimelineFromTimelineFactory.createSubtimelineVideoClipFromCurrentTimeline(saveTemplateRequest.getExposedDescriptors());
        result.put(VIDEO_TRACK_NODE, videoClip.generateSavedContent(saveMetadata));
    }
    if (projectRepository.isAudioInitialized()) {
        SubtimelineAudioClip audioClip = subtimelineFromTimelineFactory.createSubtimelineAudioClipFromCurrentTimeline(saveTemplateRequest.getExposedDescriptors());
        result.put(AUDIO_TRACK_NODE, audioClip.generateSavedContent(saveMetadata));
    }
    context.getListOfBeans(SaveLoadContributor.class).stream().filter(a -> !a.getClass().equals(TimelineManagerAccessor.class)).forEach(a -> a.generateSavedContent(result, saveMetadata));
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Component(com.helospark.lightdi.annotation.Component) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip) SubtimelineFromTimelineFactory(com.helospark.tactview.core.timeline.subtimeline.SubtimelineFromTimelineFactory) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) Map(java.util.Map) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) JsonNode(com.fasterxml.jackson.databind.JsonNode) ProjectRepository(com.helospark.tactview.core.repository.ProjectRepository) LightDiContext(com.helospark.lightdi.LightDiContext) File(java.io.File) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip)

Example 3 with SubtimelineAudioClip

use of com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip in project tactview by helospark.

the class SubtimelineFromTimelineFactory method createSubtimelineAudioClipFromCurrentTimeline.

public SubtimelineAudioClip createSubtimelineAudioClipFromCurrentTimeline(Set<ExposedDescriptorDescriptor> exposedDescriptors) {
    TimelineLength length = timelineManager.findEndPosition().toLength();
    AudioMediaMetadata metadata = AudioMediaMetadata.builder().withBitRate(timelineManager.findMaximumAudioBitRate()).withBytesPerSample(projectRepository.getBytesPerSample()).withChannels(projectRepository.getNumberOfChannels()).withLength(timelineManager.findEndPosition().toLength()).withSampleRate(projectRepository.getBytesPerSample()).build();
    SubtimelineAudioClip result = new SubtimelineAudioClip(metadata, timelineChannelsState.deepClone(CloneRequestMetadata.ofDefault()), timelineManagerAccessorFactory, subtimelineHelper, exposedDescriptors, TimelinePosition.ofZero(), length);
    result.setCreatorFactoryId(SubtimelineAudioClipFactory.ID);
    return result;
}
Also used : AudioMediaMetadata(com.helospark.tactview.core.decoder.AudioMediaMetadata) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) TimelineLength(com.helospark.tactview.core.timeline.TimelineLength)

Aggregations

SubtimelineAudioClip (com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip)3 SubtimelineVisualClip (com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 LightDiContext (com.helospark.lightdi.LightDiContext)1 Component (com.helospark.lightdi.annotation.Component)1 AudioMediaMetadata (com.helospark.tactview.core.decoder.AudioMediaMetadata)1 ProjectRepository (com.helospark.tactview.core.repository.ProjectRepository)1 TimelineChannel (com.helospark.tactview.core.timeline.TimelineChannel)1 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)1 TimelineLength (com.helospark.tactview.core.timeline.TimelineLength)1 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)1 SubtimelineFromTimelineFactory (com.helospark.tactview.core.timeline.subtimeline.SubtimelineFromTimelineFactory)1 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1