From 6bcd28aca5fd4a0c73263af08a850959eace143a Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 1 Jun 2018 01:14:42 -0500 Subject: [PATCH 01/13] Integration of gitlab branch support --- .gitlab-ci.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e391aa04..01962d26 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ linux-builder: paths: - build/install-x64/* script: - - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN 'http://gitlab.openshot.org/jonathan/libopenshot-audio/-/jobs/artifacts/master/download?job=linux-builder'" + - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=linux-builder" - unzip artifacts.zip - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 - mkdir -p build; cd build; @@ -23,6 +23,7 @@ linux-builder: - linux only: - master + - release mac-builder: stage: build-libopenshot @@ -31,7 +32,7 @@ mac-builder: paths: - build/install-x64/* script: - - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN 'http://gitlab.openshot.org/jonathan/libopenshot-audio/-/jobs/artifacts/master/download?job=mac-builder'" + - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=mac-builder" - unzip artifacts.zip - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 - mkdir -p build; cd build; @@ -45,6 +46,7 @@ mac-builder: - mac only: - master + - release windows-builder-x86: stage: build-libopenshot @@ -53,7 +55,7 @@ windows-builder-x86: paths: - build\install-x86\* script: - - Invoke-WebRequest -Uri "http://gitlab.openshot.org/jonathan/libopenshot-audio/-/jobs/artifacts/master/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" + - Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" - Expand-Archive -Path artifacts.zip -DestinationPath . - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x86" - $env:UNITTEST_DIR = "C:\msys32\usr" @@ -71,6 +73,7 @@ windows-builder-x86: - windows only: - master + - release windows-builder-x64: stage: build-libopenshot @@ -79,7 +82,7 @@ windows-builder-x64: paths: - build\install-x64\* script: - - Invoke-WebRequest -Uri "http://gitlab.openshot.org/jonathan/libopenshot-audio/-/jobs/artifacts/master/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" + - Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" - Expand-Archive -Path artifacts.zip -DestinationPath . - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x64" - $env:UNITTEST_DIR = "C:\msys64\usr" @@ -97,14 +100,16 @@ windows-builder-x64: - windows only: - master + - release trigger-pipeline: stage: trigger-openshot-qt script: - - "curl -X POST -F token=$OPENSHOT_QT_PIPELINE_TOKEN -F ref=master http://gitlab.openshot.org/api/v4/projects/3/trigger/pipeline" + - "curl -X POST -F token=$OPENSHOT_QT_PIPELINE_TOKEN -F ref=$CI_COMMIT_REF_NAME http://gitlab.openshot.org/api/v4/projects/3/trigger/pipeline" when: always dependencies: [] tags: - linux only: - - master \ No newline at end of file + - master + - release \ No newline at end of file From 25d536a79b51dc617fbf2cf01ec9ebb04ba6a3a5 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 1 Jun 2018 01:14:59 -0500 Subject: [PATCH 02/13] Bumping version to 0.2.0 (so 15) --- include/Version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Version.h b/include/Version.h index cd72ab20..971d5cfe 100644 --- a/include/Version.h +++ b/include/Version.h @@ -35,9 +35,9 @@ #endif #define OPENSHOT_VERSION_MAJOR 0; /// Major version number is incremented when huge features are added or improved. -#define OPENSHOT_VERSION_MINOR 1; /// Minor version is incremented when smaller (but still very important) improvements are added. -#define OPENSHOT_VERSION_BUILD 9; /// Build number is incremented when minor bug fixes and less important improvements are added. -#define OPENSHOT_VERSION_SO 14; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) +#define OPENSHOT_VERSION_MINOR 2; /// Minor version is incremented when smaller (but still very important) improvements are added. +#define OPENSHOT_VERSION_BUILD 0; /// Build number is incremented when minor bug fixes and less important improvements are added. +#define OPENSHOT_VERSION_SO 15; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) #define OPENSHOT_VERSION_MAJOR_MINOR STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR); /// A string of the "Major.Minor" version #define OPENSHOT_VERSION_ALL STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR) "." STRINGIZE(OPENSHOT_VERSION_BUILD); /// A string of the entire version "Major.Minor.Build" From 2db0d91e2b364d7c9b935c4b642740ac3e61cdbf Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 1 Jun 2018 01:37:09 -0500 Subject: [PATCH 03/13] Updating gitlab CI to support git flow (develop, release, master + tag) --- .gitlab-ci.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 01962d26..e93c2167 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,8 +22,9 @@ linux-builder: tags: - linux only: - - master + - develop - release + - tags mac-builder: stage: build-libopenshot @@ -45,8 +46,9 @@ mac-builder: tags: - mac only: - - master + - develop - release + - tags windows-builder-x86: stage: build-libopenshot @@ -72,8 +74,9 @@ windows-builder-x86: tags: - windows only: - - master + - develop - release + - tags windows-builder-x64: stage: build-libopenshot @@ -99,8 +102,9 @@ windows-builder-x64: tags: - windows only: - - master + - develop - release + - tags trigger-pipeline: stage: trigger-openshot-qt @@ -111,5 +115,6 @@ trigger-pipeline: tags: - linux only: - - master - - release \ No newline at end of file + - develop + - release + - tags \ No newline at end of file From 1c71659e94632e571ec06e1c5a6e48523360d521 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Wed, 6 Jun 2018 03:56:02 -0500 Subject: [PATCH 04/13] Prevent a negative starting sample when adding audio to a frame (cherry picked from commit 0327143) --- src/Frame.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index 0ff8f0cc..cd3bbc7c 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -839,8 +839,11 @@ void Frame::AddAudio(bool replaceSamples, int destChannel, int destStartSample, const GenericScopedLock lock(addingAudioSection); #pragma omp critical (adding_audio) { + // Clamp starting sample to 0 + int destStartSampleAdjusted = max(destStartSample, 0); + // Extend audio container to hold more (or less) samples and channels.. if needed - int new_length = destStartSample + numSamples; + int new_length = destStartSampleAdjusted + numSamples; int new_channel_length = audio->getNumChannels(); if (destChannel >= new_channel_length) new_channel_length = destChannel + 1; @@ -849,7 +852,7 @@ void Frame::AddAudio(bool replaceSamples, int destChannel, int destStartSample, // Clear the range of samples first (if needed) if (replaceSamples) - audio->clear(destChannel, destStartSample, numSamples); + audio->clear(destChannel, destStartSampleAdjusted, numSamples); // Get max volume of the current audio data // TODO: This always appears to be 0, which is probably not expected since that means gainFactor is always multiplied by 1.0 below. @@ -857,7 +860,7 @@ void Frame::AddAudio(bool replaceSamples, int destChannel, int destStartSample, // which makes "gainFactor *= ((current_max_volume + new_max_volume) - (current_max_volume * new_max_volume)) / sum_volumes;" // which simplifies to "gainFactor *= new_max_volume / new_max_volume;" aka "gainFactor *= 1.0" // - Rich Alloway - float current_max_volume = audio->getMagnitude(destChannel, destStartSample, numSamples); + float current_max_volume = audio->getMagnitude(destChannel, destStartSampleAdjusted, numSamples); // Determine max volume of new audio data (before we add them together) float new_max_volume = 0.0; @@ -877,7 +880,7 @@ void Frame::AddAudio(bool replaceSamples, int destChannel, int destStartSample, } // Add samples to frame's audio buffer - audio->addFrom(destChannel, destStartSample, source, numSamples, gainFactor); + audio->addFrom(destChannel, destStartSampleAdjusted, source, numSamples, gainFactor); has_audio_data = true; // Calculate max audio sample added From 06b244f19aa8b442198677b5dd7161388bac7f10 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 7 Jun 2018 16:58:31 -0500 Subject: [PATCH 05/13] Updating release branch from develop --- .gitlab-ci.yml | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e93c2167..9760ad31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,10 @@ linux-builder: paths: - build/install-x64/* script: - - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=linux-builder" + - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=linux-builder" + - if [ ! -f artifacts.zip ]; then + - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=linux-builder" + - fi - unzip artifacts.zip - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 - mkdir -p build; cd build; @@ -21,10 +24,6 @@ linux-builder: when: always tags: - linux - only: - - develop - - release - - tags mac-builder: stage: build-libopenshot @@ -33,7 +32,10 @@ mac-builder: paths: - build/install-x64/* script: - - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=mac-builder" + - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=mac-builder" + - if [ ! -f artifacts.zip ]; then + - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=mac-builder" + - fi - unzip artifacts.zip - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 - mkdir -p build; cd build; @@ -45,10 +47,6 @@ mac-builder: when: always tags: - mac - only: - - develop - - release - - tags windows-builder-x86: stage: build-libopenshot @@ -58,6 +56,7 @@ windows-builder-x86: - build\install-x86\* script: - Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" + - if (-not (Test-Path "artifacts.zip")) { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } - Expand-Archive -Path artifacts.zip -DestinationPath . - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x86" - $env:UNITTEST_DIR = "C:\msys32\usr" @@ -73,10 +72,6 @@ windows-builder-x86: when: always tags: - windows - only: - - develop - - release - - tags windows-builder-x64: stage: build-libopenshot @@ -86,6 +81,7 @@ windows-builder-x64: - build\install-x64\* script: - Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" + - if (-not (Test-Path "artifacts.zip")) { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } - Expand-Archive -Path artifacts.zip -DestinationPath . - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x64" - $env:UNITTEST_DIR = "C:\msys64\usr" @@ -101,10 +97,6 @@ windows-builder-x64: when: always tags: - windows - only: - - develop - - release - - tags trigger-pipeline: stage: trigger-openshot-qt @@ -113,8 +105,4 @@ trigger-pipeline: when: always dependencies: [] tags: - - linux - only: - - develop - - release - - tags \ No newline at end of file + - linux \ No newline at end of file From 04e4f63ea816fc7c722bcf42b7153c3143894424 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 12:02:21 -0700 Subject: [PATCH 06/13] Calculate max volume of all overlapping clips, and scale clip volume to fit within the 100%, to prevent popping --- include/Timeline.h | 2 +- src/Frame.cpp | 27 +-------------------------- src/Timeline.cpp | 30 +++++++++++++++++------------- 3 files changed, 19 insertions(+), 40 deletions(-) diff --git a/include/Timeline.h b/include/Timeline.h index 55adc3cd..ed5c2ab3 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -153,7 +153,7 @@ namespace openshot { CacheBase *final_cache; /// new_frame, Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip); + void add_layer(std::shared_ptr new_frame, Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip, float max_volume); /// Apply a FrameMapper to a clip which matches the settings of this timeline void apply_mapper_to_clip(Clip* clip); diff --git a/src/Frame.cpp b/src/Frame.cpp index cd3bbc7c..16a0d267 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -854,33 +854,8 @@ void Frame::AddAudio(bool replaceSamples, int destChannel, int destStartSample, if (replaceSamples) audio->clear(destChannel, destStartSampleAdjusted, numSamples); - // Get max volume of the current audio data - // TODO: This always appears to be 0, which is probably not expected since that means gainFactor is always multiplied by 1.0 below. - // "sum_volumes = current_max_volume + new_max_volume" is then alwasy "sum_volumes = 0 + new_max_volume", - // which makes "gainFactor *= ((current_max_volume + new_max_volume) - (current_max_volume * new_max_volume)) / sum_volumes;" - // which simplifies to "gainFactor *= new_max_volume / new_max_volume;" aka "gainFactor *= 1.0" - // - Rich Alloway - float current_max_volume = audio->getMagnitude(destChannel, destStartSampleAdjusted, numSamples); - - // Determine max volume of new audio data (before we add them together) - float new_max_volume = 0.0; - for (int sample=0; sample new_max_volume) - new_max_volume = source[sample]; - } - - // Determine volume adjustments (to prevent overflows) - float sum_volumes = current_max_volume + new_max_volume; - float gainFactor = gainToApplyToSource; - if (sum_volumes > 0.0) { - // Reduce both sources by this amount (existing samples and new samples) - gainFactor *= ((current_max_volume + new_max_volume) - (current_max_volume * new_max_volume)) / sum_volumes; - audio->applyGain(gainFactor); - ZmqLogger::Instance()->AppendDebugMethod("Frame::AddAudio", "gainToApplyToSource", gainToApplyToSource, "gainFactor", gainFactor, "sum_volumes", sum_volumes, "current_max_volume", current_max_volume, "new_max_volume", new_max_volume, "((current_max_volume + new_max_volume) - (current_max_volume * new_max_volume)) / sum_volumes", ((current_max_volume + new_max_volume) - (current_max_volume * new_max_volume)) / sum_volumes); - } - // Add samples to frame's audio buffer - audio->addFrom(destChannel, destStartSampleAdjusted, source, numSamples, gainFactor); + audio->addFrom(destChannel, destStartSampleAdjusted, source, numSamples, gainToApplyToSource); has_audio_data = true; // Calculate max audio sample added diff --git a/src/Timeline.cpp b/src/Timeline.cpp index b2f370ba..57803640 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -245,7 +245,7 @@ std::shared_ptr Timeline::GetOrCreateFrame(Clip* clip, int64_t number) } // Process a new layer of video or audio -void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip) +void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, int64_t clip_frame_number, int64_t timeline_frame_number, bool is_top_clip, float max_volume) { // Get the clip's frame & image std::shared_ptr source_frame; @@ -288,6 +288,9 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in /* COPY AUDIO - with correct volume */ if (source_clip->Reader()->info.has_audio) { + // Protect max_volume (if negative or zero, default max_volume to 1.0, which will not adjust volume) + if (max_volume <= 0.0) + max_volume = 1.0; // Debug output ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Copy Audio)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number, "", -1); @@ -295,9 +298,8 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in if (source_frame->GetAudioChannelsCount() == info.channels && source_clip->has_audio.GetInt(clip_frame_number) != 0) for (int channel = 0; channel < source_frame->GetAudioChannelsCount(); channel++) { - float initial_volume = 1.0f; - float previous_volume = source_clip->volume.GetValue(clip_frame_number - 1); // previous frame's percentage of volume (0 to 1) - float volume = source_clip->volume.GetValue(clip_frame_number); // percentage of volume (0 to 1) + float previous_volume = source_clip->volume.GetValue(clip_frame_number - 1) / max_volume; // previous frame's percentage of volume (0 to 1) + float volume = source_clip->volume.GetValue(clip_frame_number) / max_volume; // percentage of volume (0 to 1) int channel_filter = source_clip->channel_filter.GetInt(clip_frame_number); // optional channel to filter (if not -1) int channel_mapping = source_clip->channel_mapping.GetInt(clip_frame_number); // optional channel to map this channel to (if not -1) @@ -313,12 +315,8 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in if (channel_mapping == -1) channel_mapping = channel; - // If no ramp needed, set initial volume = clip's volume - if (isEqual(previous_volume, volume)) - initial_volume = volume; - // Apply ramp to source frame (if needed) - if (!isEqual(previous_volume, volume)) + if (!isEqual(previous_volume, 1.0) || !isEqual(volume, 1.0)) source_frame->ApplyGainRamp(channel_mapping, 0, source_frame->GetAudioSamplesCount(), previous_volume, volume); // TODO: Improve FrameMapper (or Timeline) to always get the correct number of samples per frame. @@ -333,7 +331,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in // Copy audio samples (and set initial volume). Mix samples with existing audio samples. The gains are added together, to // be sure to set the gain's correctly, so the sum does not exceed 1.0 (of audio distortion will happen). #pragma omp critical (T_addLayer) - new_frame->AddAudio(false, channel_mapping, 0, source_frame->GetAudioSamples(channel), source_frame->GetAudioSamplesCount(), initial_volume); + new_frame->AddAudio(false, channel_mapping, 0, source_frame->GetAudioSamples(channel), source_frame->GetAudioSamplesCount(), 1.0); } else @@ -757,17 +755,23 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) { // Determine if clip is "top" clip on this layer (only happens when multiple clips are overlapping) bool is_top_clip = true; + float max_volume = 0.0; for (int top_clip_index = 0; top_clip_index < nearby_clips.size(); top_clip_index++) { Clip *nearby_clip = nearby_clips[top_clip_index]; long nearby_clip_start_position = round(nearby_clip->Position() * info.fps.ToDouble()) + 1; long nearby_clip_end_position = round((nearby_clip->Position() + nearby_clip->Duration()) * info.fps.ToDouble()) + 1; + long nearby_clip_start_frame = (nearby_clip->Start() * info.fps.ToDouble()) + 1; + long nearby_clip_frame_number = frame_number - nearby_clip_start_position + nearby_clip_start_frame; if (clip->Id() != nearby_clip->Id() && clip->Layer() == nearby_clip->Layer() && nearby_clip_start_position <= frame_number && nearby_clip_end_position >= frame_number && - nearby_clip_start_position > clip_start_position) { + nearby_clip_start_position > clip_start_position && is_top_clip == true) { is_top_clip = false; - break; + } + + if (nearby_clip_start_position <= frame_number && nearby_clip_end_position >= frame_number) { + max_volume += nearby_clip->volume.GetValue(nearby_clip_frame_number); } } @@ -779,7 +783,7 @@ std::shared_ptr Timeline::GetFrame(int64_t requested_frame) ZmqLogger::Instance()->AppendDebugMethod("Timeline::GetFrame (Calculate clip's frame #)", "clip->Position()", clip->Position(), "clip->Start()", clip->Start(), "info.fps.ToFloat()", info.fps.ToFloat(), "clip_frame_number", clip_frame_number, "", -1, "", -1); // Add clip's frame as layer - add_layer(new_frame, clip, clip_frame_number, frame_number, is_top_clip); + add_layer(new_frame, clip, clip_frame_number, frame_number, is_top_clip, max_volume); } else // Debug output From fa59962bff8f0792455d8e57135c34a5d69f990c Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 15:14:19 -0700 Subject: [PATCH 07/13] Make linux build manual, and remove error flag from curl --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9760ad31..127bdf99 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,9 +9,9 @@ linux-builder: paths: - build/install-x64/* script: - - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=linux-builder" + - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=linux-builder" - if [ ! -f artifacts.zip ]; then - - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=linux-builder" + - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=linux-builder" - fi - unzip artifacts.zip - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 @@ -21,7 +21,7 @@ linux-builder: - make install - cp src/bindings/python/*openshot* install-x64/lib - echo -e "CI_PROJECT_NAME:$CI_PROJECT_NAME\nCI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME\nCI_COMMIT_SHA:$CI_COMMIT_SHA\nCI_JOB_ID:$CI_JOB_ID" > "install-x64/share/$CI_PROJECT_NAME" - when: always + when: manual tags: - linux @@ -32,9 +32,9 @@ mac-builder: paths: - build/install-x64/* script: - - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=mac-builder" + - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=mac-builder" - if [ ! -f artifacts.zip ]; then - - "curl -f -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=mac-builder" + - "curl -O -J -L --header PRIVATE-TOKEN:$ACCESS_TOKEN http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=mac-builder" - fi - unzip artifacts.zip - export LIBOPENSHOT_AUDIO_DIR=$CI_PROJECT_DIR/build/install-x64 From 322478f781a5a1c15c3af6ec879b7079a398d838 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 15:31:45 -0700 Subject: [PATCH 08/13] Make trigger use gitlab runner --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 127bdf99..f0903820 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -105,4 +105,4 @@ trigger-pipeline: when: always dependencies: [] tags: - - linux \ No newline at end of file + - gitlab \ No newline at end of file From b17bc83eaebe0ca100eab197258242a4842656c9 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 16:14:10 -0700 Subject: [PATCH 09/13] Make windows artifact downloads not error on 404 --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0903820..54346930 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,7 +55,7 @@ windows-builder-x86: paths: - build\install-x86\* script: - - Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" + - try { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } catch { $_.Exception.Response.StatusCode.Value__ } - if (-not (Test-Path "artifacts.zip")) { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=windows-builder-x86" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } - Expand-Archive -Path artifacts.zip -DestinationPath . - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x86" @@ -80,7 +80,7 @@ windows-builder-x64: paths: - build\install-x64\* script: - - Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" + - try { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } catch { $_.Exception.Response.StatusCode.Value__ } - if (-not (Test-Path "artifacts.zip")) { Invoke-WebRequest -Uri "http://gitlab.openshot.org/OpenShot/libopenshot-audio/-/jobs/artifacts/develop/download?job=windows-builder-x64" -Headers @{"PRIVATE-TOKEN"="$ACCESS_TOKEN"} -OutFile "artifacts.zip" } - Expand-Archive -Path artifacts.zip -DestinationPath . - $env:LIBOPENSHOT_AUDIO_DIR = "$CI_PROJECT_DIR\build\install-x64" From 11a53e3292d6a01b5ef092c45facbcf89fcee66d Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 22:32:52 -0700 Subject: [PATCH 10/13] Always use 1.0 as max_volume, unless greater than 1.0 --- src/Timeline.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 57803640..9787909b 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -288,18 +288,14 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in /* COPY AUDIO - with correct volume */ if (source_clip->Reader()->info.has_audio) { - // Protect max_volume (if negative or zero, default max_volume to 1.0, which will not adjust volume) - if (max_volume <= 0.0) - max_volume = 1.0; - // Debug output ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Copy Audio)", "source_clip->Reader()->info.has_audio", source_clip->Reader()->info.has_audio, "source_frame->GetAudioChannelsCount()", source_frame->GetAudioChannelsCount(), "info.channels", info.channels, "clip_frame_number", clip_frame_number, "timeline_frame_number", timeline_frame_number, "", -1); if (source_frame->GetAudioChannelsCount() == info.channels && source_clip->has_audio.GetInt(clip_frame_number) != 0) for (int channel = 0; channel < source_frame->GetAudioChannelsCount(); channel++) { - float previous_volume = source_clip->volume.GetValue(clip_frame_number - 1) / max_volume; // previous frame's percentage of volume (0 to 1) - float volume = source_clip->volume.GetValue(clip_frame_number) / max_volume; // percentage of volume (0 to 1) + float previous_volume = source_clip->volume.GetValue(clip_frame_number - 1) / max(max_volume, 1.0); // previous frame's percentage of volume (0 to 1) + float volume = source_clip->volume.GetValue(clip_frame_number) / max(max_volume, 1.0); // percentage of volume (0 to 1) int channel_filter = source_clip->channel_filter.GetInt(clip_frame_number); // optional channel to filter (if not -1) int channel_mapping = source_clip->channel_mapping.GetInt(clip_frame_number); // optional channel to map this channel to (if not -1) From 422f98a35bba245f04c785af323b8185c5836582 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 22:45:31 -0700 Subject: [PATCH 11/13] Float max function --- src/Timeline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 9787909b..80e92503 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -294,8 +294,8 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in if (source_frame->GetAudioChannelsCount() == info.channels && source_clip->has_audio.GetInt(clip_frame_number) != 0) for (int channel = 0; channel < source_frame->GetAudioChannelsCount(); channel++) { - float previous_volume = source_clip->volume.GetValue(clip_frame_number - 1) / max(max_volume, 1.0); // previous frame's percentage of volume (0 to 1) - float volume = source_clip->volume.GetValue(clip_frame_number) / max(max_volume, 1.0); // percentage of volume (0 to 1) + float previous_volume = source_clip->volume.GetValue(clip_frame_number - 1) / fmaxf(max_volume, 1.0); // previous frame's percentage of volume (0 to 1) + float volume = source_clip->volume.GetValue(clip_frame_number) / fmaxf(max_volume, 1.0); // percentage of volume (0 to 1) int channel_filter = source_clip->channel_filter.GetInt(clip_frame_number); // optional channel to filter (if not -1) int channel_mapping = source_clip->channel_mapping.GetInt(clip_frame_number); // optional channel to map this channel to (if not -1) From f4b4aac7dff768d1da018c1af46c86501fab52be Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 23:36:23 -0700 Subject: [PATCH 12/13] Update Frame.cpp Fixing merge error --- src/Frame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index 9da8bed9..16a0d267 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -976,7 +976,7 @@ void Frame::Play() (double) sample_rate, audio->getNumChannels()); // sample rate of source transport1.setPosition (0); - transport1.setGain(1.0 + transport1.setGain(1.0); // Create MIXER From 720c2d5ed773ec9cf3207ddb358da89bbb3b5e10 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 11 Jun 2018 23:37:02 -0700 Subject: [PATCH 13/13] Update Version.h Reverting version for develop branch --- include/Version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Version.h b/include/Version.h index 971d5cfe..cd72ab20 100644 --- a/include/Version.h +++ b/include/Version.h @@ -35,9 +35,9 @@ #endif #define OPENSHOT_VERSION_MAJOR 0; /// Major version number is incremented when huge features are added or improved. -#define OPENSHOT_VERSION_MINOR 2; /// Minor version is incremented when smaller (but still very important) improvements are added. -#define OPENSHOT_VERSION_BUILD 0; /// Build number is incremented when minor bug fixes and less important improvements are added. -#define OPENSHOT_VERSION_SO 15; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) +#define OPENSHOT_VERSION_MINOR 1; /// Minor version is incremented when smaller (but still very important) improvements are added. +#define OPENSHOT_VERSION_BUILD 9; /// Build number is incremented when minor bug fixes and less important improvements are added. +#define OPENSHOT_VERSION_SO 14; /// Shared object version number. This increments any time the API and ABI changes (so old apps will no longer link) #define OPENSHOT_VERSION_MAJOR_MINOR STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR); /// A string of the "Major.Minor" version #define OPENSHOT_VERSION_ALL STRINGIZE(OPENSHOT_VERSION_MAJOR) "." STRINGIZE(OPENSHOT_VERSION_MINOR) "." STRINGIZE(OPENSHOT_VERSION_BUILD); /// A string of the entire version "Major.Minor.Build"