diff --git a/Loris Toolbox/Scripts/UI/BufferPreview.js b/Loris Toolbox/Scripts/UI/BufferPreview.js
index ae79948..0b11c00 100644
--- a/Loris Toolbox/Scripts/UI/BufferPreview.js
+++ b/Loris Toolbox/Scripts/UI/BufferPreview.js
@@ -117,7 +117,7 @@ inline function rebuild(panel)
inline function make(name)
{
- const var p = Content.getComponent("PreviewPanel");
+ local p = Content.getComponent("PreviewPanel");
p.data.paths = [];
p.data.channels = [];
@@ -131,6 +131,7 @@ inline function make(name)
if(event.clicked)
{
+
Engine.playBuffer(this.data.channels, function[this](isPlaying, pos)
{
this.data.previewPos = pos;
@@ -158,15 +159,15 @@ inline function make(name)
g.drawRect(b, 1);
- for(p in this.data.paths)
+ for(tp in this.data.paths)
{
var pb = Rect.removeFromTop(b, this.get("height") / this.data.paths.length);
g.setColour(Colours.withAlpha(this.get("itemColour"), 0.1));
- g.fillPath(p, pb);
+ g.fillPath(tp, pb);
g.setColour(0x5aFFFFFF);
- g.drawPath(p, pb, 1.0);
+ g.drawPath(tp, pb, 1.0);
}
if(this.data.isPlaying)
diff --git a/Loris Toolbox/project_info.xml b/Loris Toolbox/project_info.xml
index 710ddd6..3f27b8d 100644
--- a/Loris Toolbox/project_info.xml
+++ b/Loris Toolbox/project_info.xml
@@ -12,8 +12,8 @@
-
-
+
+
@@ -36,4 +36,9 @@
+
+
+
+
+
diff --git a/README.md b/README.md
index 4c7ad45..c554931 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,7 @@
# loris-tools
-[](https://github.com/christophhart/loris-tools/actions/workflows/build_library.yml)
-
A collection of sample analysis tools for HISE based on the Loris library. The [Loris library](http://www.cerlsoundgroup.org/Loris/) allows you resynthesize and morph audio data and is a pretty powerful tool. This repository contains the integration of Loris into [HISE](https://github.com/christophhart/HISE/)! The integration features:
-- a prebuild dynamic library (currently only macOS, but Windows & Linux will follow soon)
- a scripting API to control loris functions using more or less the same API as the command line interface.
- integration into all file management tools in HISE: audio file loading, script Buffer support etc.
@@ -18,7 +15,7 @@ A HISE Project that demonstrates how to use the Loris library with the scripting
## loris_library
-A dynamic library wrapper that encapsulated the calls into Loris through a C-only API interface. If you want to use Loris in HISE, just grab the latest build and put it in the HISE app data directory.
+MOVED into hi_loris module
## loris_test
diff --git a/build_library.bat b/build_library.bat
deleted file mode 100644
index c263589..0000000
--- a/build_library.bat
+++ /dev/null
@@ -1,30 +0,0 @@
-@echo off
-echo Build Loris Library Windows
-git describe --abbrev=0 > tmpFile
-
-SET /p versionPoint= < tmpFile
-
-echo Version %versionPoint%
-
-set projucer="C:\actions-runner\_work\HISE\HISE\tools\projucer\Projucer.exe"
-set zip_app="C:\Program Files\7-Zip\7z.exe"
-set compiler="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MsBuild.exe"
-
-%projucer% --resave "loris_library/loris_library.jucer"
-
-set dll_project=loris_library/Builds/VisualStudio2017/loris_library.sln
-
-echo Build Debug Configuration...
-
-%compiler% %dll_project% /t:Build /p:Configuration="Debug";Platform=x64 /v:m
-
-echo Build Release Configuration...
-
-%compiler% %dll_project% /t:Build /p:Configuration="Release";Platform=x64 /v:m
-
-echo Zipping Archive
-
-%zip_app% a "loris_library_win64.zip" ".\loris_library\Builds\VisualStudio2017\x64\Debug\Dynamic Library\loris_library_debug.dll"
-%zip_app% a "loris_library_win64.zip" ".\loris_library\Builds\VisualStudio2017\x64\Release\Dynamic Library\loris_library_release.dll"
-
-pause
\ No newline at end of file
diff --git a/build_library.sh b/build_library.sh
deleted file mode 100644
index 4a11943..0000000
--- a/build_library.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-echo loris_library Build Script
-echo ==============================================================
-echo Cleanup...
-
-rm -rf loris_library/Builds
-rm loris_library_macOS.zip
-
-export loris_version=$(git describe --tags --abbrev=0)
-echo Library version is $loris_version
-
-chmod +x "/Applications/Projucer.app/Contents/MacOS/Projucer"
-
-"/Applications/Projucer.app/Contents/MacOS/Projucer" --resave "loris_library/loris_library.jucer"
-
-set -o pipefail
-echo Compiling Loris Dynamic Library...
-
-echo Compile Debug Configuration
-xcodebuild -project ./loris_library/Builds/MacOSX/loris_library.xcodeproj -configuration "Debug" -jobs "6" | xcpretty
-
-echo Compile Release Configuration...
-
-xcodebuild -project ./loris_library/Builds/MacOSX/loris_library.xcodeproj -configuration "Release" -jobs "6" | xcpretty
-
-echo Creating Archive...
-zip -X -j loris_library_macOS.zip ./loris_library/Builds/MacOSX/build/Debug/loris_library_debug.dylib ./loris_library/Builds/MacOSX/build/Release/loris_library_release.dylib
\ No newline at end of file
diff --git a/loris_library/Readme.md b/loris_library/Readme.md
new file mode 100644
index 0000000..a576e3a
--- /dev/null
+++ b/loris_library/Readme.md
@@ -0,0 +1,4 @@
+The Loris library was removed with HISE 4.0.0 and is now part of HISE. Just compile HISE with HISE_INCLUDE_LORIS enabled.
+
+If you want to use Loris in a compiled plugin, enable the Project setting `IncludeLorisInFrontend`
+
diff --git a/loris_library/Source/Helpers.cpp b/loris_library/Source/Helpers.cpp
deleted file mode 100644
index ff9ea0e..0000000
--- a/loris_library/Source/Helpers.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-#include "Helpers.h"
-#include "LorisState.h"
-
-
-namespace loris2hise
-{
-
-juce::var Options::toJSON() const
-{
- juce::DynamicObject::Ptr obj = new juce::DynamicObject();
-
- obj->setProperty(OptionIds::timedomain,
- getTimeDomainOptions()[(int)currentDomainType]);
-
- obj->setProperty(OptionIds::freqfloor, freqfloor);
- obj->setProperty(OptionIds::ampfloor, ampfloor);
- obj->setProperty(OptionIds::sidelobes, sidelobes);
- obj->setProperty(OptionIds::freqdrift, freqdrift);
- obj->setProperty(OptionIds::hoptime, hoptime);
- obj->setProperty(OptionIds::croptime, croptime);
- obj->setProperty(OptionIds::bwregionwidth, bwregionwidth);
- obj->setProperty(OptionIds::windowwidth, windowwidth);
- obj->setProperty(OptionIds::enablecache, enablecache);
-
- return juce::var(obj.get());
-}
-
-juce::StringArray Options::getTimeDomainOptions()
-{
- static const juce::StringArray options =
- {
- "seconds",
- "samples",
- "0to1"
- };
-
- return options;
-}
-
-void Options::initLorisParameters()
-{
- //hoptime = analyzer_getHopTime();
- //croptime = analyzer_getCropTime();
- freqfloor = analyzer_getFreqFloor();
- ampfloor = analyzer_getAmpFloor();
- sidelobes = analyzer_getSidelobeLevel();
- bwregionwidth = analyzer_getBwRegionWidth();
- windowwidth = 1.0;
- enablecache = false;
-}
-
-bool Options::update(const juce::Identifier& id, const juce::var& value)
-{
- if (id == OptionIds::timedomain)
- {
- auto x = value.toString().trim().unquoted();
-
- auto idx = getTimeDomainOptions().indexOf(x);
-
- if (idx == -1)
- throw juce::Result::fail("unknown time domain option: " + value.toString());
-
- currentDomainType = (TimeDomainType)idx;
-
- return true;
- }
-
- if (id == OptionIds::freqfloor) { freqfloor = (double)value; if(initialised) analyzer_setFreqFloor(freqfloor); return true; }
- if (id == OptionIds::ampfloor) { ampfloor = (double)value; if (initialised) analyzer_setAmpFloor(ampfloor); return true; }
- if (id == OptionIds::sidelobes) { sidelobes = (double)value; if (initialised) analyzer_setSidelobeLevel(sidelobes); return true; }
- if (id == OptionIds::freqdrift) { freqdrift = (double)value;
- return true; }
- if (id == OptionIds::hoptime) { hoptime = (double)value; if (initialised) analyzer_setHopTime(hoptime); return true; }
- if (id == OptionIds::croptime) { croptime = (double)value; if (initialised) analyzer_setCropTime(croptime); return true; }
- if (id == OptionIds::bwregionwidth) { bwregionwidth = (double)value; if (initialised) analyzer_setBwRegionWidth(bwregionwidth); return true; }
- if (id == OptionIds::enablecache) { enablecache = (bool)value; return true; }
- if (id == OptionIds::windowwidth) { windowwidth = jlimit(0.125, 4.0, (double)value); return true; }
-
- throw juce::Result::fail("Invalid option: " + id.toString());
-}
-
-void Helpers::reportError(const char* msg)
-{
- if (LorisState::getCurrentInstance() != nullptr)
- LorisState::getCurrentInstance()->reportError(msg);
-}
-
-void Helpers::logMessage(const char* msg)
-{
- if (LorisState::getCurrentInstance() != nullptr)
- LorisState::getCurrentInstance()->messages.add(juce::String(msg));
-}
-
-}
diff --git a/loris_library/Source/Helpers.h b/loris_library/Source/Helpers.h
deleted file mode 100644
index 49e0e32..0000000
--- a/loris_library/Source/Helpers.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-
-
-
-#include "src/loris.h"
-
-#include "ThreadController.h"
-#include "src/Breakpoint.h"
-#include "src/PartialUtils.h"
-
-#include
-
-namespace loris2hise
-{
-using namespace juce;
-
-
-
-
-enum class TimeDomainType
-{
- Seconds,
- Samples,
- Normalised,
- Frequency,
- numTimeDomainTypes
-};
-
-/** The configuration settings for the LorisState. You can change these using loris_config(). */
-struct Options
-{
- /** Creates a JSON version of this object. */
- var toJSON() const;
-
- /** Returns all options for the timedomain property. Currently: `["seconds", "samples", "0oto1"]`*/
- static StringArray getTimeDomainOptions();
-
- /** @internal: init the values. */
- void initLorisParameters();
-
- /** updates the configuration of the given property with the value. */
- bool update(const Identifier& id, const var& value);
-
- /** The timedomain used for all time (x-axis) values.
-
- By default, loris uses seconds for all time values, but you can change it for more convenient
- calculations. The possible options are:
-
- - "seconds" (default): the time in seconds (not milliseconds!)
- - "samples": the time in samples depending on the sample rate of the file
- - "0to1": the time in a normalized version from 0.0 (start of file) to 1.0 (end of file).
- */
- TimeDomainType currentDomainType = TimeDomainType::Seconds;
-
- /** The lowest frequency that is considered as harmonic content. */
- double freqfloor = 40.0;
-
- /** The lowest amplitude that is considered relevant, amplitudes below that value are considered below the noise floor. */
- double ampfloor = 90.0;
-
- /** The gain of the side lobes of the analysis window. */
- double sidelobes = 90.0;
-
- /** The max frequency drift that can occur in the sample (in cent). This defines a tolerance of pitch variations. */
- double freqdrift = 50.0;
-
- /** The time between analysis windows. */
- double hoptime = 0.0129;
-
- /** the time between I don't know. */
- double croptime = 0.0129;
-
- /** ??? */
- double bwregionwidth = 1.0;
-
- /** Enables caching of the input file. If this is true, then analyze calls to previously analyzed files are skipped. */
- bool enablecache = true;
-
- /** The window width scale factor. */
- double windowwidth = 1.0;
-
- /** If this is true, it will also call the loris_setXXX methods. */
- bool initialised = false;
-
- hise::ThreadController* threadController = nullptr;
-};
-
-
-
-/** This struct will be used as argument for the custom function. */
-struct CustomFunctionArgs
-{
- /** The function pointer type that is passed into loris_process_custom(). */
- using FunctionType = bool(*)(CustomFunctionArgs&);
-
- /** @internal The function object alias. */
- using Function = std::function;
-
- /** Creates a function args from the breakpoint, the channel index and the LorisState context. */
- CustomFunctionArgs(void* obj_, const Loris::Breakpoint& b, int channelIndex_,
- int partialIndex_,
- double sampleRate_,
- double time_,
- double rootFrequency_) :
- channelIndex(channelIndex_),
- partialIndex(partialIndex_),
- sampleRate(sampleRate_),
- rootFrequency(rootFrequency_),
- obj(obj_),
- time(time_)
- {
- frequency = b.frequency();
- phase = b.phase();
- gain = b.amplitude();
- bandwidth = b.bandwidth();
- };
-
- // Constants ========================================
-
- /** The channel in the supplied audio file. */
- int channelIndex = 0;
-
- /** The index of the partial. */
- int partialIndex = 0;
-
- /** The sample rate of the file. */
- double sampleRate = 44100.0;
-
- /** the root frequency that was passed into loris_analyze. */
- double rootFrequency = 0.0;
-
- /** @internal: a pointer to the state context. */
- void* obj = nullptr;
-
- // Variable properties ==============================
-
- /** The time of the breakpoint. The domain depends on the `timedomain` configuration option. */
- double time = 0.0;
-
- /** The frequency of partial at the breakpoint in Hz. */
- double frequency = 0.0;
-
- /** The phase of the the partial at the breakpoint in radians (0 ... 2*PI). */
- double phase = 0.0;
-
- /** The amplitude of the partial. */
- double gain = 1.0;
-
- /** The "noisiness" of the partial at the given breakpoint. (0.0 = pure sinusoidal, 1.0 = full noise). */
- double bandwidth = 0.0;
-};
-
-/** @internal Some helper functions. */
-struct Helpers
-{
- static void reportError(const char* msg);
-
- static void logMessage(const char* msg);
-};
-
-}
diff --git a/loris_library/Source/LorisState.cpp b/loris_library/Source/LorisState.cpp
deleted file mode 100644
index ef5866f..0000000
--- a/loris_library/Source/LorisState.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "LorisState.h"
-
-namespace loris2hise {
-
-LorisState* LorisState::currentInstance = nullptr;
-
-LorisState::LorisState() :
- lastError(juce::Result::ok())
-{
- setExceptionHandler(Helpers::reportError);
- setNotifier(Helpers::logMessage);
-}
-
-LorisState::~LorisState()
-{
- analysedFiles.clear();
- messages.clear();
-}
-
-LorisState* LorisState::getCurrentInstance(bool forceCreate /*= false*/)
-{
- if (currentInstance == nullptr || forceCreate)
- currentInstance = new LorisState();
-
- return currentInstance;
-}
-
-void LorisState::resetState(void* state)
-{
- if (state != getCurrentInstance())
- currentInstance = (LorisState*)state;
-
- ((LorisState*)state)->lastError = juce::Result::ok();
-}
-
-MultichannelPartialList* LorisState::getExisting(const File& f)
-{
- for (auto af : analysedFiles)
- {
- if (af->matches(f))
- return af;
- }
-
- return nullptr;
-}
-
-void LorisState::reportError(const char* msg)
-{
- lastError = juce::Result::fail(msg);
-}
-
-bool LorisState::analyse(const juce::File& audioFile, double rootFrequency)
-{
- for (const auto& af : analysedFiles)
- {
- if (af->matches(audioFile))
- {
- if (currentOption.enablecache)
- {
- messages.add("Skip " + audioFile.getFileName());
- return true;
- }
- else
- {
- analysedFiles.removeObject(af);
- break;
- }
- }
- }
- juce::AudioFormatManager m;
- m.registerBasicFormats();
-
- auto driftFactor = std::pow(2.0, currentOption.freqdrift / 1200.0);
-
- analyzer_configure(rootFrequency * 0.8, rootFrequency * currentOption.windowwidth, currentOption.threadController);
- //analyzer_setWindowWidth(rootFrequency * currentOption.windowwidth);
- analyzer_setFreqDrift(rootFrequency * 0.25);
-
- analyzer_storeNoBandwidth();
-
- if (!currentOption.initialised)
- {
- currentOption.initLorisParameters();
- currentOption.initialised = true;
- }
-
- analyzer_setHopTime(currentOption.hoptime);
- analyzer_setCropTime(currentOption.croptime);
-
- if (juce::ScopedPointer r = m.createReaderFor(audioFile))
- {
- messages.add("Analyse " + audioFile.getFileName());
-
- auto newEntry = new MultichannelPartialList(audioFile.getFullPathName(), r->numChannels);
-
- newEntry->setMetadata(r, rootFrequency);
- newEntry->setOptions(currentOption);
-
- juce::AudioSampleBuffer bf(r->numChannels, (int)r->lengthInSamples);
-
- r->read(&bf, 0, (int)r->lengthInSamples, 0, true, true);
-
- juce::HeapBlock buffer;
-
- buffer.allocate(bf.getNumSamples(), true);
-
- for (int c = 0; c < bf.getNumChannels(); c++)
- {
- if (auto s = hise::ThreadController::ScopedStepScaler(currentOption.threadController, c, bf.getNumChannels()))
- {
- if (!s)
- return false;
-
- for (int i = 0; i < bf.getNumSamples(); i++)
- buffer[i] = bf.getSample(c, i);
-
- auto list = newEntry->get(c);
-
- analyze(buffer, bf.getNumSamples(), r->sampleRate, list);
- }
- }
-
- newEntry->saveAsOriginal();
- //newEntry->prepareToMorph();
-
- analysedFiles.add(newEntry);
-
- messages.add("... Analysed OK");
- return true;
- }
-
- return false;
-}
-
-double LorisState::getOption(const juce::Identifier &id) const
-{
- juce::String msg;
- msg << "Get option " << id;
-
- Helpers::logMessage(msg.getCharPointer().getAddress());
-
- return (double)currentOption.toJSON()[id];
-}
-
-bool LorisState::setOption(const juce::Identifier& id, const juce::var& data)
-{
- juce::String msg;
- msg << "Set option " << id << " with value " << data.toString().quoted();
-
- Helpers::logMessage(msg.getCharPointer().getAddress());
-
- try
- {
- if (!currentOption.update(id, data))
- return false;
-
- for (auto& s : analysedFiles)
- s->setOptions(currentOption);
- }
- catch (juce::Result& r)
- {
- lastError = r;
- return false;
- }
-
- msg = "Updated options to: ";
- msg << "\n" << juce::JSON::toString(currentOption.toJSON());
-
- Helpers::logMessage(msg.getCharPointer().getAddress());
-
- return true;
-}
-
-
-
-
-}
diff --git a/loris_library/Source/LorisState.h b/loris_library/Source/LorisState.h
deleted file mode 100644
index cbea30a..0000000
--- a/loris_library/Source/LorisState.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include "Properties.h"
-
-#include "Helpers.h"
-#include "MultichannelPartialList.h"
-
-#include "JuceHeader.h"
-
-namespace loris2hise {
-using namespace juce;
-
-/** A state that holds all information. Create it with createLorisState and delete it with deleteLorisState().
-
- This avoids having a global context, however the error reporting will only work with the
- state that was created last (because the loris error handling is global).
- */
-struct LorisState
-{
- LorisState();
-
- ~LorisState();
-
- static LorisState* getCurrentInstance(bool forceCreate = false);
-
- static void resetState(void* state);
-
- void reportError(const char* msg);
-
- bool analyse(const juce::File& audioFile, double rootFrequency);
-
- bool setOption(const juce::Identifier& id, const juce::var& data);
-
- double getOption(const juce::Identifier& id) const;
-
- MultichannelPartialList* getExisting(const File& f);
-
- const char* getLastError() const
- {
- return lastError.getErrorMessage().getCharPointer().getAddress();
- }
-
- String getLastMessage()
- {
- if(!messages.isEmpty())
- {
- auto lastMessage = messages[messages.size()-1];
- messages.remove(messages.size()-1);
- return lastMessage;
- }
-
- return {};
- }
-
- void setThreadController(hise::ThreadController* tc)
- {
- currentOption.threadController = tc;
- }
-
-private:
-
- friend class Helpers;
-
- Options currentOption;
-
- juce::Result lastError;
-
- juce::OwnedArray analysedFiles;
-
- juce::StringArray messages;
-
- static LorisState* currentInstance;
-
- JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LorisState);
-};
-
-}
diff --git a/loris_library/Source/MultichannelPartialList.cpp b/loris_library/Source/MultichannelPartialList.cpp
deleted file mode 100644
index a46d10e..0000000
--- a/loris_library/Source/MultichannelPartialList.cpp
+++ /dev/null
@@ -1,638 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "MultichannelPartialList.h"
-#include "src/Resampler.h"
-
-namespace loris2hise {
-using namespace juce;
-
-
-MultichannelPartialList::MultichannelPartialList(const juce::String& name, int numChannels) :
- filename(name)
-{
- for (int i = 0; i < numChannels; i++)
- {
- list.add(createPartialList());
- }
-}
-
-MultichannelPartialList::~MultichannelPartialList()
-{
- for (auto& p : list)
- destroyPartialList(p);
-}
-
-double MultichannelPartialList::convertTimeToSeconds(double timeInput) const
-{
- if (options.currentDomainType == TimeDomainType::Seconds)
- return timeInput;
- if (options.currentDomainType == TimeDomainType::Samples)
- {
- return timeInput / sampleRate;
- }
- if (options.currentDomainType == TimeDomainType::Normalised)
- {
- return timeInput * numSamples / sampleRate;
- }
- if (options.currentDomainType == TimeDomainType::Frequency)
- {
- return timeInput;
- }
-
- jassertfalse;
- return timeInput;
-}
-
-double MultichannelPartialList::convertSecondsToTime(double timeInput) const
-{
- if (options.currentDomainType == TimeDomainType::Seconds)
- return timeInput;
- if (options.currentDomainType == TimeDomainType::Samples)
- {
- return timeInput * sampleRate;
- }
- if (options.currentDomainType == TimeDomainType::Normalised)
- {
- return timeInput * sampleRate / numSamples;
- }
- if (options.currentDomainType == TimeDomainType::Frequency)
- {
- return timeInput;
- }
-
- jassertfalse;
- return timeInput;
-}
-
-void MultichannelPartialList::setMetadata(juce::AudioFormatReader* r, double root)
-{
- numSamples = (int)r->lengthInSamples;
- sampleRate = r->sampleRate;
- rootFrequency = root;
-}
-
-LinearEnvelope* MultichannelPartialList::createEnvelopeFromJSON(const juce::var& data)
-{
- auto env = createLinearEnvelope();
-
- auto cleanup = [env]() { destroyLinearEnvelope(env); };
-
- checkArgs(data.isArray(), "must be a a list of [x, y] points", cleanup);
-
- if (data.isArray())
- {
- for (const auto& s : *data.getArray())
- {
- checkArgs(s.isArray() &&
- s.size() == 2, "point element must be an array with two elements", cleanup);
-
- auto timeValue = convertTimeToSeconds(s[0]);
-
- linearEnvelope_insertBreakpoint(env, timeValue, s[1]);
- }
- }
-
- return env;
-}
-
-void MultichannelPartialList::saveAsOriginal()
-{
- for (const auto l : list)
- {
- auto newO = createPartialList();
- partialList_copy(newO, l);
- original.add(newO);
- }
-
- jassert(list.size() == original.size());
-}
-
-void MultichannelPartialList::checkArgs(bool condition, const juce::String& error, const std::function& additionalCleanupFunction /*= {}*/)
-{
- if (!condition)
- {
- if (additionalCleanupFunction)
- additionalCleanupFunction();
-
- throw juce::Result::fail("process args error: " + error);
- }
-}
-
-bool MultichannelPartialList::processCustom(void* obj, const CustomFunctionArgs::Function& f)
-{
- int channelIndex = 0;
-
- for (auto l : list)
- {
- int partialIndex = 0;
-
- for (auto& p : *l)
- {
- for (Partial::iterator iter = p.begin(); iter != p.end(); ++iter)
- {
- auto t = convertSecondsToTime(iter.time());
- auto& b = iter.breakpoint();
-
- CustomFunctionArgs a(obj, b, channelIndex, partialIndex, sampleRate, t, rootFrequency);
-
- if (f(a))
- return true;
-
- iter.time();
- breakpoint_setAmplitude(&b, a.gain);
- breakpoint_setPhase(&b, a.phase);
- breakpoint_setFrequency(&b, a.frequency);
- breakpoint_setBandwidth(&b, a.bandwidth);
- }
-
- partialIndex++;
- }
-
- channelIndex++;
- }
-
- return false;
-}
-
-
-bool MultichannelPartialList::process(const juce::Identifier& command, const juce::var& data)
-{
- juce::String msg;
- msg << "Process " << filename << " with command " << command << " and JSON argument " << juce::JSON::toString(data);
-
- Helpers::logMessage(msg.getCharPointer().getAddress());
-
- if (command == ProcessIds::reset)
- {
- checkArgs(data.isObject() &&
- data.getDynamicObject()->getProperties().isEmpty(),
- "must be an empty object");
-
- for (int i = 0; i < list.size(); i++)
- {
- partialList_clear(list[i]);
- partialList_copy(list[i], original[i]);
- }
-
- return true;
- }
- if (command == ProcessIds::applyFilter)
- {
- juce::ScopedValueSetter svs(options.currentDomainType, TimeDomainType::Frequency);
-
- auto env = createEnvelopeFromJSON(data);
-
- for (auto& l : list)
- {
- for (auto& p : *l)
- {
-
- for (auto& b : p)
- {
- auto freq = breakpoint_getFrequency(&b);
- auto gain = linearEnvelope_valueAt(env, freq);
-
- gain *= breakpoint_getAmplitude(&b);
-
- breakpoint_setAmplitude(&b, gain);
- }
- }
- }
-
- destroyLinearEnvelope(env);
- return true;
- }
- if (command == ProcessIds::shiftTime)
- {
- checkArgs(data.hasProperty("offset"), "must be a JSON object with a offset property");
-
- auto offset = convertTimeToSeconds(data["offset"]);
-
- for (auto l : list)
- shiftTime(l, offset);
-
- return true;
- }
- if (command == ProcessIds::shiftPitch)
- {
- if (data.isArray())
- {
- auto env = createEnvelopeFromJSON(data);
-
- for (auto l : list)
- shiftPitch(l, env);
-
- destroyLinearEnvelope(env);
- }
- else if (data.isObject())
- {
- checkArgs(data.hasProperty("offset"), "shiftPitch with a constant value needs a JSON with an offset property");
-
- auto s = data["offset"];
-
- auto env = createLinearEnvelope();
-
- linearEnvelope_insertBreakpoint(env, 0.0, s);
-
- for (auto l : list)
- {
- shiftPitch(l, env);
- }
-
- destroyLinearEnvelope(env);
- }
-
-
- return true;
- }
- if (command == ProcessIds::scaleFrequency)
- {
- auto env = createEnvelopeFromJSON(data);
-
- for (auto l : list)
- scaleFrequency(l, env);
-
- destroyLinearEnvelope(env);
-
- return true;
- }
-
- if (command == ProcessIds::dilate)
- {
- checkArgs(data.isArray(), "must be an array with two list of data points");
-
- if (data.isArray())
- {
- juce::Array itimes;
- juce::Array ttimes;
-
- auto iv = data[0];
- auto tv = data[1];
-
- checkArgs(iv.isArray(), "first element must be a list of numbers");
- checkArgs(tv.isArray(), "second element must be a list of numbers");
-
- for (int i = 0; i < iv.size(); i++)
- {
- checkArgs(iv[i].isDouble(),
- "in[" + juce::String(i) + "] must be a double number");
-
- checkArgs(tv[i].isDouble(),
- "out[" + juce::String(i) + "] must be a double number");
-
- itimes.add(convertTimeToSeconds(iv[i]));
- ttimes.add(convertTimeToSeconds(tv[i]));
- }
-
- for (auto l : list)
- dilate(l, itimes.getRawDataPointer(), ttimes.getRawDataPointer(), itimes.size());
- }
-
- return true;
- }
-
- throw juce::Result::fail("Invalid command: " + command);
-}
-
-size_t MultichannelPartialList::getRequiredBytes() const
-{
- return list.size() * numSamples * sizeof(float);
-}
-
-juce::AudioSampleBuffer MultichannelPartialList::synthesize()
-{
- juce::String msg;
- msg << "Synthesize " << filename << "...";
- Helpers::logMessage(msg.getCharPointer().getAddress());
- juce::AudioSampleBuffer output(list.size(), numSamples);
-
- juce::HeapBlock buffer;
- buffer.allocate(numSamples, true);
-
- for (int i = 0; i < list.size(); i++)
- {
- juce::FloatVectorOperations::clear(buffer, numSamples);
- ::synthesize(list[i], buffer, numSamples, sampleRate);
-
- for (int s = 0; s < numSamples; s++)
- {
- output.setSample(i, s, (float)buffer[s]);
- }
- }
-
- Helpers::logMessage("...Synthesize OK");
- return output;
-}
-
-bool MultichannelPartialList::prepareToMorph(bool removeUnlabeled)
-{
- if(preparedForMorph)
- return true;
-
- Helpers::logMessage("Prepare partial list for morphing");
-
- if (auto s = hise::ThreadController::ScopedStepScaler(options.threadController, 0, 5))
- {
- for (auto p : list)
- {
- if (auto s2 = hise::ThreadController::ScopedStepScaler(options.threadController, list.indexOf(p), list.size()))
- {
- auto l = std::pow(2.0, -1.0 * options.freqdrift / 1200.0);
- auto h = std::pow(2.0, options.freqdrift / 1200.0);
-
- LinearEnvelope* env;
-
- {
- hise::ThreadController::ScopedRangeScaler s(options.threadController, 0.0, 0.5);
- env = createF0Estimate(p, rootFrequency * l, rootFrequency * h, options.hoptime * 10.0, options.threadController);
- }
-
-
- {
- hise::ThreadController::ScopedRangeScaler s(options.threadController, 0.5, 1.0);
- channelize(p, env, 1);
- }
-
- destroyLinearEnvelope(env);
- }
-
- }
- }
-
-
-
- if (auto s = hise::ThreadController::ScopedRangeScaler(options.threadController, 0.5, 1.0))
- {
- int idx = 0;
- int length = list.size();
-
- for (auto p : list)
- {
- if (auto ls = hise::ThreadController::ScopedStepScaler(options.threadController, idx++, length))
- {
- hise::ThreadController::ScopedStepScaler(options.threadController, 0, 5);
- collate(p);
-
- if (!options.threadController)
- return false;
-
- hise::ThreadController::ScopedStepScaler(options.threadController, 1, 5);
- sortByLabel(p);
-
- if (!options.threadController)
- return false;
-
- hise::ThreadController::ScopedStepScaler(options.threadController, 2, 5);
- sift(p);
-
- if (!options.threadController)
- return false;
-
- hise::ThreadController::ScopedStepScaler(options.threadController, 3, 5);
- distill(p);
-
- if (!options.threadController)
- return false;
-
- if (removeUnlabeled)
- removeLabeled(p, 0);
-
- if (!options.threadController)
- return false;
-
- hise::ThreadController::ScopedStepScaler(options.threadController, 4, 5);
- sortByLabel(p);
-
- if (!options.threadController)
- return false;
-
- // better to compute this only once:
- const double OneOverSrate = 1. / sampleRate;
-
- // use a Resampler to quantize the Breakpoint times and
- // correct the phases:
- Loris::Resampler quantizer(options.hoptime);
- quantizer.setPhaseCorrect(true);
-
- for (auto& pr : *p)
- {
- if (!options.threadController)
- return false;
-
- quantizer.quantize(pr);
- }
- }
- }
-
- preparedForMorph = true;
- return true;
- }
- else
- return false;
-
-}
-
-juce::AudioSampleBuffer MultichannelPartialList::renderEnvelope(const juce::Identifier ¶meter, int partialIndex)
-{
- AudioSampleBuffer b(getNumChannels(), getNumSamples());
- b.clear();
-
- if(parameter == ParameterIds::rootFrequency)
- {
- for(auto e: rootFrequencyEnvelopes)
- destroyLinearEnvelope(e);
-
- rootFrequencyEnvelopes.clear();
-
- int c = 0;
-
- for(auto pl: list)
- {
- const var hoptimeSamples = options.hoptime * sampleRate;
-
- LinearEnvelope* env = createF0Estimate(pl, rootFrequency * (1.0 + options.freqdrift), rootFrequency / (1.0 + options.freqdrift), options.hoptime * 4.0, options.threadController);
-
- for(int i = 0; i < b.getNumSamples(); i++)
- b.setSample(c, i, linearEnvelope_valueAt(env, i / sampleRate) / rootFrequency);
-
- rootFrequencyEnvelopes.add(env);
- c++;
- }
- }
- else
- {
- prepareToMorph();
-
- int c = 0;
- for(auto pl: list)
- {
- bool found = false;
-
- for(auto p: *pl)
- {
- if(partialIndex == (p.label() - 1))
- {
- found = true;
-
- const int sampleDelta = options.hoptime * sampleRate;
- SmoothedValue ramp;
- std::function vf;
-
- ramp.reset(sampleRate, options.hoptime);
-
- if(parameter == ParameterIds::phase)
- vf = partial_phaseAt;
- if(parameter == ParameterIds::frequency)
- vf = partial_frequencyAt;
- if(parameter == ParameterIds::gain)
- vf = partial_amplitudeAt;
- if(parameter == ParameterIds::bandwidth)
- vf = partial_bandwidthAt;
-
- for(int i = 0; i < getNumSamples(); i++)
- {
- if(i % sampleDelta == 0)
- {
- auto t = (double)i / sampleRate;
- ramp.setTargetValue((float)vf(&p, t));
- }
-
- b.setSample(c, i, ramp.getNextValue());
- }
- }
- }
-
- if(!found)
- {
- String msg;
- msg <<"Can't find partial with label " << String(partialIndex);
- Helpers::reportError(msg.getCharPointer().getAddress());
- }
- }
-
- c++;
- }
-
-
-
- return b;
-}
-
-bool MultichannelPartialList::createSnapshot(const juce::Identifier ¶meter, double timeSeconds, double *buffer, int& numChannels, int &numHarmonics)
-{
- auto timeToUse = convertTimeToSeconds(timeSeconds);
-
- numChannels = getNumChannels();
-
- if (auto s = hise::ThreadController::ScopedRangeScaler(options.threadController, 0.0, 0.5))
- {
- prepareToMorph(true);
- }
-
- hise::ThreadController::ScopedRangeScaler s2(options.threadController, 0.5, 1.0);
-
- std::function vf;
-
- if(parameter == ParameterIds::phase)
- vf = partial_phaseAt;
- if(parameter == ParameterIds::frequency)
- vf = partial_frequencyAt;
- if(parameter == ParameterIds::gain)
- vf = partial_amplitudeAt;
- if(parameter == ParameterIds::bandwidth)
- vf = partial_bandwidthAt;
-
- int index = 1;
-
- int numMaxHarmonics = 0;
-
- for (auto& pl : list)
- {
- for (const auto& part : *pl)
- {
- numMaxHarmonics = jmax(numMaxHarmonics, part.label()-1);
- }
- }
-
- FloatVectorOperations::clear(buffer, numMaxHarmonics);
-
- int channelOffset = 0;
-
- int idx = 0;
- int length = (double)list.size();
-
- auto tc = options.threadController;
-
- for(auto& pl: list)
- {
- int thisNum = 0;
-
- if (auto s = hise::ThreadController::ScopedStepScaler(tc, idx++, length))
- {
- for (auto& p : *pl)
- {
- auto labelIndex = p.label() - 1;
-
- if (tc != nullptr)
- tc->setProgress((double)labelIndex / (double)numMaxHarmonics);
-
- jassert(isPositiveAndBelow(labelIndex, numMaxHarmonics + 1));
- buffer[channelOffset + labelIndex] = vf(&p, timeToUse);
- }
-
- channelOffset += numMaxHarmonics;
- }
- else
- return false;
- }
-
- numHarmonics = numMaxHarmonics;
-
- return true;
-}
-
-bool MultichannelPartialList::matches(const juce::File& f) const
-{
- return f.getFullPathName() == filename;
-}
-
-int MultichannelPartialList::getNumSamples() const
-{
- return numSamples;
-}
-
-int MultichannelPartialList::getNumChannels() const
-{
- return list.size();
-}
-
-void MultichannelPartialList::setOptions(const Options& newOptions)
-{
- options = newOptions;
-}
-
-
-
-
-
-
-
-
-
-
-}
diff --git a/loris_library/Source/MultichannelPartialList.h b/loris_library/Source/MultichannelPartialList.h
deleted file mode 100644
index f63b06c..0000000
--- a/loris_library/Source/MultichannelPartialList.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "src/loris.h"
-#include "src/Partial.h"
-
-#include "Properties.h"
-#include "Helpers.h"
-
-#pragma once
-
-namespace loris2hise {
-using namespace juce;
-
-/** This object contains a Loris::PartialList for each audio channel. */
-struct MultichannelPartialList
-{
- /** @internal only used internally. */
- MultichannelPartialList(const juce::String& name, int numChannels);
-
- /** @internal only used internally. */
- ~MultichannelPartialList();
-
- /** @internal only used internally. */
- double convertTimeToSeconds(double timeInput) const;
-
- /** @internal only used internally. */
- double convertSecondsToTime(double timeInput) const;
-
- /** @internal only used internally. */
- PartialList* get(int index) { return list[index]; }
-
- /** @internal only used internally. */
- void setMetadata(juce::AudioFormatReader* r, double root);
-
- /** @internal This function creates a linear envelope from points supplied as JSON object.
-
- The JSON format is a two-dimensional array with `[x, y]` items.
-
- @example: `[ [0.0, 0.0], [0.5, 0.25], [1.0, 1.0] ]`
-
- This is used by multiple process algorithm that require a time-varying parameter. Note that the `x`
- parameter (=time) is always converted using the global timedomain setting.
- */
- LinearEnvelope* createEnvelopeFromJSON(const juce::var& data);
-
- /** @internal: argument sanitizer. Throws a juce::Result with the supplied error message. */
- void checkArgs(bool condition, const juce::String& error, const std::function& additionalCleanupFunction = {});
-
- /** Iterates all channels, partials and breakpoints (3D!) and calls the given function for each data point.
-
- - state: the LorisState context. This is only used internally.
- - f: a function with a single argument that contains a reference to the CustomFunctionArgs object that holds the data
- for the breakpoint that should be modified. If the function returns true, the iteration will be aborted.
-
- returns true if the processing was sucessful and false if there was an error.
- */
- bool processCustom(void* obj, const CustomFunctionArgs::Function& f);
-
- /** Processes the partials of each channel with a predefined function.
-
- - command: the function you want to execute (see below)
- - args: a JSON object containing the data parameters for the algorithm.
-
- returns true if the processing was sucessful and false if there was an error.
-
- The list of available process commands is defined in the ProcessIds namespace.
-
- The JSON data for each command:
-
- - reset: an empty object `{}`
- -
-
- */
- bool process(const juce::Identifier& command, const juce::var& args);
-
- bool createSnapshot(const juce::Identifier& id, double timeSeconds, double* buffer, int& numChannels, int& numHarmonics);
-
- juce::AudioSampleBuffer synthesize();
-
- juce::AudioSampleBuffer renderEnvelope(const Identifier& parameter, int partialIndex);
-
- bool matches(const juce::File& f) const;
-
- size_t getRequiredBytes() const;
- int getNumSamples() const;
- int getNumChannels() const;
-
- /**@ internal **/
- void setOptions(const Options& newOptions);
-
- /** @internal */
- void saveAsOriginal();
-
- bool prepareToMorph(bool removeUnlabeled=false);
-
-private:
-
- bool preparedForMorph = false;
-
- Options options;
-
- juce::String filename;
-
- int numSamples = 0;
- double sampleRate = 0.0;
- double rootFrequency;
-
- juce::Array list;
-
- juce::Array rootFrequencyEnvelopes;
-
- juce::Array original;
-
- JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MultichannelPartialList);
-};
-
-}
diff --git a/loris_library/Source/Properties.h b/loris_library/Source/Properties.h
deleted file mode 100644
index 1b1085a..0000000
--- a/loris_library/Source/Properties.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include "JuceHeader.h"
-
-namespace loris2hise
-{
-
-#define DECLARE_ID(x) static const juce::Identifier x(#x);
-
-namespace OptionIds
-{
- DECLARE_ID(timedomain);
- DECLARE_ID(enablecache);
- DECLARE_ID(windowwidth);
- DECLARE_ID(freqfloor);
- DECLARE_ID(ampfloor);
- DECLARE_ID(sidelobes);
- DECLARE_ID(freqdrift);
- DECLARE_ID(hoptime);
- DECLARE_ID(croptime);
- DECLARE_ID(bwregionwidth);
-
- /** @internal */
- static juce::Array getAllIds()
- {
- return { timedomain, enablecache, windowwidth, freqfloor, ampfloor, sidelobes, freqdrift, hoptime, croptime, bwregionwidth };
- };
-}
-
-namespace ParameterIds
-{
- DECLARE_ID(rootFrequency);
- DECLARE_ID(frequency);
- DECLARE_ID(phase);
- DECLARE_ID(gain);
- DECLARE_ID(bandwidth);
-
- static juce::Array getAllIds()
- {
- return { rootFrequency, frequency, phase, gain, bandwidth };
- };
-};
-
-/** This contains a list of all available commands that can be passed into process. */
-namespace ProcessIds
-{
- /** Resets the partials to the original. Use this if you have cached the file and want*/
- DECLARE_ID(reset);
- DECLARE_ID(shiftTime);
- DECLARE_ID(shiftPitch);
- DECLARE_ID(applyFilter);
- DECLARE_ID(scaleFrequency);
- DECLARE_ID(dilate);
- DECLARE_ID(custom);
-
- /** @internal */
- static juce::Array getAllIds()
- {
- return { reset, shiftTime, shiftPitch, scaleFrequency, dilate, applyFilter, custom };
- }
-
-}
-
-#undef DECLARE_ID
-
-}
diff --git a/loris_library/Source/ThreadController.h b/loris_library/Source/ThreadController.h
deleted file mode 100644
index d03c832..0000000
--- a/loris_library/Source/ThreadController.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * This file is part of the HISE loris_library codebase (https://github.com/christophhart/loris-tools).
- * Copyright (c) 2023 Christoph Hart
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include
-
-namespace hise
-{
- using namespace juce;
-
- /** A minimal POD that can be used to check the thread state across DLL boundaries. */
- class ThreadController : public ReferenceCountedObject
- {
- struct Scaler
- {
- Scaler(bool isStep_ = false) :
- isStep(isStep_)
- {}
-
- double getScaledProgress(double input) const
- {
- if (isStep)
- return (v1 + input) / v2;
- else
- return v1 + (v2 - v1) * input;
- }
-
- bool isStep = false;
- double v1 = 0.0;
- double v2 = 0.0;
- };
-
- template struct ScopedScaler
- {
- template ScopedScaler(ThreadController* parent_, T v1, T v2) : parent(parent_)
- {
- Scaler s(IsStep);
- s.v1 = (double)v1;
- s.v2 = (double)v2;
-
- if (parent != nullptr)
- parent->pushProgressScaler(s);
- };
-
- ~ScopedScaler()
- {
- if (parent != nullptr)
- parent->popProgressScaler();
- };
-
- operator bool() const { return parent; }
- ThreadController* parent;
- };
-
- public:
-
- using Ptr = ReferenceCountedObjectPtr;
- using ScopedRangeScaler = ScopedScaler;
- using ScopedStepScaler = ScopedScaler;
-
- ThreadController(Thread* t, double* p, int timeoutMs, uint32& lastTime_) :
- juceThreadPointer(t),
- progress(p),
- timeout(timeoutMs),
- lastTime(&lastTime_)
- {};
-
- ThreadController() :
- juceThreadPointer(nullptr),
- progress(nullptr),
- lastTime(nullptr)
- {};
-
- operator bool() const
- {
- if (juceThreadPointer == nullptr)
- return false;
-
- auto thisTime = Time::getMillisecondCounter();
-
- if (lastTime != nullptr && *lastTime != 0 && thisTime - *lastTime > timeout)
- {
- // If this hits, it means that the timeout you've set is too low.
- // Either increase the timeout or add more checks in between...
- int x = 5;
-
- // prevent the jassert above to mess up subsequent timeouts...
- thisTime = Time::getMillisecondCounter();
- }
-
- if (lastTime != nullptr)
- *lastTime = thisTime;
-
- return !static_cast(juceThreadPointer)->threadShouldExit();
- }
-
- /** Allow a bigger time between calls. */
- void extendTimeout(uint32 milliSeconds)
- {
- if (lastTime != nullptr)
- *lastTime += milliSeconds;
- }
-
-
- /** Set a progress. If you want to add a scaler to the progress (for indicating a subprocess, use either ScopedStepScaler or ScopedRangeScalers). */
- bool setProgress(double p)
- {
- if (progress == nullptr)
- return true;
-
- for (int i = progressScalerIndex-1; i >= 0; i--)
- {
- p = jlimit(0.0, 1.0, progressScalers[i].getScaledProgress(p));
- }
-
- // If this hits, you might have forgot a scaler in the call stack...
- jassert(*progress <= p);
-
- *progress = p;
-
- return *this;
- }
-
- private:
-
- static constexpr int NumProgressScalers = 32;
-
- void pushProgressScaler(const Scaler& f)
- {
- progressScalers[progressScalerIndex++] = f;
- jassert(isPositiveAndBelow(progressScalerIndex, NumProgressScalers));
- setProgress(0.0);
- }
-
- void popProgressScaler()
- {
- progressScalers[progressScalerIndex--] = {};
- jassert(progressScalerIndex >= 0);
- }
-
- void* juceThreadPointer = nullptr;
- double* progress = nullptr;
- mutable uint32* lastTime = nullptr;
- uint32 timeout = 0;
- int progressScalerIndex = 0;
- Scaler progressScalers[NumProgressScalers];
-
- JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ThreadController);
- };
-}
\ No newline at end of file
diff --git a/loris_library/Source/include/loris.h b/loris_library/Source/include/loris.h
deleted file mode 100644
index 26d0d15..0000000
--- a/loris_library/Source/include/loris.h
+++ /dev/null
@@ -1,1020 +0,0 @@
-#ifndef INCLUDE_LORIS_H
-#define INCLUDE_LORIS_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * loris.h
- *
- * Header specifying C-linkable procedural interface for Loris.
- *
- * Main components of this interface:
- * - version identification symbols
- * - type declarations
- * - Analyzer configuration
- * - LinearEnvelope (formerly BreakpointEnvelope) operations
- * - PartialList operations
- * - Partial operations
- * - Breakpoint operations
- * - sound modeling functions for preparing PartialLists
- * - utility functions for manipulating PartialLists
- * - notification and exception handlers (all exceptions must be caught and
- * handled internally, clients can specify an exception handler and
- * a notification function. The default one in Loris uses printf()).
- *
- * loris.h is generated automatically from loris.h.in. Do not modify loris.h
- *
- * Kelly Fitz, 4 Feb 2002
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-/* ---------------------------------------------------------------- */
-/* Version
-/*
-/* Define symbols that facilitate version/release identification.
- */
-
-#define LORIS_MAJOR_VERSION 1
-#define LORIS_MINOR_VERSION 8
-#define LORIS_SUBMINOR_VERSION
-#define LORIS_VERSION_STR "Loris 1.8"
-
-/* ---------------------------------------------------------------- */
-/* Types
-/*
-/* The (class) types Breakpoint, LinearEnvelope, Partial,
- and PartialList are imported from the Loris namespace.
- The first three are classes, the latter is a typedef
- for std::list< Loris::Partial >.
- */
-#if defined(__cplusplus)
- // include std library list header, declaring templates
- // is too painful and fragile:
- #include
-
- // declare Loris classes in Loris namespace:
- namespace Loris
- {
- class Breakpoint;
- class LinearEnvelope;
- class Partial;
-
- // this typedef has to be copied from PartialList.h
- typedef std::list< Loris::Partial > PartialList;
- }
-
- // import those names into the global namespace
- using Loris::Breakpoint;
- using Loris::LinearEnvelope;
- using Loris::Partial;
- using Loris::PartialList;
-#else
- /* no classes, just declare types and use
- opaque C pointers
- */
- typedef struct Breakpoint Breakpoint;
- typedef struct LinearEnvelope LinearEnvelope;
- typedef struct PartialList PartialList;
- typedef struct Partial Partial;
-#endif
-
-/*
- TODO
- Maybe should also have loris_label_t and loris_size_t
- defined, depending on configure.
-*/
-
-#if defined(__cplusplus)
- extern "C" {
-#endif
-
-/* ---------------------------------------------------------------- */
-/* Analyzer configuration
-/*
-/* An Analyzer represents a configuration of parameters for
- performing Reassigned Bandwidth-Enhanced Additive Analysis
- of sampled waveforms. This analysis process yields a collection
- of Partials, each having a trio of synchronous, non-uniformly-
- sampled breakpoint envelopes representing the time-varying
- frequency, amplitude, and noisiness of a single bandwidth-
- enhanced sinusoid.
-
- For more information about Reassigned Bandwidth-Enhanced
- Analysis and the Reassigned Bandwidth-Enhanced Additive Sound
- Model, refer to the Loris website: www.cerlsoundgroup.org/Loris/.
-
- In the procedural interface, there is only one Analyzer.
- It must be configured by calling analyzer_configure before
- any of the other analyzer operations can be performed.
- */
-
-void analyze( const double * buffer, unsigned int bufferSize,
- double srate, PartialList * partials );
-/* Analyze an array of bufferSize (mono) samples at the given sample rate
- (in Hz) and append the extracted Partials to the given
- PartialList.
- */
-
-void analyzer_configure( double resolution, double windowWidth );
-/* Configure the sole Analyzer instance with the specified
- frequency resolution (minimum instantaneous frequency
- difference between Partials). All other Analyzer parameters
- are computed from the specified frequency resolution.
-
- Construct the Analyzer instance if necessary.
-
- In the procedural interface, there is only one Analyzer.
- It must be configured by calling analyzer_configure before
- any of the other analyzer operations can be performed.
- */
-
-double analyzer_getAmpFloor( void );
-/* Return the amplitude floor (lowest detected spectral amplitude),
- in (negative) dB, for the Loris Analyzer.
- */
-
-double analyzer_getCropTime( void );
-/* Return the crop time (maximum temporal displacement of a time-
- frequency data point from the time-domain center of the analysis
- window, beyond which data points are considered "unreliable")
- for the Loris Analyzer.
- */
-
-double analyzer_getFreqDrift( void );
-/* Return the maximum allowable frequency difference between
- consecutive Breakpoints in a Partial envelope for the Loris Analyzer.
- */
-
-double analyzer_getFreqFloor( void );
-/* Return the frequency floor (minimum instantaneous Partial
- frequency), in Hz, for the Loris Analyzer.
- */
-
-double analyzer_getFreqResolution( void );
-/* Return the frequency resolution (minimum instantaneous frequency
- difference between Partials) for the Loris Analyzer.
- */
-
-double analyzer_getHopTime( void );
-/* Return the hop time (which corresponds approximately to the
- average density of Partial envelope Breakpoint data) for this
- Analyzer.
- */
-
-double analyzer_getSidelobeLevel( void );
-/* Return the sidelobe attenutation level for the Kaiser analysis window in
- positive dB. Higher numbers (e.g. 90) give very good sidelobe
- rejection but cause the window to be longer in time. Smaller
- numbers raise the level of the sidelobes, increasing the likelihood
- of frequency-domain interference, but allow the window to be shorter
- in time.
- */
-
-double analyzer_getWindowWidth( void );
-/* Return the frequency-domain main lobe width (measured between
- zero-crossings) of the analysis window used by the Loris Analyzer.
- */
-
-void analyzer_setAmpFloor( double x );
-/* Set the amplitude floor (lowest detected spectral amplitude), in
- (negative) dB, for the Loris Analyzer.
- */
-
-void analyzer_setBwRegionWidth( double x );
-/* Deprecated, use analyzer_storeResidueBandwidth instead.
- */
-
-void analyzer_setCropTime( double x );
-/* Set the crop time (maximum temporal displacement of a time-
- frequency data point from the time-domain center of the analysis
- window, beyond which data points are considered "unreliable")
- for the Loris Analyzer.
- */
-
-void analyzer_setFreqDrift( double x );
-/* Set the maximum allowable frequency difference between
- consecutive Breakpoints in a Partial envelope for the Loris Analyzer.
- */
-
-void analyzer_setFreqFloor( double x );
-/* Set the amplitude floor (minimum instantaneous Partial
- frequency), in Hz, for the Loris Analyzer.
- */
-
-void analyzer_setFreqResolution( double x );
-/* Set the frequency resolution (minimum instantaneous frequency
- difference between Partials) for the Loris Analyzer. (Does not cause
- other parameters to be recomputed.)
- */
-
-void analyzer_setHopTime( double x );
-/* Set the hop time (which corresponds approximately to the average
- density of Partial envelope Breakpoint data) for the Loris Analyzer.
- */
-
-void analyzer_setSidelobeLevel( double x );
-/* Set the sidelobe attenutation level for the Kaiser analysis window in
- positive dB. Larger numbers (e.g. 90) give very good sidelobe
- rejection but cause the window to be longer in time. Smaller
- numbers raise the level of the sidelobes, increasing the likelihood
- of frequency-domain interference, but allow the window to be shorter
- in time.
- */
-
-void analyzer_setWindowWidth( double x );
-/* Set the frequency-domain main lobe width (measured between
- zero-crossings) of the analysis window used by the Loris Analyzer.
- */
-
-void analyzer_storeResidueBandwidth( double regionWidth );
-/* Construct Partial bandwidth envelopes during analysis
- by associating residual energy in the spectrum (after
- peak extraction) with the selected spectral peaks that
- are used to construct Partials.
-
- regionWidth is the width (in Hz) of the bandwidth
- association regions used by this process, must be positive.
- */
-
-void analyzer_storeConvergenceBandwidth( double tolerancePct );
-/* Construct Partial bandwidth envelopes during analysis
- by storing the mixed derivative of short-time phase,
- scaled and shifted so that a value of 0 corresponds
- to a pure sinusoid, and a value of 1 corresponds to a
- bandwidth-enhanced sinusoid with maximal energy spread
- (minimum sinusoidal convergence).
-
- tolerance is the amount of range over which the
- mixed derivative indicator should be allowed to drift away
- from a pure sinusoid before saturating. This range is mapped
- to bandwidth values on the range [0,1]. Must be positive and
- not greater than 1.
- */
-
-void analyzer_storeNoBandwidth( void );
-/* Disable bandwidth envelope construction. Bandwidth
- will be zero for all Breakpoints in all Partials.
- */
-
-double analyzer_getBwRegionWidth( void );
-/* Return the width (in Hz) of the Bandwidth Association regions
- used by this Analyzer, only if the spectral residue method is
- used to compute bandwidth envelopes. Return zero if the mixed
- derivative method is used, or if no bandwidth is computed.
- */
-
-double analyzer_getBwConvergenceTolerance( void );
-/* Return the mixed derivative convergence tolerance
- only if the convergence indicator is used to compute
- bandwidth envelopes. Return zero if the spectral residue
- method is used or if no bandwidth is computed.
- */
-
-
-/* ---------------------------------------------------------------- */
-/* LinearEnvelope object interface
-/*
-/* A LinearEnvelope represents a linear segment breakpoint
- function with infinite extension at each end (that is, the
- values past either end of the breakpoint function have the
- values at the nearest end).
-
- In C++, a LinearEnvelope is a Loris::LinearEnvelope.
- */
-
-LinearEnvelope * createLinearEnvelope( void );
-/* Construct and return a new LinearEnvelope having no
- breakpoints and an implicit value of 0. everywhere,
- until the first breakpoint is inserted.
- */
-
-LinearEnvelope * copyLinearEnvelope( const LinearEnvelope * ptr_this );
-/* Construct and return a new LinearEnvelope that is an
- exact copy of the specified LinearEnvelopes, having
- an identical set of breakpoints.
- */
-
-void destroyLinearEnvelope( LinearEnvelope * ptr_this );
-/* Destroy this LinearEnvelope.
- */
-
-void linearEnvelope_insertBreakpoint( LinearEnvelope * ptr_this,
- double time, double val );
-/* Insert a breakpoint representing the specified (time, value)
- pair into this LinearEnvelope. If there is already a
- breakpoint at the specified time, it will be replaced with
- the new breakpoint.
- */
-
-double linearEnvelope_valueAt( const LinearEnvelope * ptr_this,
- double time );
-/* Return the interpolated value of this LinearEnvelope at the
- specified time.
- */
-
-/* ---------------------------------------------------------------- */
-/* PartialList object interface
-/*
-/* A PartialList represents a collection of Bandwidth-Enhanced
- Partials, each having a trio of synchronous, non-uniformly-
- sampled breakpoint envelopes representing the time-varying
- frequency, amplitude, and noisiness of a single bandwidth-
- enhanced sinusoid.
-
- For more information about Bandwidth-Enhanced Partials and the
- Reassigned Bandwidth-Enhanced Additive Sound Model, refer to
- the Loris website: www.cerlsoundgroup.org/Loris/.
-
- In C++, a PartialList is a Loris::PartialList.
- */
-PartialList * createPartialList( void );
-/* Return a new empty PartialList.
- */
-
-void destroyPartialList( PartialList * ptr_this );
-/* Destroy this PartialList.
- */
-
-void partialList_clear( PartialList * ptr_this );
-/* Remove (and destroy) all the Partials from this PartialList,
- leaving it empty.
- */
-
-void partialList_copy( PartialList * ptr_this,
- const PartialList * src );
-/* Make this PartialList a copy of the source PartialList by making
- copies of all of the Partials in the source and adding them to
- this PartialList.
- */
-
-unsigned long partialList_size( const PartialList * ptr_this );
-/* Return the number of Partials in this PartialList.
- */
-
-void partialList_splice( PartialList * ptr_this,
- PartialList * src );
-/* Splice all the Partials in the source PartialList onto the end of
- this PartialList, leaving the source empty.
- */
-
-/* ---------------------------------------------------------------- */
-/* Partial object interface
-/*
-/* A Partial represents a single component in the
- reassigned bandwidth-enhanced additive model. A Partial consists of a
- chain of Breakpoints describing the time-varying frequency, amplitude,
- and bandwidth (or noisiness) envelopes of the component, and a 4-byte
- label. The Breakpoints are non-uniformly distributed in time. For more
- information about Reassigned Bandwidth-Enhanced Analysis and the
- Reassigned Bandwidth-Enhanced Additive Sound Model, refer to the Loris
- website: www.cerlsoundgroup.org/Loris/.
- */
-
-double partial_startTime( const Partial * p );
-/* Return the start time (seconds) for the specified Partial.
- */
-
-double partial_endTime( const Partial * p );
-/* Return the end time (seconds) for the specified Partial.
- */
-
-double partial_duration( const Partial * p );
-/* Return the duration (seconds) for the specified Partial.
- */
-
-double partial_initialPhase( const Partial * p );
-/* Return the initial phase (radians) for the specified Partial.
- */
-
-int partial_label( const Partial * p );
-/* Return the integer label for the specified Partial.
- */
-
-unsigned long partial_numBreakpoints( const Partial * p );
-/* Return the number of Breakpoints in the specified Partial.
- */
-
-double partial_frequencyAt( const Partial * p, double t );
-/* Return the frequency (Hz) of the specified Partial interpolated
- at a particular time. It is an error to apply this function to
- a Partial having no Breakpoints.
- */
-
-double partial_bandwidthAt( const Partial * p, double t );
-/* Return the bandwidth of the specified Partial interpolated
- at a particular time. It is an error to apply this function to
- a Partial having no Breakpoints.
- */
-
-double partial_phaseAt( const Partial * p, double t );
-/* Return the phase (radians) of the specified Partial interpolated
- at a particular time. It is an error to apply this function to
- a Partial having no Breakpoints.
- */
-
-double partial_amplitudeAt( const Partial * p, double t );
-/* Return the (absolute) amplitude of the specified Partial interpolated
- at a particular time. Partials are assumed to fade out
- over 1 millisecond at the ends (rather than instantaneously).
- It is an error to apply this function to a Partial having no Breakpoints.
- */
-
-void partial_setLabel( Partial * p, int label );
-/* Assign a new integer label to the specified Partial.
- */
-
-/* ---------------------------------------------------------------- */
-/* Breakpoint object interface
-/*
-/* A Breakpoint represents a single breakpoint in the
- Partial parameter (frequency, amplitude, bandwidth) envelope.
- Instantaneous phase is also stored, but is only used at the onset of
- a partial, or when it makes a transition from zero to nonzero amplitude.
-
- Loris Partials represent reassigned bandwidth-enhanced model components.
- A Partial consists of a chain of Breakpoints describing the time-varying
- frequency, amplitude, and bandwidth (noisiness) of the component.
- For more information about Reassigned Bandwidth-Enhanced
- Analysis and the Reassigned Bandwidth-Enhanced Additive Sound
- Model, refer to the Loris website:
- www.cerlsoundgroup.org/Loris/.
- */
-
-double breakpoint_getAmplitude( const Breakpoint * bp );
-/* Return the (absolute) amplitude of the specified Breakpoint.
- */
-
-double breakpoint_getBandwidth( const Breakpoint * bp );
-/* Return the bandwidth coefficient of the specified Breakpoint.
- */
-
-double breakpoint_getFrequency( const Breakpoint * bp );
-/* Return the frequency (Hz) of the specified Breakpoint.
- */
-
-double breakpoint_getPhase( const Breakpoint * bp );
-/* Return the phase (radians) of the specified Breakpoint.
- */
-
-void breakpoint_setAmplitude( Breakpoint * bp, double a );
-/* Assign a new (absolute) amplitude to the specified Breakpoint.
- */
-
-void breakpoint_setBandwidth( Breakpoint * bp, double bw );
-/* Assign a new bandwidth coefficient to the specified Breakpoint.
- */
-
-void breakpoint_setFrequency( Breakpoint * bp, double f );
-/* Assign a new frequency (Hz) to the specified Breakpoint.
- */
-
-void breakpoint_setPhase( Breakpoint * bp, double phi );
-/* Assign a new phase (radians) to the specified Breakpoint.
- */
-
-/* ---------------------------------------------------------------- */
-/* non-object-based procedures
-/*
-/* Operations in Loris that need not be accessed though object
- interfaces are represented as simple functions.
- */
-
-void channelize( PartialList * partials,
- LinearEnvelope * refFreqEnvelope, int refLabel );
-/* Label Partials in a PartialList with the integer nearest to
- the amplitude-weighted average ratio of their frequency envelope
- to a reference frequency envelope. The frequency spectrum is
- partitioned into non-overlapping channels whose time-varying
- center frequencies track the reference frequency envelope.
- The reference label indicates which channel's center frequency
- is exactly equal to the reference envelope frequency, and other
- channels' center frequencies are multiples of the reference
- envelope frequency divided by the reference label. Each Partial
- in the PartialList is labeled with the number of the channel
- that best fits its frequency envelope. The quality of the fit
- is evaluated at the breakpoints in the Partial envelope and
- weighted by the amplitude at each breakpoint, so that high-
- amplitude breakpoints contribute more to the channel decision.
- Partials are labeled, but otherwise unmodified. In particular,
- their frequencies are not modified in any way.
- */
-
-void collate( PartialList * partials );
-/* Collate unlabeled (zero-labeled) Partials into the smallest-possible
- number of Partials that does not combine any overlapping Partials.
- Collated Partials appear at the end of the sequence, after all
- labeled Partials.
- */
-
-LinearEnvelope *
-createFreqReference( PartialList * partials,
- double minFreq, double maxFreq, long numSamps );
-/* Return a newly-constructed LinearEnvelope using the legacy
- FrequencyReference class. The envelope will have approximately
- the specified number of samples. The specified number of samples
- must be greater than 1. Uses the FundamentalEstimator
- (FundamentalFromPartials) class to construct an estimator of
- fundamental frequency, configured to emulate the behavior of
- the FrequencyReference class in Loris 1.4-1.5.2. If numSamps
- is zero, construct the reference envelope from fundamental
- estimates taken every five milliseconds.
-
- For simple sounds, this frequency reference may be a
- good first approximation to a reference envelope for
- channelization (see channelize()).
-
- Clients are responsible for disposing of the newly-constructed
- LinearEnvelope.
- */
-
-LinearEnvelope *
-createF0Estimate( PartialList * partials, double minFreq, double maxFreq,
- double interval );
-/* Return a newly-constructed LinearEnvelope that estimates
- the time-varying fundamental frequency of the sound
- represented by the Partials in a PartialList. This uses
- the FundamentalEstimator (FundamentalFromPartials)
- class to construct an estimator of fundamental frequency,
- and returns a LinearEnvelope that samples the estimator at the
- specified time interval (in seconds). Default values are used
- to configure the estimator. Only estimates in the specified
- frequency range will be considered valid, estimates outside this
- range will be ignored.
-
- Clients are responsible for disposing of the newly-constructed
- LinearEnvelope.
- */
-
-void dilate( PartialList * partials,
- const double * initial, const double * target, int npts );
-/* Dilate Partials in a PartialList according to the given
- initial and target time points. Partial envelopes are
- stretched and compressed so that temporal features at
- the initial time points are aligned with the final time
- points. Time points are sorted, so Partial envelopes are
- are only stretched and compressed, but breakpoints are not
- reordered. Duplicate time points are allowed. There must be
- the same number of initial and target time points.
- */
-
-void distill( PartialList * partials );
-/* Distill labeled (channelized) Partials in a PartialList into a
- PartialList containing at most one Partial per label. Unlabeled
- (zero-labeled) Partials are left unmodified at the end of the
- distilled Partials.
- */
-
-void exportAiff( const char * path, const double * buffer,
- unsigned int bufferSize, double samplerate, int bitsPerSamp );
-/* Export mono audio samples stored in an array of size bufferSize to
- an AIFF file having the specified sample rate at the given file path
- (or name). The floating point samples in the buffer are clamped to the
- range (-1.,1.) and converted to integers having bitsPerSamp bits.
- */
-
-void exportSdif( const char * path, PartialList * partials );
-/* Export Partials in a PartialList to a SDIF file at the specified
- file path (or name). SDIF data is described by RBEM and RBEL
- matrices.
- For more information about SDIF, see the SDIF web site at:
- www.ircam.fr/equipes/analyse-synthese/sdif/
- */
-
-void exportSpc( const char * path, PartialList * partials, double midiPitch,
- int enhanced, double endApproachTime );
-/* Export Partials in a PartialList to a Spc file at the specified file
- path (or name). The fractional MIDI pitch must be specified. The
- enhanced parameter defaults to true (for bandwidth-enhanced spc files),
- but an be specified false for pure-sines spc files. The endApproachTime
- parameter is in seconds. A nonzero endApproachTime indicates that the plist does
- not include a release, but rather ends in a static spectrum corresponding
- to the final breakpoint values of the partials. The endApproachTime
- specifies how long before the end of the sound the amplitude, frequency,
- and bandwidth values are to be modified to make a gradual transition to
- the static spectrum.
- */
-
-/* Apply a reference Partial to fix the frequencies of Breakpoints
- whose amplitude is below threshold_dB. 0 harmonifies full-amplitude
- Partials, to apply only to quiet Partials, specify a lower
- threshold like -90). The reference Partial is the first Partial
- in the PartialList labeled refLabel (usually 1). The LinearEnvelope
- is a time-varying weighting on the harmonifing process. When 1,
- harmonic frequencies are used, when 0, breakpoint frequencies are
- unmodified.
- */
-void harmonify( PartialList * partials, long refLabel,
- const LinearEnvelope * env, double threshold_dB );
-
-unsigned int importAiff( const char * path, double * buffer, unsigned int bufferSize,
- double * samplerate );
-/* Import audio samples stored in an AIFF file at the given file
- path (or name). The samples are converted to floating point
- values on the range (-1.,1.) and stored in an array of doubles.
- The value returned is the number of samples in buffer, and it is at
- most bufferSize. If samplerate is not a NULL pointer,
- then, on return, it points to the value of the sample rate (in
- Hz) of the AIFF samples. The AIFF file must contain only a single
- channel of audio data. The prior contents of buffer, if any, are
- overwritten.
- */
-
-void importSdif( const char * path, PartialList * partials );
-/* Import Partials from an SDIF file at the given file path (or
- name), and append them to a PartialList.
- */
-
-void importSpc( const char * path, PartialList * partials );
-/* Import Partials from an Spc file at the given file path (or
- name), and return them in a PartialList.
- */
-
-void morph( const PartialList * src0, const PartialList * src1,
- const LinearEnvelope * ffreq,
- const LinearEnvelope * famp,
- const LinearEnvelope * fbw,
- PartialList * dst );
-/* Morph labeled Partials in two PartialLists according to the
- given frequency, amplitude, and bandwidth (noisiness) morphing
- envelopes, and append the morphed Partials to the destination
- PartialList. Loris morphs Partials by interpolating frequency,
- amplitude, and bandwidth envelopes of corresponding Partials in
- the source PartialLists. For more information about the Loris
- morphing algorithm, see the Loris website:
- www.cerlsoundgroup.org/Loris/
- */
-
-void morphWithReference( const PartialList * src0,
- const PartialList * src1,
- long src0RefLabel,
- long src1RefLabel,
- const LinearEnvelope * ffreq,
- const LinearEnvelope * famp,
- const LinearEnvelope * fbw,
- PartialList * dst );
-/* Morph labeled Partials in two PartialLists according to the
- given frequency, amplitude, and bandwidth (noisiness) morphing
- envelopes, and append the morphed Partials to the destination
- PartialList. Specify the labels of the Partials to be used as
- reference Partial for the two morph sources. The reference
- partial is used to compute frequencies for very low-amplitude
- Partials whose frequency estimates are not considered reliable.
- The reference Partial is considered to have good frequency
- estimates throughout. A reference label of 0 indicates that
- no reference Partial should be used for the corresponding
- morph source.
-
- Loris morphs Partials by interpolating frequency,
- amplitude, and bandwidth envelopes of corresponding Partials in
- the source PartialLists. For more information about the Loris
- morphing algorithm, see the Loris website:
- www.cerlsoundgroup.org/Loris/
- */
-
-void morpher_setAmplitudeShape( double shape );
-/* Set the shaping parameter for the amplitude morphing
- function. This shaping parameter controls the slope of
- the amplitude morphing function, for values greater than
- 1, this function gets nearly linear (like the old
- amplitude morphing function), for values much less than
- 1 (e.g. 1E-5) the slope is gently curved and sounds
- pretty "linear", for very small values (e.g. 1E-12) the
- curve is very steep and sounds un-natural because of the
- huge jump from zero amplitude to very small amplitude.
-
- Use LORIS_DEFAULT_AMPMORPHSHAPE to obtain the default
- amplitude morphing shape for Loris, (equal to 1E-5,
- which works well for many musical instrument morphs,
- unless Loris was compiled with the symbol
- LINEAR_AMP_MORPHS defined, in which case
- LORIS_DEFAULT_AMPMORPHSHAPE is equal to
- LORIS_LINEAR_AMPMORPHSHAPE).
-
- Use LORIS_LINEAR_AMPMORPHSHAPE to approximate the linear
- amplitude morphs performed by older versions of Loris.
-
- The amplitude shape must be positive.
- */
-
-extern const double LORIS_DEFAULT_AMPMORPHSHAPE;
-extern const double LORIS_LINEAR_AMPMORPHSHAPE;
-
-void resample( PartialList * partials, double interval );
-/* Resample all Partials in a PartialList using the specified
- sampling interval, so that the Breakpoints in the Partial
- envelopes will all lie on a common temporal grid.
- The Breakpoint times in resampled Partials will comprise a
- contiguous sequence of integer multiples of the sampling interval,
- beginning with the multiple nearest to the Partial's start time and
- ending with the multiple nearest to the Partial's end time. Resampling
- is performed in-place.
-
- */
-
-void shapeSpectrum( PartialList * partials, PartialList * surface,
- double stretchFreq, double stretchTime );
-/* Scale the amplitudes of a set of Partials by applying
- a spectral suface constructed from another set.
- Stretch the spectral surface in time and frequency
- using the specified stretch factors. Set the stretch
- factors to one for no stretching.
- */
-
-void sift( PartialList * partials );
-/* Identify overlapping Partials having the same (nonzero)
- label. If any two partials with same label
- overlap in time, set the label of the weaker
- (having less total energy) partial to zero.
-
- */
-
-unsigned int
-synthesize( const PartialList * partials,
- double * buffer, unsigned int bufferSize,
- double srate );
-/* Synthesize Partials in a PartialList at the given sample
- rate, and store the (floating point) samples in a buffer of
- size bufferSize. The buffer is neither resized nor
- cleared before synthesis, so newly synthesized samples are
- added to any previously computed samples in the buffer, and
- samples beyond the end of the buffer are lost. Return the
- number of samples synthesized, that is, the index of the
- latest sample in the buffer that was modified.
- */
-
-/* ---------------------------------------------------------------- */
-/* utility functions
-/*
-/* Operations for transforming and manipulating collections
- of Partials.
- */
-
-double avgAmplitude( const Partial * p );
-/* Return the average amplitude over all Breakpoints in this Partial.
- Return zero if the Partial has no Breakpoints.
- */
-
-double avgFrequency( const Partial * p );
-/* Return the average frequency over all Breakpoints in this Partial.
- Return zero if the Partial has no Breakpoints.
- */
-
-void copyIf( const PartialList * src, PartialList * dst,
- int ( * predicate )( const Partial * p, void * data ),
- void * data );
-/* Append copies of Partials in the source PartialList satisfying the
- specified predicate to the destination PartialList. The source list
- is unmodified. The data parameter can be used to
- supply extra user-defined data to the function. Pass 0 if no
- additional data is needed.
- */
-
-void copyLabeled( const PartialList * src, long label, PartialList * dst );
-/* Append copies of Partials in the source PartialList having the
- specified label to the destination PartialList. The source list
- is unmodified.
- */
-
-void crop( PartialList * partials, double t1, double t2 );
-/* Trim Partials by removing Breakpoints outside a specified time span.
- Insert a Breakpoint at the boundary when cropping occurs. Remove
- any Partials that are left empty after cropping (Partials having no
- Breakpoints between t1 and t2).
- */
-
-void extractIf( PartialList * src, PartialList * dst,
- int ( * predicate )( const Partial * p, void * data ),
- void * data );
-/* Remove Partials in the source PartialList satisfying the
- specified predicate from the source list and append them to
- the destination PartialList. The data parameter can be used to
- supply extra user-defined data to the function. Pass 0 if no
- additional data is needed.
- */
-
-void extractLabeled( PartialList * src, long label, PartialList * dst );
-/* Remove Partials in the source PartialList having the specified
- label from the source list and append them to the destination
- PartialList.
- */
-
-void fixPhaseAfter( PartialList * partials, double time );
-/* Recompute phases of all Breakpoints later than the specified
- time so that the synthesized phases of those later Breakpoints
- matches the stored phase, as long as the synthesized phase at
- the specified time matches the stored (not recomputed) phase.
-
- Phase fixing is only applied to non-null (nonzero-amplitude)
- Breakpoints, because null Breakpoints are interpreted as phase
- reset points in Loris. If a null is encountered, its phase is
- corrected from its non-Null successor, if it has one, otherwise
- it is unmodified.
- */
-
-void fixPhaseAt( PartialList * partials, double time );
-/* Recompute phases of all Breakpoints in a Partial
- so that the synthesized phases match the stored phases,
- and the synthesized phase at (nearest) the specified
- time matches the stored (not recomputed) phase.
-
- Backward phase-fixing stops if a null (zero-amplitude)
- Breakpoint is encountered, because nulls are interpreted as
- phase reset points in Loris. If a null is encountered, the
- remainder of the Partial (the front part) is fixed in the
- forward direction, beginning at the start of the Partial.
- Forward phase fixing is only applied to non-null
- (nonzero-amplitude) Breakpoints. If a null is encountered,
- its phase is corrected from its non-Null successor, if
- it has one, otherwise it is unmodified.
- */
-
-void fixPhaseBefore( PartialList * partials, double time );
-/* Recompute phases of all Breakpoints earlier than the specified
- time so that the synthesized phases of those earlier Breakpoints
- matches the stored phase, and the synthesized phase at the
- specified time matches the stored (not recomputed) phase.
-
- Backward phase-fixing stops if a null (zero-amplitude) Breakpoint
- is encountered, because nulls are interpreted as phase reset
- points in Loris. If a null is encountered, the remainder of the
- Partial (the front part) is fixed in the forward direction,
- beginning at the start of the Partial.
- */
-
-void fixPhaseBetween( PartialList * partials, double tbeg, double tend );
-/*
- Fix the phase travel between two times by adjusting the
- frequency and phase of Breakpoints between those two times.
-
- This algorithm assumes that there is nothing interesting
- about the phases of the intervening Breakpoints, and modifies
- their frequencies as little as possible to achieve the correct
- amount of phase travel such that the frequencies and phases at
- the specified times match the stored values. The phases of all
- the Breakpoints between the specified times are recomputed.
- */
-
-void fixPhaseForward( PartialList * partials, double tbeg, double tend );
-/* Recompute phases of all Breakpoints later than the specified
- time so that the synthesized phases of those later Breakpoints
- matches the stored phase, as long as the synthesized phase at
- the specified time matches the stored (not recomputed) phase.
- Breakpoints later than tend are unmodified.
-
- Phase fixing is only applied to non-null (nonzero-amplitude)
- Breakpoints, because null Breakpoints are interpreted as phase
- reset points in Loris. If a null is encountered, its phase is
- corrected from its non-Null successor, if it has one, otherwise
- it is unmodified.
- */
-
-int forEachBreakpoint( Partial * p,
- int ( * func )( Breakpoint * p, double time, void * data ),
- void * data );
-/* Apply a function to each Breakpoint in a Partial. The function
- is called once for each Breakpoint in the source Partial. The
- function may modify the Breakpoint (but should not otherwise attempt
- to modify the Partial). The data parameter can be used to supply extra
- user-defined data to the function. Pass 0 if no additional data is needed.
- The function should return 0 if successful. If the function returns
- a non-zero value, then forEachBreakpoint immediately returns that value
- without applying the function to any other Breakpoints in the Partial.
- forEachBreakpoint returns zero if all calls to func return zero.
- */
-
-int forEachPartial( PartialList * src,
- int ( * func )( Partial * p, void * data ),
- void * data );
-/* Apply a function to each Partial in a PartialList. The function
- is called once for each Partial in the source PartialList. The
- function may modify the Partial (but should not attempt to modify
- the PartialList). The data parameter can be used to supply extra
- user-defined data to the function. Pass 0 if no additional data
- is needed. The function should return 0 if successful. If the
- function returns a non-zero value, then forEachPartial immediately
- returns that value without applying the function to any other
- Partials in the PartialList. forEachPartial returns zero if all
- calls to func return zero.
- */
-
-double peakAmplitude( const Partial * p );
-/* Return the maximum amplitude achieved by a Partial.
- */
-
-void removeIf( PartialList * src,
- int ( * predicate )( const Partial * p, void * data ),
- void * data );
-/* Remove from a PartialList all Partials satisfying the
- specified predicate. The data parameter can be used to
- supply extra user-defined data to the function. Pass 0 if no
- additional data is needed.
- */
-
-void removeLabeled( PartialList * src, long label );
-/* Remove from a PartialList all Partials having the specified label.
- */
-
-void scaleAmplitude( PartialList * partials, LinearEnvelope * ampEnv );
-/* Scale the amplitude of the Partials in a PartialList according
- to an envelope representing a time-varying amplitude scale value.
- */
-
-void scaleAmp( PartialList * partials, LinearEnvelope * ampEnv );
-/* Bad old name for scaleAmplitude.
- */
-
-void scaleBandwidth( PartialList * partials, LinearEnvelope * bwEnv );
-/* Scale the bandwidth of the Partials in a PartialList according
- to an envelope representing a time-varying bandwidth scale value.
- */
-
-void scaleFrequency( PartialList * partials, LinearEnvelope * freqEnv );
-/* Scale the frequency of the Partials in a PartialList according
- to an envelope representing a time-varying frequency scale value.
- */
-
-void scaleNoiseRatio( PartialList * partials, LinearEnvelope * noiseEnv );
-/* Scale the relative noise content of the Partials in a PartialList
- according to an envelope representing a (time-varying) noise energy
- scale value.
- */
-
-void setBandwidth( PartialList * partials, LinearEnvelope * bwEnv );
-/* Set the bandwidth of the Partials in a PartialList according
- to an envelope representing a time-varying bandwidth value.
- */
-
-void shiftPitch( PartialList * partials, LinearEnvelope * pitchEnv );
-/* Shift the pitch of all Partials in a PartialList according to
- the given pitch envelope. The pitch envelope is assumed to have
- units of cents (1/100 of a halfstep).
- */
-
-void shiftTime( PartialList * partials, double offset );
-/* Shift the time of all the Breakpoints in a Partial by a
- constant amount.
- */
-
-void sortByLabel( PartialList * partials );
-/* Sort the Partials in a PartialList in order of increasing label.
- The sort is stable; Partials having the same label are not
- reordered.
- */
-
-void timeSpan( PartialList * partials, double * tmin, double * tmax );
-/* Return the minimum start time and maximum end time
- in seconds of all Partials in this PartialList. The v
- times are returned in the (non-null) pointers tmin
- and tmax.
- */
-
-double weightedAvgFrequency( const Partial * p );
-/* Return the average frequency over all Breakpoints in this Partial,
- weighted by the Breakpoint amplitudes. Return zero if the Partial
- has no Breakpoints.
- */
-
-/* ---------------------------------------------------------------- */
-/* Notification and exception handlers
-/*
-/* An exception handler and a notifier may be specified. Both
- are functions taking a const char * argument and returning
- void.
- */
-
-void setExceptionHandler( void(*f)(const char *) );
-/* Specify a function to call when reporting exceptions. The
- function takes a const char * argument, and returns void.
- */
-
-void setNotifier( void(*f)(const char *) );
-/* Specify a notification function. The function takes a
- const char * argument, and returns void.
- */
-
-#if defined(__cplusplus)
-} /* extern "C" */
-#endif
-
-#endif /* ndef INCLUDE_LORIS_H */
diff --git a/loris_library/Source/include/loris/AiffData.h b/loris_library/Source/include/loris/AiffData.h
deleted file mode 100644
index fb07ed2..0000000
--- a/loris_library/Source/include/loris/AiffData.h
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * AiffData.h
- *
- * Declarations of import and export functions.
- *
- * Kelly Fitz, 17 Sept 2003
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "Marker.h"
-
-#include
-#include
-
-// in case configure wasn't run (no config.h),
-// pick some (hopefully-) reasonable values for
-// these things and hope for the best...
-#if ! defined( SIZEOF_SHORT )
-#define SIZEOF_SHORT 2
-#endif
-
-#if ! defined( SIZEOF_INT )
-#define SIZEOF_INT 4
-#endif
-
-#if ! defined( SIZEOF_LONG )
-#define SIZEOF_LONG 4 // not for DEC Alpha!
-#endif
-
-
-#if SIZEOF_SHORT == 2
-typedef short Int_16;
-typedef unsigned short Uint_16;
-#elif SIZEOF_INT == 2
-typedef int Int_16;
-typedef unsigned int Uint_16;
-#else
-#error "cannot find an appropriate type for 16-bit integers"
-#endif
-
-#if SIZEOF_INT == 4
-typedef int Int_32;
-typedef unsigned int Uint_32;
-#elif SIZEOF_LONG == 4
-typedef long Int_32;
-typedef unsigned long Uint_32;
-#else
-#error "cannot find an appropriate type for 32-bit integers"
-#endif
-
-
-// begin namespace
-namespace Loris {
-
-// -- chunk types --
-enum
-{
- ContainerId = 0x464f524d, // 'FORM'
- AiffType = 0x41494646, // 'AIFF'
- CommonId = 0x434f4d4d, // 'COMM'
- ApplicationSpecificId = 0x4150504c, // 'APPL'
- SosEnvelopesId = 0x534f5365, // 'SOSe'
- SoundDataId = 0x53534e44, // 'SSND'
- InstrumentId = 0x494e5354, // 'INST'
- MarkerId = 0x4d41524b // 'MARK'
-};
-
-typedef Uint_32 ID;
-typedef char Byte;
-
-struct CkHeader
-{
- ID id;
- Uint_32 size;
-
- // providing this default constructor
- // gives clients a way to determine whether
- // a chunk has been read and assigned:
- CkHeader( void ) : id(0), size(0) {}
-};
-
-struct ContainerCk
-{
- CkHeader header;
- ID formType;
-};
-
-struct CommonCk
-{
- CkHeader header;
- Int_16 channels; // number of channels
- Int_32 sampleFrames; // channel independent sample frames
- Int_16 bitsPerSample; // number of bits per sample
- double srate; // sampling rate (stored in IEEE 10 byte format)
-};
-
-struct SoundDataCk
-{
- CkHeader header;
- Uint_32 offset;
- Uint_32 blockSize;
-
- // sample frames follow
- std::vector< Byte > sampleBytes;
-};
-
-struct MarkerCk
-{
- CkHeader header;
- Uint_16 numMarkers;
-
- struct Marker
- {
- Uint_16 markerID;
- Uint_32 position; // position in uncompressed samples
- std::string markerName;
- };
-
- std::vector< MarkerCk::Marker > markers;
-};
-
-struct InstrumentCk
-{
- CkHeader header;
- Byte baseNote; /* all notes are MIDI note numbers */
- Byte detune; /* cents off, only -50 to +50 are significant */
- Byte lowNote;
- Byte highNote;
- Byte lowVelocity; /* 1 to 127 */
- Byte highVelocity; /* 1 to 127 */
- Int_16 gain; /* in dB, 0 is normal */
-
- struct Loop
- {
- Int_16 playMode; /* 0 - no loop, 1 - forward looping, 2 - backward looping */
- Uint_16 beginLoop; /* this is a reference to a markerID, so you always
- ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ have to work with MARK and INST together!! */
- Uint_16 endLoop;
- };
-
- Loop sustainLoop;
- Loop releaseLoop;
-};
-
-
-struct SosEnvelopesCk
-{
- CkHeader header;
- Int_32 signature; // For SOS, should be 'SOSe'
- Int_32 enhanced; // 0 for sine-only, 1 for bandwidth-enhanced
- Int_32 validPartials; // Number of partials with data in them; the file must
- // be padded out to the next higher 2**n partials;
- // this number is doubled for enhanced files
-
- // skip validPartials * sizeof(Int_32) bytes of junk here
- Int_32 resolution; // frame duration in microseconds
- Int_32 quasiHarmonic; // how many of the partials are quasiharmonic
- // skip
- // (4*LargestLabel + 8 - validPartials - 2) * sizeof(Int_32)
- // bytes of junk here
-
-/*
- // this stuff is unbelievably nasty!
-
-#define initPhaseLth ( 4*LargestLabel + 8 )
- Int_32 initPhase[initPhaseLth]; // obsolete initial phase array; is VARIABLE LENGTH array
- // this is big enough for a max of 512 enhanced partials plus values below
-// Int_32 resolution; // frame duration in microseconds
- #define SOSresolution( es ) initPhase[ spcEI.enhanced \
- ? 2 * spcEI.numPartials : spcEI.numPartials]
- // follows the initPhase[] array
-
-
-// Int_32 quasiHarmonic; // how many of the partials are quasiharmonic
- #define SOSquasiHarmonic( es ) initPhase[ spcEI.enhanced \
- ? 2 * spcEI.numPartials + 1 : spcEI.numPartials + 1]
- // follows the initPhase[] array
-*/
-};
-
-// ---------------------------------------------------------------------------
-// readChunkHeader
-// ---------------------------------------------------------------------------
-// Read the id and chunk size from the current file position.
-// Let exceptions propogate.
-//
-std::istream &
-readChunkHeader( std::istream & s, CkHeader & h );
-
-
-// ---------------------------------------------------------------------------
-// readApplicationSpecifcData
-// ---------------------------------------------------------------------------
-// Read the data in the ApplicationSpecific chunk, assume the stream is
-// correctly positioned, and that the chunk header has already been read.
-//
-// Look for data specific to SPC files. Any other kind of Application
-// Specific data is ignored.
-//
-std::istream &
-readApplicationSpecifcData( std::istream & s, SosEnvelopesCk & ck, unsigned long chunkSize );
-
-
-// ---------------------------------------------------------------------------
-// readCommonData
-// ---------------------------------------------------------------------------
-// Read the data in the Common chunk, assume the stream is correctly
-// positioned, and that the chunk header has already been read.
-//
-std::istream &
-readCommonData( std::istream & s, CommonCk & ck, unsigned long chunkSize );
-
-// ---------------------------------------------------------------------------
-// readContainer
-// ---------------------------------------------------------------------------
-//
-std::istream &
-readContainer( std::istream & s, ContainerCk & ck, unsigned long chunkSize );
-
-// ---------------------------------------------------------------------------
-// readInstrumentData
-// ---------------------------------------------------------------------------
-//
-std::istream &
-readInstrumentData( std::istream & s, InstrumentCk & ck, unsigned long chunkSize );
-
-// ---------------------------------------------------------------------------
-// readMarkerData
-// ---------------------------------------------------------------------------
-//
-std::istream &
-readMarkerData( std::istream & s, MarkerCk & ck, unsigned long chunkSize );
-
-// ---------------------------------------------------------------------------
-// readSampleData
-// ---------------------------------------------------------------------------
-// Read the data in the Sound Data chunk, assume the stream is correctly
-// positioned, and that the chunk header has already been read.
-//
-std::istream &
-readSampleData( std::istream & s, SoundDataCk & ck, unsigned long chunkSize );
-
-// ---------------------------------------------------------------------------
-// configureCommonCk
-// ---------------------------------------------------------------------------
-void
-configureCommonCk( CommonCk & ck, unsigned long nFrames, unsigned int nChans,
- unsigned int bps, double srate );
-
-// ---------------------------------------------------------------------------
-// configureContainer
-// ---------------------------------------------------------------------------
-// dataSize is the combined size of all other chunks in file. Configure
-// them first, then add their sizes (with headers!).
-//
-void
-configureContainer( ContainerCk & ck, unsigned long dataSize );
-
-// ---------------------------------------------------------------------------
-// configureInstrumentCk
-// ---------------------------------------------------------------------------
-void
-configureInstrumentCk( InstrumentCk & ck, double midiNoteNum );
-
-// ---------------------------------------------------------------------------
-// configureMarkerCk
-// ---------------------------------------------------------------------------
-void
-configureMarkerCk( MarkerCk & ck, const std::vector< Marker > & markers,
- double srate );
-
-// ---------------------------------------------------------------------------
-// configureSoundDataCk
-// ---------------------------------------------------------------------------
-//
-void
-configureSoundDataCk( SoundDataCk & ck, const std::vector< double > & samples,
- unsigned int bps );
-
-// ---------------------------------------------------------------------------
-// writeCommon
-// ---------------------------------------------------------------------------
-//
-std::ostream &
-writeCommonData( std::ostream & s, const CommonCk & ck );
-
-// ---------------------------------------------------------------------------
-// writeContainer
-// ---------------------------------------------------------------------------
-//
-std::ostream &
-writeContainer( std::ostream & s, const ContainerCk & ck );
-
-// ---------------------------------------------------------------------------
-// writeInstrumentData
-// ---------------------------------------------------------------------------
-std::ostream &
-writeInstrumentData( std::ostream & s, const InstrumentCk & ck );
-
-// ---------------------------------------------------------------------------
-// writeMarkerData
-// ---------------------------------------------------------------------------
-std::ostream &
-writeMarkerData( std::ostream & s, const MarkerCk & ck );
-
-// ---------------------------------------------------------------------------
-// writeSampleData
-// ---------------------------------------------------------------------------
-//
-std::ostream &
-writeSampleData( std::ostream & s, const SoundDataCk & ck );
-
-// ---------------------------------------------------------------------------
-// convertBytesToSamples
-// ---------------------------------------------------------------------------
-// Convert sample bytes to double precision floating point samples
-// (-1.0, 1.0). The samples vector is resized to fit exactly as many
-// samples as are represented in the bytes vector, and any prior
-// contents are overwritten.
-//
-void
-convertBytesToSamples( const std::vector< Byte > & bytes,
- std::vector< double > & samples, unsigned int bps );
-
-// ---------------------------------------------------------------------------
-// convertSamplesToBytes
-// ---------------------------------------------------------------------------
-// Convert floating point samples (-1.0, 1.0) to bytes.
-// The bytes vector is resized to fit exactly as many
-// samples as are stored in the samples vector, and any prior
-// contents are overwritten.
-//
-void
-convertSamplesToBytes( const std::vector< double > & samples,
- std::vector< Byte > & bytes, unsigned int bps );
-
-} // end of namespace
diff --git a/loris_library/Source/include/loris/AiffFile.h b/loris_library/Source/include/loris/AiffFile.h
deleted file mode 100644
index 55c2bc7..0000000
--- a/loris_library/Source/include/loris/AiffFile.h
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * AiffFile.h
- *
- * Definition of AiffFile class for sample import and export in Loris.
- *
- * Kelly Fitz, 8 Jan 2003
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-#include "Marker.h"
-#include "Synthesizer.h"
-
-#if defined(NO_TEMPLATE_MEMBERS)
-#include "PartialList.h"
-#endif
-
-#include
-#include
-#include
-
-// begin namespace
-namespace Loris {
-
-class Partial;
-
-// ---------------------------------------------------------------------------
-// class AiffFile
-//
-//! Class AiffFile represents sample data in a AIFF-format samples
-//! file, and manages file I/O and sample conversion. Since the sound
-//! analysis and synthesis algorithms in Loris and the reassigned
-//! bandwidth-enhanced representation are monaural, AiffFile imports
-//! only monaural (single channel) AIFF-format samples files, though
-//! it can create and export a new two-channel file from a pair of
-//! sample vectors.
-//
-class AiffFile
-{
-// -- public interface --
-public:
-
-// -- types --
-
- //! The type of the sample storage in an AiffFile.
- typedef std::vector< double > samples_type;
-
- //! The type of all size parameters for AiffFile.
- typedef samples_type::size_type size_type;
-
- //! The type of AIFF marker storage in an AiffFile.
- typedef std::vector< Marker > markers_type;
-
-// -- construction --
-
- //! Initialize an instance of AiffFile by importing sample data from
- //! the file having the specified filename or path.
- //!
- //! \param filename is the name or path of an AIFF samples file
- explicit AiffFile( const std::string & filename );
-
- //! Initialize an instance of AiffFile with samples rendered
- //! from a sequnence of Partials. The Partials in the
- //! specified half-open (STL-style) range are rendered at
- //! the specified sample rate, using the (optionally)
- //! specified Partial fade time (see Synthesizer.h
- //! for an examplanation of fade time). Other synthesis
- //! parameters are taken from the Synthesizer DefaultParameters.
- //!
- //! \sa Synthesizer::DefaultParameters
- //!
- //! \param begin_partials is the beginning of a sequence of Partials
- //! \param end_partials is (one-past) the end of a sequence of
- //! Partials
- //! \param samplerate is the rate (Hz) at which Partials are rendered
- //! \param fadeTime is the Partial fade time (seconds) for rendering
- //! the Partials on the specified range. If unspecified, the
- //! fade time is taken from the Synthesizer DefaultParameters.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
- //! only PartialList::const_iterator arguments.
-#if !defined(NO_TEMPLATE_MEMBERS)
- template
- AiffFile( Iter begin_partials, Iter end_partials,
- double samplerate, double fadeTime = FadeTimeUnspecified );
-#else
- AiffFile( PartialList::const_iterator begin_partials,
- PartialList::const_iterator end_partials,
- double samplerate, double fadeTime = FadeTimeUnspecified );
-#endif
-
- //! Initialize an instance of AiffFile having the specified sample
- //! rate, preallocating numFrames samples, initialized to zero.
- //!
- //! \param samplerate is the rate at which Partials are rendered
- //! \param numFrames is the initial number of (zero) samples. If
- //! unspecified, no samples are preallocated.
- //! \param numChannels is the number of channels of audio data
- //! to preallocate (default 1 channel)
- AiffFile( double samplerate, size_type numFrames = 0,
- unsigned int numChannels = 1 );
-
- //! Initialize an instance of AiffFile from a buffer of sample
- //! data, with the specified sample rate.
- //!
- //! \param buffer is a pointer to a buffer of floating point samples.
- //! \param bufferlength is the number of samples in the buffer.
- //! \param samplerate is the sample rate of the samples in the buffer.
- AiffFile( const double * buffer, size_type bufferlength, double samplerate );
-
- //! Initialize an instance of AiffFile from two buffers of sample
- //! data, with the specified sample rate. Both buffers must store
- //! the same number (bufferLength) of samples.
- //!
- //! \param buffer_left is a pointer to a buffer of floating point samples
- //! representing the left channel samples.
- //! \param buffer_right is a pointer to a buffer of floating point samples
- //! representing the right channel samples.
- //! \param bufferlength is the number of samples in the buffer.
- //! \param samplerate is the sample rate of the samples in the buffer.
- //
- AiffFile( const double * buffer_left, const double * buffer_right,
- size_type bufferlength, double samplerate );
-
- //! Initialize an instance of AiffFile from a vector of sample
- //! data, with the specified sample rate.
- //!
- //! \param vec is a vector of floating point samples.
- //! \param samplerate is the sample rate of the samples in the vector.
- AiffFile( const std::vector< double > & vec, double samplerate );
-
- //! Initialize an instance of AiffFile from two vectors of sample
- //! data, with the specified sample rate. If the two vectors have different
- //! lengths, the shorter one is padded with zeros.
- //!
- //! \param vec_left is a vector of floating point samples representing the
- //! left channel samples.
- //! \param vec_right is a vector of floating point samples representing the
- //! right channel samples.
- //! \param samplerate is the sample rate of the samples in the vectors.
- //
- AiffFile( const std::vector< double > & vec_left,
- const std::vector< double > & vec_right,
- double samplerate );
-
- //! Initialize this and AiffFile that is an exact copy, having
- //! all the same sample data, as another AiffFile.
- //!
- //! \param other is the AiffFile to copy
- AiffFile( const AiffFile & other );
-
- //! Assignment operator: change this AiffFile to be an exact copy
- //! of the specified AiffFile, rhs, that is, having the same sample
- //! data.
- //!
- //! \param rhs is the AiffFile to replicate
- AiffFile & operator= ( const AiffFile & rhs );
-
-// -- access --
-
- //! Return a reference to the Marker (see Marker.h) container
- //! for this AiffFile.
- markers_type & markers( void );
-
- //! Return a const reference to the Marker (see Marker.h) container
- //! for this AiffFile.
- const markers_type & markers( void ) const;
-
- //! Return the fractional MIDI note number assigned to this AiffFile.
- //! If the sound has no definable pitch, note number 60.0 is used.
- double midiNoteNumber( void ) const;
-
- //! Return the number of channels of audio samples represented by
- //! this AiffFile, 1 for mono, 2 for stereo.
- unsigned int numChannels( void ) const;
-
- //! Return the number of sample frames represented in this AiffFile.
- //! A sample frame contains one sample per channel for a single sample
- //! interval (e.g. mono and stereo samples files having a sample rate of
- //! 44100 Hz both have 44100 sample frames per second of audio samples).
- size_type numFrames( void ) const;
-
- //! Bad old legacy name for numFrames.
- //! \deprecated Use numFrames instead.
- size_type sampleFrames( void ) const { return numFrames(); }
-
- //! Return the sampling freqency in Hz for the sample data in this
- //! AiffFile.
- double sampleRate( void ) const;
-
- //! Return a reference (or const reference) to the vector containing
- //! the floating-point sample data for this AiffFile.
- samples_type & samples( void );
-
- //! Return a const reference (or const reference) to the vector containing
- //! the floating-point sample data for this AiffFile.
- const samples_type & samples( void ) const;
-
-// -- mutation --
-
- //! Render the specified Partial using the (optionally) specified
- //! Partial fade time (see Synthesizer.h for an examplanation
- //! of fade time), and accumulate the resulting samples into
- //! the sample vector for this AiffFile. Other synthesis parameters
- //! are taken from the Synthesizer DefaultParameters.
- //!
- //! \sa Synthesizer::DefaultParameters
- //!
- //! \param p is the partial to render into this AiffFile
- //! \param fadeTime is the Partial fade time for rendering
- //! the Partials on the specified range. If unspecified, the
- //! fade time is taken from the Synthesizer DefaultParameters.
- void addPartial( const Loris::Partial & p, double fadeTime = FadeTimeUnspecified );
-
- //! Accumulate samples rendered from a sequence of Partials.
- //! The Partials in the specified half-open (STL-style) range are
- //! rendered at this AiffFile's sample rate, using the (optionally)
- //! specified Partial fade time (see Synthesizer.h for an examplanation
- //! of fade time). Other synthesis parameters are taken from the
- //! Synthesizer DefaultParameters.
- //!
- //! \sa Synthesizer::DefaultParameters
- //!
- //! \param begin_partials is the beginning of a sequence of Partials
- //! \param end_partials is (one-past) the end of a sequence of
- //! Partials
- //! \param fadeTime is the Partial fade time for rendering
- //! the Partials on the specified range. If unspecified, the
- //! fade time is taken from the Synthesizer DefaultParameters.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
- //! only PartialList::const_iterator arguments.
-#if !defined(NO_TEMPLATE_MEMBERS)
- template
- void addPartials( Iter begin_partials, Iter end_partials,
- double fadeTime = FadeTimeUnspecified );
-#else
- void addPartials( PartialList::const_iterator begin_partials,
- PartialList::const_iterator end_partials,
- double fadeTime = FadeTimeUnspecified );
-#endif
-
- //! Set the fractional MIDI note number assigned to this AiffFile.
- //! If the sound has no definable pitch, use note number 60.0 (the default).
- //!
- //! \param nn is a fractional MIDI note number, 60 is middle C.
- void setMidiNoteNumber( double nn );
-
-// -- export --
-
- //! Export the sample data represented by this AiffFile to
- //! the file having the specified filename or path. Export
- //! signed integer samples of the specified size, in bits
- //! (8, 16, 24, or 32).
- //!
- //! \param filename is the name or path of the AIFF samples file
- //! to be created or overwritten.
- //! \param bps is the number of bits per sample to store in the
- //! samples file (8, 16, 24, or 32).If unspeicified, 16 bits
- void write( const std::string & filename, unsigned int bps = 16 );
-
-private:
-// -- implementation --
- double notenum_, rate_; // MIDI note number and sample rate
- unsigned int numchans_;
- markers_type markers_; // AIFF Markers
- samples_type samples_; // floating point samples [-1.0, 1.0]
-
-
-// -- helpers --
-
- // Construct a Synthesizer for rendering Partials and set its fadeTime.
- // Modify the default synthesizer parameters with this file's sample rate
- // and, if specified (not equal to FadeTimeUnspecified), the fade time.
- Synthesizer configureSynthesizer( double fadeTime );
-
- // Import data from an AIFF file on disk.
- void readAiffData( const std::string & filename );
-
- enum { FadeTimeUnspecified = -9999999 };
- // This is not pretty, but it is better (perhaps) than defining two
- // of every member having an optional fade time parameter.
-
-}; // end of class AiffFile
-
-// -- template members --
-
-// ---------------------------------------------------------------------------
-// constructor from Partial range
-// ---------------------------------------------------------------------------
-//! Initialize an instance of AiffFile with samples rendered
-//! from a sequnence of Partials. The Partials in the
-//! specified half-open (STL-style) range are rendered at
-//! the specified sample rate, using the (optionally)
-//! specified Partial fade time (see Synthesizer.h
-//! for an examplanation of fade time). Other synthesis
-//! parameters are taken from the Synthesizer DefaultParameters.
-//!
-//! \sa Synthesizer::DefaultParameters
-//!
-//! \param begin_partials is the beginning of a sequence of Partials
-//! \param end_partials is (one-past) the end of a sequence of
-//! Partials
-//! \param samplerate is the rate (Hz) at which Partials are rendered
-//! \param fadeTime is the Partial fade time (seconds) for rendering
-//! the Partials on the specified range. If unspecified, the
-//! fade time is taken from the Synthesizer DefaultParameters.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
-//! only PartialList::const_iterator arguments.
-//
-#if !defined(NO_TEMPLATE_MEMBERS)
-template< typename Iter >
- AiffFile::AiffFile( Iter begin_partials, Iter end_partials,
- double samplerate, double fadeTime ) :
-#else
- AiffFile::AiffFile( PartialList::const_iterator begin_partials,
- PartialList::const_iterator end_partials,
- double samplerate, double fadeTime ) :
-#endif
-// initializers:
- notenum_( 60 ),
- rate_( samplerate ),
- numchans_( 1 )
-{
- addPartials( begin_partials, end_partials, fadeTime );
-}
-
-// ---------------------------------------------------------------------------
-// addPartials
-// ---------------------------------------------------------------------------
-//! Accumulate samples rendered from a sequence of Partials.
-//! The Partials in the specified half-open (STL-style) range are
-//! rendered at this AiffFile's sample rate, using the (optionally)
-//! specified Partial fade time (see Synthesizer.h for an examplanation
-//! of fade time). Other synthesis parameters are taken from the
-//! Synthesizer DefaultParameters.
-//!
-//! \sa Synthesizer::DefaultParameters
-//!
-//! \param begin_partials is the beginning of a sequence of Partials
-//! \param end_partials is (one-past) the end of a sequence of
-//! Partials
-//! \param fadeTime is the Partial fade time for rendering
-//! the Partials on the specified range. If unspecified, the
-//! fade time is taken from the Synthesizer DefaultParameters.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
-//! only PartialList::const_iterator arguments.
-//
-#if !defined(NO_TEMPLATE_MEMBERS)
-template< typename Iter >
-void
- AiffFile::addPartials( Iter begin_partials, Iter end_partials, double fadeTime )
-#else
-void
- AiffFile::addPartials( PartialList::const_iterator begin_partials,
- PartialList::const_iterator end_partials,
- double fadeTime )
-#endif
-{
- Synthesizer synth = configureSynthesizer( fadeTime );
- synth.synthesize( begin_partials, end_partials );
-}
-
-} // end of namespace Loris
diff --git a/loris_library/Source/include/loris/Analyzer.h b/loris_library/Source/include/loris/Analyzer.h
deleted file mode 100644
index 6bdfe52..0000000
--- a/loris_library/Source/include/loris/Analyzer.h
+++ /dev/null
@@ -1,620 +0,0 @@
-#ifndef INCLUDE_ANALYZER_H
-#define INCLUDE_ANALYZER_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Analyzer.h
- *
- * Definition of class Loris::Analyzer.
- *
- * Kelly Fitz, 5 Dec 99
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-#include
-#include
-#include "LinearEnvelope.h"
-#include "Partial.h"
-#include "PartialList.h"
-// #include "SpectralPeaks.h"
-
-// begin namespace
-namespace Loris {
-
-class Envelope;
-class LinearEnvelopeBuilder;
-// class Peaks;
-// class Peaks::iterator;
-// oooo, this is nasty, need to fix it!
-class SpectralPeak;
-typedef std::vector< SpectralPeak > Peaks;
-
-// ---------------------------------------------------------------------------
-// class Analyzer
-//
-//! Class Analyzer represents a configuration of parameters for
-//! performing Reassigned Bandwidth-Enhanced Additive Analysis
-//! of sampled sounds. The analysis process yields a collection
-//! of Partials, each having a trio of synchronous, non-uniformly-
-//! sampled breakpoint envelopes representing the time-varying
-//! frequency, amplitude, and noisiness of a single bandwidth-
-//! enhanced sinusoid. These Partials are accumulated in the
-//! Analyzer.
-//!
-//! The core analysis parameter is the frequency resolution, the
-//! minimum instantaneous frequency spacing between partials. Most
-//! other parameters are initially configured according to this
-//! parameter (and the analysis window width, if specified).
-//! Subsequent parameter mutations are independent.
-//!
-//! Bandwidth enhancement:
-//! Two different strategies are available for computing bandwidth
-//! (or noisiness) envelope:
-//!
-//! One strategy is to construct bandwidth envelopes during analysis
-//! by associating residual energy in the spectrum (after peak
-//! extraction) with the selected spectral peaks that are used
-//! to construct Partials. This is the original bandwidth enhancement
-//! algorithm, and bandwidth envelopes constructed in this way may
-//! be suitable for use in bandwidth-enhanced synthesis.
-//!
-//! Another stategy is to construct bandwidth envelopes during
-//! analysis by storing the mixed derivative of short-time phase,
-//! scaled and shifted so that a value of 0 corresponds
-//! to a pure sinusoid, and a value of 1 corresponds to a
-//! bandwidth-enhanced sinusoid with maximal energy spread
-//! (minimum convergence in frequency). These bandwidth envelopes
-//! are not suitable for bandwidth-enhanced synthesis, be sure
-//! to set the bandwidth to 0, or to disable bandwidth enhancement
-//! before rendering.
-//!
-//! The Analyzer may be configured to use either of these two
-//! strategies for bandwidth-enhanced analysis, or to construct
-//! no bandwidth envelopes at all. If unspecified, the default
-//! Analyzer configuration uses spectral residue to construct
-//! bandwidth envelopes.
-//!
-//! \sa storeResidueBandwidth, storeConvergenceBandwidth, storeNoBandwidth
-//!
-//! For more information about Reassigned Bandwidth-Enhanced
-//! Analysis and the Reassigned Bandwidth-Enhanced Additive Sound
-//! Model, refer to the Loris website: www.cerlsoundgroup.org/Loris/.
-//
-class Analyzer
-{
-// -- public interface --
-public:
-
-// -- construction --
-
- //! Construct a new Analyzer configured with the given
- //! frequency resolution (minimum instantaneous frequency
- //! difference between Partials). All other Analyzer parameters
- //! are computed from the specified frequency resolution.
- //!
- //! \param resolutionHz is the frequency resolution in Hz.
- explicit Analyzer( double resolutionHz );
-
- //! Construct a new Analyzer configured with the given
- //! frequency resolution (minimum instantaneous frequency
- //! difference between Partials) and analysis window width
- //! (main lobe, zero-to-zero). All other Analyzer parameters
- //! are computed from the specified resolution and window width.
- //!
- //! \param resolutionHz is the frequency resolution in Hz.
- //! \param windowWidthHz is the main lobe width of the Kaiser
- //! analysis window in Hz.
- Analyzer( double resolutionHz, double windowWidthHz );
-
- //! Construct a new Analyzer configured with the given time-varying
- //! frequency resolution (minimum instantaneous frequency
- //! difference between Partials) and analysis window width
- //! (main lobe, zero-to-zero). All other Analyzer parameters
- //! are computed from the specified resolution and window width.
- //!
- //! \param resolutionHz is the frequency resolution in Hz.
- //! \param windowWidthHz is the main lobe width of the Kaiser
- //! analysis window in Hz.
- Analyzer( const Envelope & resolutionEnv, double windowWidthHz );
-
- //! Construct a new Analyzer having identical
- //! parameter configuration to another Analyzer.
- //! The list of collected Partials is not copied.
- //!
- //! \param other is the Analyzer to copy.
- Analyzer( const Analyzer & other );
-
- //! Destroy this Analyzer.
- ~Analyzer( void );
-
- //! Construct a new Analyzer having identical
- //! parameter configuration to another Analyzer.
- //! The list of collected Partials is not copied.
- //!
- //! \param rhs is the Analyzer to copy.
- Analyzer & operator=( const Analyzer & rhs );
-
-// -- configuration --
-
- //! Configure this Analyzer with the given frequency resolution
- //! (minimum instantaneous frequency difference between Partials,
- //! in Hz). All other Analyzer parameters are (re-)computed from the
- //! frequency resolution, including the window width, which is
- //! twice the resolution.
- //!
- //! \param resolutionHz is the frequency resolution in Hz.
- void configure( double resolutionHz );
-
- //! Configure this Analyzer with the given frequency resolution
- //! (minimum instantaneous frequency difference between Partials)
- //! and analysis window width (main lobe, zero-to-zero, in Hz).
- //! All other Analyzer parameters are (re-)computed from the
- //! frequency resolution and window width.
- //!
- //! \param resolutionHz is the frequency resolution in Hz.
- //! \param windowWidthHz is the main lobe width of the Kaiser
- //! analysis window in Hz.
- //!
- //! There are three categories of analysis parameters:
- //! - the resolution, and params that are usually related to (or
- //! identical to) the resolution (frequency floor and drift)
- //! - the window width and params that are usually related to (or
- //! identical to) the window width (hop and crop times)
- //! - independent parameters (bw region width and amp floor)
- void configure( double resolutionHz, double windowWidthHz );
-
- //! Configure this Analyzer with the given time-varying frequency resolution
- //! (minimum instantaneous frequency difference between Partials)
- //! and analysis window width (main lobe, zero-to-zero, in Hz).
- //! All other Analyzer parameters are (re-)computed from the
- //! frequency resolution and window width.
- //!
- //! \param resolutionEnv is the time-varying frequency resolution
- //! in Hz.
- //! \param windowWidthHz is the main lobe width of the Kaiser
- //! analysis window in Hz.
- //!
- //! There are three categories of analysis parameters:
- //! - the resolution, and params that are usually related to (or
- //! identical to) the resolution (frequency floor and drift)
- //! - the window width and params that are usually related to (or
- //! identical to) the window width (hop and crop times)
- //! - independent parameters (bw region width and amp floor)
- //
- void configure( const Envelope & resolutionEnv, double windowWidthHz );
-
-// -- analysis --
-
- //! Analyze a vector of (mono) samples at the given sample rate
- //! (in Hz) and store the extracted Partials in the Analyzer's
- //! PartialList (std::list of Partials).
- //!
- //! \param vec is a vector of floating point samples
- //! \param srate is the sample rate of the samples in the vector
- void analyze( const std::vector & vec, double srate );
-
- //! Analyze a range of (mono) samples at the given sample rate
- //! (in Hz) and store the extracted Partials in the Analyzer's
- //! PartialList (std::list of Partials).
- //!
- //! \param bufBegin is a pointer to a buffer of floating point samples
- //! \param bufEnd is (one-past) the end of a buffer of floating point
- //! samples
- //! \param srate is the sample rate of the samples in the buffer
- void analyze( const double * bufBegin, const double * bufEnd, double srate );
-
-// -- tracking analysis --
-
- //! Analyze a vector of (mono) samples at the given sample rate
- //! (in Hz) and store the extracted Partials in the Analyzer's
- //! PartialList (std::list of Partials). Use the specified envelope
- //! as a frequency reference for Partial tracking.
- //!
- //! \param vec is a vector of floating point samples
- //! \param srate is the sample rate of the samples in the vector
- //! \param reference is an Envelope having the approximate
- //! frequency contour expected of the resulting Partials.
- void analyze( const std::vector & vec, double srate,
- const Envelope & reference );
-
- //! Analyze a range of (mono) samples at the given sample rate
- //! (in Hz) and store the extracted Partials in the Analyzer's
- //! PartialList (std::list of Partials). Use the specified envelope
- //! as a frequency reference for Partial tracking.
- //!
- //! \param bufBegin is a pointer to a buffer of floating point samples
- //! \param bufEnd is (one-past) the end of a buffer of floating point
- //! samples
- //! \param srate is the sample rate of the samples in the buffer
- //! \param reference is an Envelope having the approximate
- //! frequency contour expected of the resulting Partials.
- void analyze( const double * bufBegin, const double * bufEnd, double srate,
- const Envelope & reference );
-
-// -- parameter access --
-
- //! Return the amplitude floor (lowest detected spectral amplitude),
- //! in (negative) dB, for this Analyzer.
- double ampFloor( void ) const;
-
- //! Return the crop time (maximum temporal displacement of a time-
- //! frequency data point from the time-domain center of the analysis
- //! window, beyond which data points are considered "unreliable")
- //! for this Analyzer.
- double cropTime( void ) const;
-
- //! Return the maximum allowable frequency difference between
- //! consecutive Breakpoints in a Partial envelope for this Analyzer.
- double freqDrift( void ) const;
-
- //! Return the frequency floor (minimum instantaneous Partial
- //! frequency), in Hz, for this Analyzer.
- double freqFloor( void ) const;
-
- //! Return the frequency resolution (minimum instantaneous frequency
- //! difference between Partials) for this Analyzer at the specified
- //! time in seconds. If no time is specified, then the initial resolution
- //! (at 0 seconds) is returned.
- //!
- //! \param time is the time in seconds at which to evaluate the
- //! frequency resolution
- double freqResolution( double time = 0.0 ) const;
-
- //! Return the hop time (which corresponds approximately to the
- //! average density of Partial envelope Breakpoint data) for this
- //! Analyzer.
- double hopTime( void ) const;
-
- //! Return the sidelobe attenutation level for the Kaiser analysis window in
- //! positive dB. Larger numbers (e.g. 90) give very good sidelobe
- //! rejection but cause the window to be longer in time. Smaller numbers
- //! (like 60) raise the level of the sidelobes, increasing the likelihood
- //! of frequency-domain interference, but allow the window to be shorter
- //! in time.
- double sidelobeLevel( void ) const;
-
- //! Return the frequency-domain main lobe width (measured between
- //! zero-crossings) of the analysis window used by this Analyzer.
- double windowWidth( void ) const;
-
- //! Return true if the phases and frequencies of the constructed
- //! partials should be modified to be consistent at the end of the
- //! analysis, and false otherwise. (Default is true.)
- bool phaseCorrect( void ) const;
-
-
-// -- parameter mutation --
-
- //! Set the amplitude floor (lowest detected spectral amplitude), in
- //! (negative) dB, for this Analyzer.
- //!
- //! \param x is the new value of this parameter.
- void setAmpFloor( double x );
-
- //! Set the crop time (maximum temporal displacement of a time-
- //! frequency data point from the time-domain center of the analysis
- //! window, beyond which data points are considered "unreliable")
- //! for this Analyzer.
- //!
- //! \param x is the new value of this parameter.
- void setCropTime( double x );
-
- //! Set the maximum allowable frequency difference between
- //! consecutive Breakpoints in a Partial envelope for this Analyzer.
- //!
- //! \param x is the new value of this parameter.
- void setFreqDrift( double x );
-
- //! Set the frequency floor (minimum instantaneous Partial
- //! frequency), in Hz, for this Analyzer.
- //!
- //! \param x is the new value of this parameter.
- void setFreqFloor( double x );
-
- //! Set the frequency resolution (minimum instantaneous frequency
- //! difference between Partials) for this Analyzer. (Does not cause
- //! other parameters to be recomputed.)
- //!
- //! \param x is the new value of this parameter.
- void setFreqResolution( double x );
-
- //! Set the time-varying frequency resolution (minimum instantaneous frequency
- //! difference between Partials) for this Analyzer. (Does not cause
- //! other parameters to be recomputed.)
- //!
- //! \param e is the envelope to copy for this parameter.
- void setFreqResolution( const Envelope & e );
-
- //! Set the hop time (which corresponds approximately to the average
- //! density of Partial envelope Breakpoint data) for this Analyzer.
- //!
- //! \param x is the new value of this parameter.
- void setHopTime( double x );
-
- //! Set the sidelobe attenutation level for the Kaiser analysis window in
- //! positive dB. More negative numbers (e.g. -90) give very good sidelobe
- //! rejection but cause the window to be longer in time. Less negative
- //! numbers raise the level of the sidelobes, increasing the likelihood
- //! of frequency-domain interference, but allow the window to be shorter
- //! in time.
- //!
- //! \param x is the new value of this parameter.
- void setSidelobeLevel( double x );
-
- //! Set the frequency-domain main lobe width (measured between
- //! zero-crossings) of the analysis window used by this Analyzer.
- //!
- //! \param x is the new value of this parameter.
- void setWindowWidth( double x );
-
- //! Indicate whether the phases and frequencies of the constructed
- //! partials should be modified to be consistent at the end of the
- //! analysis. (Default is true.)
- //!
- //! \param TF is a flag indicating whether or not to construct
- //! phase-corrected Partials
- void setPhaseCorrect( bool TF = true );
-
-
-// -- bandwidth envelope specification --
-
- enum { Default_ResidueBandwidth_RegionWidth = 2000,
- Default_ConvergenceBandwidth_TolerancePct = 10 };
-
- //! Construct Partial bandwidth envelopes during analysis
- //! by associating residual energy in the spectrum (after
- //! peak extraction) with the selected spectral peaks that
- //! are used to construct Partials.
- //!
- //! This is the default bandwidth-enhancement strategy.
- //!
- //! \param regionWidth is the width (in Hz) of the bandwidth
- //! association regions used by this process, must be positive.
- //! If unspecified, a default value is used.
- void storeResidueBandwidth( double regionWidth = Default_ResidueBandwidth_RegionWidth );
-
- //! Construct Partial bandwidth envelopes during analysis
- //! by storing the mixed derivative of short-time phase,
- //! scaled and shifted so that a value of 0 corresponds
- //! to a pure sinusoid, and a value of 1 corresponds to a
- //! bandwidth-enhanced sinusoid with maximal energy spread
- //! (minimum sinusoidal convergence).
- //!
- //! \param tolerance is the amount of range over which the
- //! mixed derivative indicator should be allowed to drift away
- //! from a pure sinusoid before saturating. This range is mapped
- //! to bandwidth values on the range [0,1]. Must be positive and
- //! not greater than 1. If unspecified, a default value is used.
- void storeConvergenceBandwidth( double tolerancePct =
- 0.01 * (double)Default_ConvergenceBandwidth_TolerancePct );
-
- //! Disable bandwidth envelope construction. Bandwidth
- //! will be zero for all Breakpoints in all Partials.
- void storeNoBandwidth( void );
-
- //! Return true if this Analyzer is configured to compute
- //! bandwidth envelopes using the spectral residue after
- //! peaks have been identified, and false otherwise.
- bool bandwidthIsResidue( void ) const;
-
- //! Return true if this Analyzer is configured to compute
- //! bandwidth envelopes using the mixed derivative convergence
- //! indicator, and false otherwise.
- bool bandwidthIsConvergence( void ) const;
-
- //! Return the width (in Hz) of the Bandwidth Association regions
- //! used by this Analyzer, only if the spectral residue method is
- //! used to compute bandwidth envelopes. Return zero if the mixed
- //! derivative method is used, or if no bandwidth is computed.
- double bwRegionWidth( void ) const;
-
- //! Return the mixed derivative convergence tolerance (percent)
- //! only if the convergence indicator is used to compute
- //! bandwidth envelopes. Return zero if the spectral residue
- //! method is used or if no bandwidth is computed.
- double bwConvergenceTolerance( void ) const;
-
- //! Return true if bandwidth envelopes are to be constructed
- //! by any means, that is, if either bandwidthIsResidue() or
- //! bandwidthIsConvergence() are true. Otherwise, return
- //! false.
- bool associateBandwidth( void ) const
- { return bandwidthIsResidue() || bandwidthIsConvergence(); }
-
- //! Deprecated, use storeResidueBandwidth or storeNoBandwidth instead.
- void setBwRegionWidth( double x )
- {
- if ( x != 0 )
- {
- storeResidueBandwidth( x );
- }
- else
- {
- storeNoBandwidth();
- }
- }
-
-
-// -- PartialList access --
-
- //! Return a mutable reference to this Analyzer's list of
- //! analyzed Partials.
- PartialList & partials( void );
-
- //! Return an immutable (const) reference to this Analyzer's
- //! list of analyzed Partials.
- const PartialList & partials( void ) const;
-
-// -- envelope access --
-
- enum { Default_FundamentalEnv_ThreshDb = -60,
- Default_FundamentalEnv_ThreshHz = 8000 };
-
- //! Specify parameters for constructing a fundamental frequency
- //! envelope for the analyzed sound during analysis. The fundamental
- //! frequency estimate can be accessed by fundamentalEnv() after the
- //! analysis is complete.
- //!
- //! By default, a fundamental envelope is estimated during analysis
- //! between the frequency resolution and 1.5 times the resolution.
- //!
- //! \param fmin is the lower bound on the fundamental frequency estimate
- //! \param fmax is the upper bound on the fundamental frequency estimate
- //! \param threshDb is the lower bound on the amplitude of a spectral peak
- //! that will constribute to the fundamental frequency estimate (very
- //! low amplitude peaks tend to have less reliable frequency estimates).
- //! Default is -60 dB.
- //! \param threshHz is the upper bound on the frequency of a spectral
- //! peak that will constribute to the fundamental frequency estimate.
- //! Default is 8 kHz.
- void buildFundamentalEnv( double fmin, double fmax,
- double threshDb = Default_FundamentalEnv_ThreshDb,
- double threshHz = Default_FundamentalEnv_ThreshHz );
-
-
- //! Return the fundamental frequency estimate envelope constructed
- //! during the most recent analysis performed by this Analyzer.
- //!
- //! By default, a fundamental envelope is estimated during analysis
- //! between the frequency resolution and 1.5 times the resolution.
- const LinearEnvelope & fundamentalEnv( void ) const;
-
- //! Return the overall amplitude estimate envelope constructed
- //! during the most recent analysis performed by this Analyzer.
- const LinearEnvelope & ampEnv( void ) const;
-
-
-// -- legacy support --
-
- // Fundamental and amplitude envelopes are always constructed during
- // analysis, these members do nothing, and are retained for backwards
- // compatibility.
- void buildAmpEnv( bool TF = true ) { TF = TF; }
- void buildFundamentalEnv( bool TF = true ) { TF = TF; }
-
-// -- private member variables --
-
-private:
-
- std::auto_ptr< Envelope > m_freqResolutionEnv;
- //! in Hz, minimum instantaneous frequency distance;
- //! this is the core parameter, others are, by default,
- //! computed from this one
-
- double m_ampFloor; //! dB, relative to full amplitude sine wave, absolute
- //! amplitude threshold (negative)
-
- double m_windowWidth; //! in Hz, width of main lobe; this might be more
- //! conveniently presented as window length, but
- //! the main lobe width more explicitly highlights
- //! the critical interaction with resolution
-
- // std::auto_ptr< Envelope > m_freqFloorEnv;
- double m_freqFloor; //! lowest frequency (Hz) component extracted
- //! in spectral analysis
-
- double m_freqDrift; //! the maximum frequency (Hz) difference between two
- //! consecutive Breakpoints that will be linked to
- //! form a Partial
-
- double m_hopTime; //! in seconds, time between analysis windows in
- //! successive spectral analyses
-
- double m_cropTime; //! in seconds, maximum time correction for a spectral
- //! component to be considered reliable, and to be eligible
- //! for extraction and for Breakpoint formation
-
- double m_bwAssocParam; //! formerly, width in Hz of overlapping bandwidth
- //! association regions, or zero if bandwidth association
- //! is disabled, now a catch-all bandwidth association
- //! parameter that, if negative, indicates the tolerance (%)
- //! level used to construct bandwidth envelopes from the
- //! mixed phase derivative indicator
-
- double m_sidelobeLevel; //! sidelobe attenutation level for the Kaiser analysis
- //! window, in positive dB
-
- bool m_phaseCorrect; //! flag indicating that phases/frequencies should be
- //! made consistent at the end of the analysis
-
- PartialList m_partials; //! collect Partials here
-
- //! builder object for constructing a fundamental frequency
- //! estimate during analysis
- std::auto_ptr< LinearEnvelopeBuilder > m_f0Builder;
-
- //! builder object for constructing an amplitude
- //! estimate during analysis
- std::auto_ptr< LinearEnvelopeBuilder > m_ampEnvBuilder;
-
-// -- private auxiliary functions --
-// future development
-/*
-
- // These members make up the sequence of operations in an
- // analysis. If analysis were ever to be made into a
- // template method, these would be the operations that
- // derived classes could override. Or each of these could
- // be represented by a strategy class.
-
- //! Compute the spectrum of the next sequence of samples.
- void computeSpectrum( void );
-
- //! Identify and select the spectral components that will be
- //! used to form Partials.
- void selectPeaks( void );
-
- //! Compute the bandwidth coefficients for the Breakpoints
- //! that are going to be used to form Partials.
- void associateBandwidth( void );
-
- //! Construct Partials from extracted spectral components.
- //! Partials are built up frame by frame by appending
- //! Breakpoints to Partials under construction, and giving
- //! birth to new Partials using unmatched Peaks.
- void formPartials( Peaks & peaks );
-*/
- // Reject peaks that are too close in frequency to a louder peak that is
- // being retained, and peaks that are too quiet. Peaks that are retained,
- // but are quiet enough to be in the specified fadeRange should be faded.
- //
- // Rejected peaks are placed at the end of the peak collection.
- // Return the first position in the collection containing a rejected peak,
- // or the end of the collection if no peaks are rejected.
- Peaks::iterator thinPeaks( Peaks & peaks, double frameTime );
-
- // Fix the bandwidth value stored in the specified Peaks.
- // This function is invoked if the spectral residue method is
- // not used to compute bandwidth (that method overwrites the
- // bandwidth already). If the convergence method is used to
- // compute bandwidth, the appropriate scaling is applied
- // to the stored mixed phase derivative. Otherwise, the
- // Peak bandwidth is set to zero.
- void fixBandwidth( Peaks & peaks );
-
-}; // end of class Analyzer
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_ANALYZER_H */
diff --git a/loris_library/Source/include/loris/AssociateBandwidth.h b/loris_library/Source/include/loris/AssociateBandwidth.h
deleted file mode 100644
index 475aeb0..0000000
--- a/loris_library/Source/include/loris/AssociateBandwidth.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef INCLUDE_ASSOCIATEBANDWIDTH_H
-#define INCLUDE_ASSOCIATEBANDWIDTH_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * AssociateBandwidth.h
- *
- * Definition of a class representing a policy for associating noise
- * (bandwidth) energy with reassigned spectral peaks to be used in
- * Partial formation.
- *
- * Kelly Fitz, 20 Jan 2000
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "SpectralPeaks.h"
-
-#include
-
-// begin namespace
-namespace Loris {
-
-class Breakpoint;
-
-// ---------------------------------------------------------------------------
-// class AssociateBandwidth
-//
-// In the new strategy, Breakpoints are extracted and accumulated
-// as sinusoids. Spectral peaks that are not extracted (don't exceed
-// the amplitude floor) or are rejected for certain reasons, are
-// accumulated diectly as noise (surplus). After all spectral peaks
-// have been accumulated as noise or sinusoids, the noise is distributed
-// as bandwidth.
-//
-class AssociateBandwidth
-{
-// -- instance variables --
- std::vector< double > _weights; // weights vector for recording
- // frequency distribution of retained
- // sinusoids
- std::vector< double > _surplus; // surplus (noise) energy vector for
- // accumulating the distribution of
- // spectral energy to be distributed
- // as noise
-
- double _regionRate; // inverse of region center spacing
-
-// -- public interface --
-public:
- // construction:
- AssociateBandwidth( double regionWidth, double srate );
- ~AssociateBandwidth( void );
-
- // Perform bandwidth association on a collection of reassigned spectral peaks
- // or ridges. The range [begin, rejected) spans the Peaks selected to form
- // Partials. The range [rejected, end) spans the Peaks that were found in
- // the reassigned spectrum, but rejected as too weak or too close (in
- // frequency) to another stronger Peak.
- void associateBandwidth( Peaks::iterator begin, // beginning of Peaks
- Peaks::iterator rejected, // first rejected Peak
- Peaks::iterator end ); // end of Peaks
-
-
-// -- private helpers --
-private:
- double computeNoiseEnergy( double freq, double amp );
-
- // These four formerly comprised the public interface
- // to this policy, now they are all hidden behind a
- // single call to associateBandwidth.
-
- // energy accumulation:
- void accumulateNoise( double freq, double amp );
- void accumulateSinusoid( double freq, double amp );
-
- // bandwidth assocation:
- void associate( SpectralPeak & pk );
-
- // call this to wipe out the accumulated energy to
- // prepare for the next frame (yuk):
- void reset( void );
-
-}; // end of class AssociateBandwidth
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_ASSOCIATEBANDWIDTH_H */
diff --git a/loris_library/Source/include/loris/BigEndian.h b/loris_library/Source/include/loris/BigEndian.h
deleted file mode 100644
index d4d70e8..0000000
--- a/loris_library/Source/include/loris/BigEndian.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef INCLUDE_BIGENDIAN_H
-#define INCLUDE_BIGENDIAN_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * BigEndian.h
- *
- * Definition of wrappers for stream-based binary file i/o.
- *
- * Kelly Fitz, 23 May 2000
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class BigEndian
-//
-class BigEndian
-{
-public:
- static std::istream & read( std::istream & s, long howmany, int size, char * putemHere );
- static std::ostream & write( std::ostream & s, long howmany, int size, const char * stuff );
-}; // end of class BigEndian
-
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_BIGENDIAN_H */
diff --git a/loris_library/Source/include/loris/Breakpoint.h b/loris_library/Source/include/loris/Breakpoint.h
deleted file mode 100644
index 31123dd..0000000
--- a/loris_library/Source/include/loris/Breakpoint.h
+++ /dev/null
@@ -1,133 +0,0 @@
-#ifndef INCLUDE_BREAKPOINT_H
-#define INCLUDE_BREAKPOINT_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Breakpoint.h
- *
- * Definition of class Loris::Breakpoint.
- *
- * Kelly Fitz, 16 Aug 99
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-// begin namespace
-namespace Loris {
-
-
-// ---------------------------------------------------------------------------
-// class Breakpoint
-//
-//! Class Breakpoint represents a single breakpoint in the
-//! Partial parameter (frequency, amplitude, bandwidth) envelope.
-//! Instantaneous phase is also stored, but is only used at the onset of
-//! a partial, or when it makes a transition from zero to nonzero amplitude.
-//!
-//! Loris Partials represent reassigned bandwidth-enhanced model components.
-//! A Partial consists of a chain of Breakpoints describing the time-varying
-//! frequency, amplitude, and bandwidth (noisiness) of the component.
-//! For more information about Reassigned Bandwidth-Enhanced
-//! Analysis and the Reassigned Bandwidth-Enhanced Additive Sound
-//! Model, refer to the Loris website:
-//! www.cerlsoundgroup.org/Loris/.
-//!
-//! Breakpoint is a leaf class, do not subclass.
-//
-class Breakpoint
-{
-// -- instance variables --
- double _frequency; //! in Hertz
- double _amplitude; //! absolute
- double _bandwidth; //! fraction of total energy that is noise energy
- double _phase; //! radians
-
-// -- public Breakpoint interface --
-
-public:
-// -- construction --
-
- //! Construct a new Breakpoint with all parameters initialized to 0
- //! (needed for STL containability).
- Breakpoint( void );
-
- //! Construct a new Breakpoint with the specified parameters.
- //!
- //! \param f is the intial frequency.
- //! \param a is the initial amplitude.
- //! \param b is the initial bandwidth.
- //! \param p is the initial phase, if specified (if unspecified, 0
- //! is assumed).
- Breakpoint( double f, double a, double b, double p = 0. );
-
- // (use compiler-generated destructor, copy, and assign)
-
-// -- access --
- //! Return the amplitude of this Breakpoint.
- double amplitude( void ) const { return _amplitude; }
-
- //! Return the bandwidth (noisiness) coefficient of this Breakpoint.
- double bandwidth( void ) const { return _bandwidth; }
-
- //! Return the frequency of this Breakpoint.
- double frequency( void ) const { return _frequency; }
-
- //! Return the phase of this Breakpoint.
- double phase( void ) const { return _phase; }
-
-// -- mutation --
- //! Set the amplitude of this Breakpoint.
- //!
- //! \param x is the new amplitude
- void setAmplitude( double x ) { _amplitude = x; }
-
- //! Set the bandwidth (noisiness) coefficient of this Breakpoint.
- //!
- //! \param x is the new bandwidth
- void setBandwidth( double x ) { _bandwidth = x; }
-
- //! Set the frequency of this Breakpoint.
- //!
- //! \param x is the new frequency.
- void setFrequency( double x ) { _frequency = x; }
-
- //! Set the phase of this Breakpoint.
- //!
- //! \param x is the new phase.
- void setPhase( double x ) { _phase = x; }
-
- //! Add noise (bandwidth) energy to this Breakpoint by computing new
- //! amplitude and bandwidth values. enoise may be negative, but
- //! noise energy cannot be removed (negative energy added) in excess
- //! of the current noise energy.
- //!
- //! \param enoise is the amount of noise energy to add to
- //! this Breakpoint.
- void addNoiseEnergy( double enoise );
-
-}; // end of class Breakpoint
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_BREAKPOINT_H */
diff --git a/loris_library/Source/include/loris/BreakpointEnvelope.h b/loris_library/Source/include/loris/BreakpointEnvelope.h
deleted file mode 100644
index 383626a..0000000
--- a/loris_library/Source/include/loris/BreakpointEnvelope.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef INCLUDE_BREAKPOINTENVELOPE_H
-#define INCLUDE_BREAKPOINTENVELOPE_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * BreakpointEnvelope.h
- *
- * Definition of class BreakpointEnvelope.
- * This class has been renamed LinearEnvelope. The old
- * name and header are preserved for compatibility.
- *
- * Kelly Fitz, 21 July 2000
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "LinearEnvelope.h"
-
-// begin namespace
-namespace Loris {
-
- typedef LinearEnvelope BreakpointEnvelope;
-
-}
-
-#endif /* ndef INCLUDE_BREAKPOINTENVELOPE_H */
diff --git a/loris_library/Source/include/loris/BreakpointUtils.h b/loris_library/Source/include/loris/BreakpointUtils.h
deleted file mode 100644
index 41fd106..0000000
--- a/loris_library/Source/include/loris/BreakpointUtils.h
+++ /dev/null
@@ -1,217 +0,0 @@
-#ifndef INCLUDE_BREAKPOINTUTILS_H
-#define INCLUDE_BREAKPOINTUTILS_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * BreakpointUtils.h
- *
- * Breakpoint utility functions collected in namespace BreakpointUtils.
- *
- * Kelly Fitz, 6 July 2000
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "Breakpoint.h"
-#include
-#include
-
-// begin namespace
-namespace Loris {
-
-namespace BreakpointUtils {
-
-// -- free functions --
-
-// ---------------------------------------------------------------------------
-// addNoiseEnergy
-// ---------------------------------------------------------------------------
-//! Add noise (bandwidth) energy to a Breakpoint by computing new
-//! amplitude and bandwidth values. enoise may be negative, but
-//! noise energy cannot be removed (negative energy added) in excess
-//! of the current noise energy.
-//!
-//! \deprecated This operation is now part of the Breakpoint interface.
-//! Use Breakpoint::addNoiseEnergy instead.
-//
-inline void addNoiseEnergy( Breakpoint & bp, double enoise )
-{
- bp.addNoiseEnergy(enoise);
-}
-
-// ---------------------------------------------------------------------------
-// makeNullBefore
-// ---------------------------------------------------------------------------
-//! Return a null (zero-amplitude) Breakpoint to preceed the specified
-//! Breakpoint, useful for fading in a Partial.
-//!
-//! \param bp make a null Breakpoint to preceed this one
-//! \param fadeTime the time (in seconds) by which the new null Breakpoint
-//! should preceed bp
-//! \return a new null Breakpoint, having zero amplitude, frequency equal
-//! to that of bp, and phase computed back from that of bp
-//
-Breakpoint makeNullBefore( const Breakpoint & bp, double fadeTime ); // see BreakpointUtils.C
-
-
-// ---------------------------------------------------------------------------
-// addNoiseEnergy
-// ---------------------------------------------------------------------------
-//! Return a null (zero-amplitude) Breakpoint to succeed the specified
-//! Breakpoint, useful for fading out a Partial.
-//!
-//! \param bp make a null Breakpoint to succeed this one
-//! \param fadeTime the time (in seconds) by which the new null Breakpoint
-//! should succeed bp
-//! \return a new null Breakpoint, having zero amplitude, frequency equal
-//! to that of bp, and phase computed forward from that of bp
-//
-Breakpoint makeNullAfter( const Breakpoint & bp, double fadeTime ); // see BreakpointUtils.C
-
-// -- predicates --
-
-// ---------------------------------------------------------------------------
-// isFrequencyBetween
-//
-//! Predicate functor returning true if its Breakpoint argument
-//! has frequency between specified bounds, and false otherwise.
-//
-class isFrequencyBetween :
- public std::unary_function< const Breakpoint, bool >
-{
-public:
- //! Return true if its Breakpoint argument has frequency
- //! between specified bounds, and false otherwise.
- bool operator()( const Breakpoint & b ) const
- {
- return (b.frequency() > _fmin) &&
- (b.frequency() < _fmax);
- }
-
-// constructor:
-
- //! Construct a predicate functor, specifying two frequency bounds.
- isFrequencyBetween( double x, double y ) :
- _fmin( x ), _fmax( y )
- {
- if (x>y) std::swap(x,y);
- }
-
-// bounds:
-private:
- double _fmin, _fmax;
-};
-
-//! Old name for isFrequencyBetween.
-//! \deprecated use isFrequencyBetween instead.
-typedef isFrequencyBetween frequency_between;
-
-// ---------------------------------------------------------------------------
-// isNonNull
-//
-//! Predicate functor returning true if a Breakpoint has non-zero
-//! amplitude, false otherwise.
-//
-static bool isNonNull( const Breakpoint & bp )
-{
- return bp.amplitude() != 0.;
-}
-
-// ---------------------------------------------------------------------------
-// isNull
-//
-//! Predicate functor returning true if a Breakpoint has zero
-//! amplitude, false otherwise.
-//
-static bool isNull( const Breakpoint & bp )
-{
- return ! isNonNull( bp );
-}
-
-// -- comparitors --
-
-// ---------------------------------------------------------------------------
-// compareFrequencyLess
-//
-//! Comparitor (binary) functor returning true if its first Breakpoint
-//! argument has frequency less than that of its second Breakpoint argument,
-//! and false otherwise.
-//
-class compareFrequencyLess :
- public std::binary_function< const Breakpoint, const Breakpoint, bool >
-{
-public:
- //! Return true if its first Breakpoint argument has frequency less
- //! than that of its second Breakpoint argument, and false otherwise.
- bool operator()( const Breakpoint & lhs, const Breakpoint & rhs ) const
- { return lhs.frequency() < rhs.frequency(); }
-};
-
-//! Old name for compareFrequencyLess.
-//! \deprecated use compareFrequencyLess instead.
-typedef compareFrequencyLess less_frequency;
-
-// ---------------------------------------------------------------------------
-// compareAmplitudeGreater
-//
-//! Comparitor (binary) functor returning true if its first Breakpoint
-//! argument has amplitude greater than that of its second Breakpoint argument,
-//! and false otherwise.
-//
-class compareAmplitudeGreater :
- public std::binary_function< const Breakpoint, const Breakpoint, bool >
-{
-public:
- //! Return true if its first Breakpoint argument has amplitude greater
- //! than that of its second Breakpoint argument, and false otherwise.
- bool operator()( const Breakpoint & lhs, const Breakpoint & rhs ) const
- { return lhs.amplitude() > rhs.amplitude(); }
-};
-
-//! Old name for compareAmplitudeGreater.
-//! \deprecated use compareAmplitudeGreater instead.
-typedef compareAmplitudeGreater greater_amplitude;
-
-// ---------------------------------------------------------------------------
-// compareAmplitudeLess
-//
-//! Comparitor (binary) functor returning true if its first Breakpoint
-//! argument has amplitude less than that of its second Breakpoint argument,
-//! and false otherwise.
-//
-class compareAmplitudeLess :
- public std::binary_function< const Breakpoint, const Breakpoint, bool >
-{
-public:
- //! Return true if its first Breakpoint argument has amplitude greater
- //! than that of its second Breakpoint argument, and false otherwise.
- bool operator()( const Breakpoint & lhs, const Breakpoint & rhs ) const
- { return lhs.amplitude() < rhs.amplitude(); }
-};
-
-} // end of namespace BreakpointUtils
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_BREAKPOINTUTILS_H */
diff --git a/loris_library/Source/include/loris/Channelizer.h b/loris_library/Source/include/loris/Channelizer.h
deleted file mode 100644
index d57932b..0000000
--- a/loris_library/Source/include/loris/Channelizer.h
+++ /dev/null
@@ -1,526 +0,0 @@
-#ifndef INCLUDE_CHANNELIZER_H
-#define INCLUDE_CHANNELIZER_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Channelizer.h
- *
- * Definition of class Loris::Channelizer.
- *
- * Kelly Fitz, 21 July 2000
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "PartialList.h"
-
-#include
-
-// begin namespace
-namespace Loris {
-
-class Envelope;
-class Partial;
-
-// ---------------------------------------------------------------------------
-// Channelizer
-//
-//! Class Channelizer represents an algorithm for automatic labeling of
-//! a sequence of Partials. Partials must be labeled in
-//! preparation for morphing (see Morpher) to establish correspondences
-//! between Partials in the morph source and target sounds.
-//!
-//! Channelized partials are labeled according to their adherence to a
-//! harmonic frequency structure with a time-varying fundamental
-//! frequency. The frequency spectrum is partitioned into
-//! non-overlapping channels having time-varying center frequencies that
-//! are harmonic (integer) multiples of a specified reference frequency
-//! envelope, and each channel is identified by a unique label equal to
-//! its harmonic number. Each Partial is assigned the label
-//! corresponding to the channel containing the greatest portion of its
-//! (the Partial's) energy.
-//!
-//! A reference frequency Envelope for channelization and the channel
-//! number to which it corresponds (1 for an Envelope that tracks the
-//! Partial at the fundamental frequency) must be specified. The
-//! reference Envelope can be constructed explcitly, point by point
-//! (using, for example, the BreakpointEnvelope class), or constructed
-//! automatically using the FrequencyReference class.
-//!
-//! The Channelizer can be configured with a stretch factor, to accomodate
-//! detuned harmonics, as in the case of piano tones. The static member
-//! computeStretchFactor can compute the apppropriate stretch factor, given
-//! a pair of partials. This computation is based on formulae given in
-//! "Understanding the complex nature of the piano tone" by Martin Keane
-//! at the Acoustics Research Centre at the University of Aukland (Feb 2004).
-//! The stretching factor must be non-negative (and is zero for perfectly
-//! tunes harmonics). Even in the case of stretched harmonics, the
-//! reference frequency envelope is assumed to track the frequency of
-//! one of the partials, and the center frequency of the corresponding
-//! channel, even though it may represent a stretched harmonic.
-//!
-//! Channelizer is a leaf class, do not subclass.
-//
-class Channelizer
-{
-// -- implementaion --
- std::auto_ptr< Envelope > _refChannelFreq; //! the reference frequency envelope
-
- int _refChannelLabel; //! the channel number corresponding to the
- //! reference frequency (1 for the fundamental)
-
- double _stretchFactor; //! stretching factor to account for
- //! detuned harmonics, as in the case of the piano;
- //! can be computed using the static member
- //! computeStretchFactor. Should be 0 for most
- //! (strongly harmonic) sounds.
-
- double _ampWeighting; //! exponent for amplitude weighting in channel
- //! computation, 0 for no weighting, 1 for linear
- //! amplitude weighting, 2 for power weighting, etc.
- //! default is 0, amplitude weighting is a bad idea
- //! for many sounds
-
-// -- public interface --
-public:
-// -- construction --
-
- //! Construct a new Channelizer using the specified reference
- //! Envelope to represent the a numbered channel. If the sound
- //! being channelized is known to have detuned harmonics, a
- //! stretching factor can be specified (defaults to 0 for no
- //! stretching). The stretching factor can be computed using
- //! the static member computeStretchFactor.
- //!
- //! \param refChanFreq is an Envelope representing the center frequency
- //! of a channel.
- //! \param refChanLabel is the corresponding channel number (i.e. 1
- //! if refChanFreq is the lowest-frequency channel, and all
- //! other channels are harmonics of refChanFreq, or 2 if
- //! refChanFreq tracks the second harmonic, etc.).
- //! \param stretchFactor is a stretching factor to account for detuned
- //! harmonics, default is 0.
- //!
- //! \throw InvalidArgument if refChanLabel is not positive.
- //! \throw InvalidArgument if stretchFactor is negative.
- Channelizer( const Envelope & refChanFreq, int refChanLabel, double stretchFactor = 0 );
-
- //! Construct a new Channelizer having a constant reference frequency.
- //! The specified frequency is the center frequency of the lowest-frequency
- //! channel (for a harmonic sound, the channel containing the fundamental
- //! Partial.
- //!
- //! \param refFreq is the reference frequency (in Hz) corresponding
- //! to the first frequency channel.
- //! \param stretchFactor is a stretching factor to account for detuned
- //! harmonics, default is 0.
- //!
- //! \throw InvalidArgument if refChanLabel is not positive.
- //! \throw InvalidArgument if stretchFactor is negative.
- Channelizer( double refFreq, double stretchFactor = 0 );
-
- //! Construct a new Channelizer that is an exact copy of another.
- //! The copy represents the same set of frequency channels, constructed
- //! from the same reference Envelope and channel number.
- //!
- //! \param other is the Channelizer to copy
- Channelizer( const Channelizer & other );
-
- //! Assignment operator: make this Channelizer an exact copy of another.
- //! This Channelizer is made to represent the same set of frequency channels,
- //! constructed from the same reference Envelope and channel number as rhs.
- //!
- //! \param rhs is the Channelizer to copy
- Channelizer & operator=( const Channelizer & rhs );
-
- //! Destroy this Channelizer.
- ~Channelizer( void );
-
-// -- channelizing --
-
- //! Label a Partial with the number of the frequency channel containing
- //! the greatest portion of its (the Partial's) energy.
- //!
- //! \param partial is the Partial to label.
- void channelize( Partial & partial ) const;
-
- //! Assign each Partial in the specified half-open (STL-style) range
- //! the label corresponding to the frequency channel containing the
- //! greatest portion of its (the Partial's) energy.
- //!
- //! \param begin is the beginning of the range of Partials to channelize
- //! \param end is (one-past) the end of the range of Partials to channelize
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
- //! must be PartialList::iterators, otherwise they can be any type
- //! of iterators over a sequence of Partials.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- void channelize( Iter begin, Iter end ) const;
-#else
- void channelize( PartialList::iterator begin, PartialList::iterator end ) const;
-#endif
-
- //! Function call operator: same as channelize().
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- void operator() ( Iter begin, Iter end ) const
-#else
- inline
- void operator() ( PartialList::iterator begin, PartialList::iterator end ) const
-#endif
- { channelize( begin, end ); }
-
- //! Compute the center frequency of one a channel at the specified
- //! time. For non-stretched harmonics, this is simply the value
- //! of the reference envelope scaled by the ratio of the specified
- //! channel number to the reference channel number. For stretched
- //! harmonics, the channel center frequency is computed using the
- //! stretch factor. See Martin Keane, "Understanding
- //! the complex nature of the piano tone", 2004, for a discussion
- //! and the source of the mode frequency stretching algorithms
- //! implemented here.
- //!
- //! \param time is the time (in seconds) at which to evalute
- //! the reference envelope
- //! \param channel is the frequency channel (or harmonic, or vibrational
- //! mode) number whose frequency is to be determined
- //! \return the center frequency in Hz of the specified frequency channel
- //! at the specified time
- double channelFrequencyAt( double time, int channel ) const;
-
- //! Compute the (fractional) channel number estimate for a Partial having a
- //! given frequency at a specified time. For ordinary harmonics, this
- //! is simply the ratio of the specified frequency to the reference
- //! frequency at the specified time. For stretched harmonics (as in
- //! a piano), the stretching factor is used to compute the frequency
- //! of the corresponding modes of a massy string. See Martin Keane,
- //! "Understanding the complex nature of the piano tone", 2004, for
- //! the source of the mode frequency stretching algorithms
- //! implemented here.
- //!
- //! \param time is the time (in seconds) at which to evalute
- //! the reference envelope
- //! \param frequency is the frequency (in Hz) for wihch the channel
- //! number is to be determined
- //! \return the channel number corresponding to the specified
- //! frequency and time
- int computeChannelNumber( double time, double frequency ) const;
-
- //! Compute the (fractional) channel number estimate for a Partial having a
- //! given frequency at a specified time. For ordinary harmonics, this
- //! is simply the ratio of the specified frequency to the reference
- //! frequency at the specified time. For stretched harmonics (as in
- //! a piano), the stretching factor is used to compute the frequency
- //! of the corresponding modes of a massy string. See Martin Keane,
- //! "Understanding the complex nature of the piano tone", 2004, for
- //! the source of the mode frequency stretching algorithms
- //! implemented here.
- //!
- //! The fractional channel number is used internally to determine
- //! a best estimate for the channel number (label) for a Partial
- //! having time-varying frequency.
- //!
- //! \param time is the time (in seconds) at which to evalute
- //! the reference envelope
- //! \param frequency is the frequency (in Hz) for wihch the channel
- //! number is to be determined
- //! \return the fractional channel number corresponding to the specified
- //! frequency and time
- double computeFractionalChannelNumber( double time, double frequency ) const;
-
-
- //! Compute the reference frequency at the specified time. For non-stretched
- //! harmonics, this is simply the ratio of the reference envelope evaluated
- //! at that time to the reference channel number, and is the center frequecy
- //! for the lowest channel. For stretched harmonics, the reference frequency
- //! is NOT equal to the center frequency of any of the channels, and is also
- //! a function of the stretch factor.
- //!
- //! \param time is the time (in seconds) at which to evalute
- //! the reference envelope
- double referenceFrequencyAt( double time ) const;
-
-// -- access/mutation --
-
- //! Return the exponent applied to amplitude before weighting
- //! the instantaneous estimate of the frequency channel number
- //! for a Partial. zero (default) for no weighting, 1 for linear
- //! amplitude weighting, 2 for power weighting, etc.
- //! Amplitude weighting is a bad idea for many sounds, particularly
- //! those with transients, for which it may emphasize the part of
- //! the Partial having the least reliable frequency estimate.
- double amplitudeWeighting( void ) const;
-
- //! Set the exponent applied to amplitude before weighting
- //! the instantaneous estimate of the frequency channel number
- //! for a Partial. zero (default) for no weighting, 1 for linear
- //! amplitude weighting, 2 for power weighting, etc.
- //! Amplitude weighting is a bad idea for many sounds, particularly
- //! those with transients, for which it may emphasize the part of
- //! the Partial having the least reliable frequency estimate.
- void setAmplitudeWeighting( double expon );
-
- //! Return the stretching factor used to account for detuned
- //! harmonics, as in a piano tone. Normally set to 0 for
- //! in-tune harmonics.
- //!
- //! The stretching factor is a small positive number for
- //! heavy vibrating strings (as in pianos) for which the
- //! mass of the string significantly affects the frequency
- //! of the vibrating modes. See Martin Keane, "Understanding
- //! the complex nature of the piano tone", 2004, for a discussion
- //! and the source of the mode frequency stretching algorithms
- //! implemented here.
- double stretchFactor( void ) const;
-
- //! Set the stretching factor used to account for detuned
- //! harmonics, as in a piano tone. Normally set to 0 for
- //! in-tune harmonics. The stretching factor for massy
- //! vibrating strings (like pianos) can be computed from
- //! the physical characteristics of the string, or using
- //! computeStretchFactor().
- //!
- //! The stretching factor is a small positive number for
- //! heavy vibrating strings (as in pianos) for which the
- //! mass of the string significantly affects the frequency
- //! of the vibrating modes. See Martin Keane, "Understanding
- //! the complex nature of the piano tone", 2004, for a discussion
- //! and the source of the mode frequency stretching algorithms
- //! implemented here.
- //!
- //! \throw InvalidArgument if stretch is negative.
- void setStretchFactor( double stretch );
-
-
-// -- static members --
-
-
- //! Static member to compute the stretch factor for a sound having
- //! (consistently) detuned harmonics, like piano tones.
- //!
- //! The stretching factor is a small positive number for
- //! heavy vibrating strings (as in pianos) for which the
- //! mass of the string significantly affects the frequency
- //! of the vibrating modes. See Martin Keane, "Understanding
- //! the complex nature of the piano tone", 2004, for a discussion
- //! and the source of the mode frequency stretching algorithms
- //! implemented here.
- //!
- //! The value returned by this function MAY NOT be a valid stretch
- //! factor. If this function returns a negative stretch factor,
- //! then the specified pair of frequencies and mode numbers cannot
- //! be used to estimate the effects of string mass on mode frequency
- //! (because the negative stretch factor implies a physical
- //! impossibility, like negative mass or negative length).
- //!
- //! \param fm is the frequency of the Mth stretched harmonic
- //! \param m is the harmonic number of the harmonic whose frequnecy is fm
- //! \param fn is the frequency of the Nth stretched harmonic
- //! \param n is the harmonic number of the harmonic whose frequnecy is fn
- //! \returns the stretching factor, usually a very small positive
- //! floating point number, or 0 for pefectly tuned harmonics
- //! (that is, if fn = n*f1).
- static double computeStretchFactor( double fm, int m, double fn, int n );
-
-
-// -- simplified interface --
-
- //! Static member that constructs an instance and applies
- //! it to a PartialList (simplified interface).
- //!
- //! Construct a Channelizer using the specified Envelope
- //! and reference label, and use it to channelize a
- //! sequence of Partials.
- //!
- //! \param partials is the sequence of Partials to
- //! channelize.
- //! \param refChanFreq is an Envelope representing the center frequency
- //! of a channel.
- //! \param refChanLabel is the corresponding channel number (i.e. 1
- //! if refChanFreq is the lowest-frequency channel, and all
- //! other channels are harmonics of refChanFreq, or 2 if
- //! refChanFreq tracks the second harmonic, etc.).
- //! \throw InvalidArgument if refChanLabel is not positive.
- static
- void channelize( PartialList & partials,
- const Envelope & refChanFreq, int refChanLabel );
-
-
-
-// -- DEPRECATED members --
-
- //! DEPRECATED
- //!
- //! Set the stretching factor used to account for (consistently)
- //! detuned harmonics, as in a piano tone, from a pair of
- //! mode (harmonic) frequencies and numbers.
- //!
- //! The stretching factor is a small positive number for
- //! heavy vibrating strings (as in pianos) for which the
- //! mass of the string significantly affects the frequency
- //! of the vibrating modes. See Martin Keane, "Understanding
- //! the complex nature of the piano tone", 2004, for a discussion
- //! and the source of the mode frequency stretching algorithms
- //! implemented here.
- //!
- //! The stretching factor is computed using computeStretchFactor,
- //! but only a valid stretch factor will ever be assigned. If an
- //! invalid (negative) stretching factor is computed for the
- //! specified frequencies and mode numbers, the stretch factor
- //! will be set to zero.
- //!
- //! \param fm is the frequency of the Mth stretched harmonic
- //! \param m is the harmonic number of the harmonic whose frequnecy is fm
- //! \param fn is the frequency of the Nth stretched harmonic
- //! \param n is the harmonic number of the harmonic whose frequnecy is fn
- void setStretchFactor( double fm, int m, double fn, int n );
-
-
- //! DEPRECATED
- //!
- //! Static member that constructs an instance and applies
- //! it to a sequence of Partials.
- //! Construct a Channelizer using the specified Envelope
- //! and reference label, and use it to channelize a
- //! sequence of Partials.
- //!
- //! \param begin is the beginning of a sequence of Partials to
- //! channelize.
- //! \param end is the end of a sequence of Partials to
- //! channelize.
- //! \param refChanFreq is an Envelope representing the center frequency
- //! of a channel.
- //! \param refChanLabel is the corresponding channel number (i.e. 1
- //! if refChanFreq is the lowest-frequency channel, and all
- //! other channels are harmonics of refChanFreq, or 2 if
- //! refChanFreq tracks the second harmonic, etc.).
- //! \throw InvalidArgument if refChanLabel is not positive.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
- //! must be PartialList::iterators, otherwise they can be any type
- //! of iterators over a sequence of Partials.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Iter >
- static
- void channelize( Iter begin, Iter end,
- const Envelope & refChanFreq, int refChanLabel );
-#else
- static inline
- void channelize( PartialList::iterator begin, PartialList::iterator end,
- const Envelope & refChanFreq, int refChanLabel );
-#endif
-
-
- //! DEPRECATED
- //!
- //! Static member to compute the stretch factor for a sound having
- //! (consistently) detuned harmonics, like piano tones. Legacy version
- //! that assumes the first argument corresponds to the first partial.
- //!
- //! \param f1 is the frequency of the lowest numbered (1) partial.
- //! \param fn is the frequency of the Nth stretched harmonic
- //! \param n is the harmonic number of the harmonic whose frequnecy is fn
- //! \returns the stretching factor, usually a very small positive
- //! floating point number, or 0 for pefectly tuned harmonics
- //! (that is, for harmonic frequencies fn = n*f1).
- static double computeStretchFactor( double f1, double fn, double n );
-
-}; // end of class Channelizer
-
-// ---------------------------------------------------------------------------
-// channelize (sequence of Partials)
-// ---------------------------------------------------------------------------
-//! Assign each Partial in the specified half-open (STL-style) range
-//! the label corresponding to the frequency channel containing the
-//! greatest portion of its (the Partial's) energy.
-//!
-//! \param begin is the beginning of the range of Partials to channelize
-//! \param end is (one-past) the end of the range of Partials o channelize
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
-//! must be PartialList::iterators, otherwise they can be any type
-//! of iterators over a sequence of Partials.
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template
-void Channelizer::channelize( Iter begin, Iter end ) const
-#else
-inline
-void Channelizer::channelize( PartialList::iterator begin, PartialList::iterator end ) const
-#endif
-{
- while ( begin != end )
- {
- channelize( *begin++ );
- }
-}
-
-// ---------------------------------------------------------------------------
-// channelize (static)
-// ---------------------------------------------------------------------------
-//! DEPRECATED
-//!
-//! Static member that constructs an instance and applies
-//! it to a sequence of Partials.
-//! Construct a Channelizer using the specified Envelope
-//! and reference label, and use it to channelize a
-//! sequence of Partials.
-//!
-//! \param begin is the beginning of a sequence of Partials to
-//! channelize.
-//! \param end is the end of a sequence of Partials to
-//! channelize.
-//! \param refChanFreq is an Envelope representing the center frequency
-//! of a channel.
-//! \param refChanLabel is the corresponding channel number (i.e. 1
-//! if refChanFreq is the lowest-frequency channel, and all
-//! other channels are harmonics of refChanFreq, or 2 if
-//! refChanFreq tracks the second harmonic, etc.).
-//! \throw InvalidArgument if refChanLabel is not positive.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
-//! must be PartialList::iterators, otherwise they can be any type
-//! of iterators over a sequence of Partials.
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Iter >
-void Channelizer::channelize( Iter begin, Iter end,
- const Envelope & refChanFreq, int refChanLabel )
-#else
-inline
-void Channelizer::channelize( PartialList::iterator begin, PartialList::iterator end,
- const Envelope & refChanFreq, int refChanLabel )
-#endif
-{
- Channelizer instance( refChanFreq, refChanLabel );
- while ( begin != end )
- {
- instance.channelize( *begin++ );
- }
-}
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_CHANNELIZER_H */
diff --git a/loris_library/Source/include/loris/Collator.h b/loris_library/Source/include/loris/Collator.h
deleted file mode 100644
index e1d441c..0000000
--- a/loris_library/Source/include/loris/Collator.h
+++ /dev/null
@@ -1,366 +0,0 @@
-#ifndef INCLUDE_COLLATOR_H
-#define INCLUDE_COLLATOR_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Collator.h
- *
- * Definition of class Collator.
- *
- * Kelly Fitz, 29 April 2005
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "Distiller.h" // for default fade time and silent time
-#include "Partial.h"
-#include "PartialList.h"
-#include "PartialUtils.h"
-
-#include
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class Collator
-//
-//! Class Collator represents an algorithm for reducing a collection
-//! of Partials into the smallest collection of "equivalent" Partials
-//! by joining non-overlapping Partials end to end.
-//!
-//! Partials that are not labeled, that is, Partials having label 0,
-//! are "collated " into groups of non-overlapping (in time)
-//! Partials, and fused into a single Partial per group.
-//! "Collating" is a bit like "distilling" but non-overlapping
-//! Partials are grouped without regard to frequency proximity. This
-//! algorithm produces the smallest-possible number of collated Partials.
-//! Thanks to Ulrike Axen for providing this optimal algorithm.
-//!
-//! Collating modifies the Partial container (a PartialList). Only
-//! unlabeled (labeled 0) Partials are affected by the collating
-//! operation. Collated Partials are moved to the end of the
-//! collection of Partials.
-//
-class Collator
-{
-// -- instance variables --
-
- double _fadeTime, _gapTime;
-
-// -- public interface --
-public:
-
-// -- global defaults and constants --
-
- enum
- {
-
- //! Default time in milliseconds over which Partials joined by
- //! distillation fade to and from zero amplitude. Divide by
- //! 1000 to use as a member function parameter. This parameter
- //! should be the same in Distiller, Sieve, and Collator.
- DefaultFadeTimeMs = Distiller::DefaultFadeTimeMs,
-
- //! Default minimum duration in milliseconds of the silent
- //! (zero-amplitude) gap between two Partials joined by
- //! distillation. Divide by 1000 to use as a member function
- //! parameter. This parameter should be the same in Distiller,
- //! Sieve, and Collator.
- DefaultSilentTimeMs = Distiller::DefaultSilentTimeMs
- };
-
-// -- construction --
-
- //! Construct a new Collator using the specified fade and gap times
- //! between Partials. When two Partials are joined, the collated Partial
- //! fades out at the end of the earlier Partial and back in again
- //! at the onset of the later one. The fade time is the time over
- //! which these fades occur. By default, use a 5 ms fade time.
- //! The gap time is the additional time over which a Partial faded
- //! out must remain at zero amplitude before it can fade back in.
- //! By default, use a gap time of one millisecond, to
- //! prevent a pair of arbitrarily close null Breakpoints being
- //! inserted. (Defaults are copied from the Distiller.)
- //!
- //! \param partialFadeTime is the time (in seconds) over
- //! which Partials joined by distillation fade to
- //! and from zero amplitude. Default is 0.005 (one
- //! millisecond).
- //! \param partialSilentTime is the minimum duration (in seconds)
- //! of the silent (zero-amplitude) gap between two
- //! Partials joined by distillation. (Default is
- //! 0.001 (one millisecond).
- explicit
- Collator( double partialFadeTime = Collator::DefaultFadeTimeMs/1000.0,
- double partialSilentTime = Collator::DefaultSilentTimeMs/1000.0 );
-
- // Use compiler-generated copy, assign, and destroy.
-
-// -- collating --
-
- //! Collate unlabeled (zero-labeled) Partials into the smallest-possible
- //! number of Partials that does not combine any overlapping Partials.
- //! Collated Partials assigned labels higher than any label in the original
- //! list, and appear at the end of the sequence, after all previously-labeled
- //! Partials.
- //!
- //!
- //! Return an iterator refering to the position of the first collated Partial,
- //! or the end of the collated collection if there are no collated Partials.
- //! Since collating is in-place, the Partials collection may be smaller
- //! (fewer Partials) after collating, and any iterators on the collection
- //! may be invalidated.
- //!
- //! \param partials is the collection of Partials to collate in-place
- //! \return the position of the end of the range of labeled Partials,
- //! which is either the end of the collection, or the position
- //! of the first collated Partial, composed of unlabeled Partials
- //! in the original collection.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
- //! must be a PartialList, otherwise it can be any container type
- //! storing Partials that supports at least bidirectional iterators.
- //!
- //! \sa Collator::collate( Container & partials )
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Container >
- typename Container::iterator collate( Container & partials );
-#else
- inline
- PartialList::iterator collate( PartialList & partials );
-#endif
-
- //! Function call operator: same as collate( PartialList & partials ).
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Container >
- typename Container::iterator operator() ( Container & partials );
-#else
- PartialList::iterator operator() ( PartialList & partials );
-#endif
-
- //! Static member that constructs an instance and applies
- //! it to a sequence of Partials. Collated Partials are
- //! labeled beginning with the label one more than the
- //! largest label in the orignal Partials.
- //!
- //! \param partials is the collection of Partials to collate in-place
- //! \param partialFadeTime is the time (in seconds) over
- //! which Partials joined by collating fade to
- //! and from zero amplitude.
- //! \param partialSilentTime is the minimum duration (in seconds)
- //! of the silent (zero-amplitude) gap between two
- //! Partials joined by collating.
- //! \return the position of the first collated Partial
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
- //! must be a PartialList, otherwise it can be any container type
- //! storing Partials that supports at least bidirectional iterators.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Container >
- static typename Container::iterator
- collate( Container & partials, double partialFadeTime,
- double partialSilentTime );
-#else
- static inline PartialList::iterator
- collate( PartialList & partials, double partialFadeTime,
- double partialSilentTime );
-#endif
-
-
-private:
-
-// -- helpers --
-
- //! Collate unlabeled (zero labeled) Partials into the smallest
- //! possible number of Partials that does not combine any temporally
- //! overlapping Partials. Give each collated Partial a label, starting
- //! with startlabel, and incrementing. If startLabel is zero, then
- //! give each collated Partial the label zero. The unlabeled Partials are
- //! collated in-place.
- void collateAux( PartialList & unlabled );
-
-}; // end of class Collator
-
-// ---------------------------------------------------------------------------
-// collate
-// ---------------------------------------------------------------------------
-//! Collate unlabeled (zero-labeled) Partials into the smallest-possible
-//! number of Partials that does not combine any overlapping Partials.
-//! Collated Partials assigned labels higher than any label in the original
-//! list, and appear at the end of the sequence, after all previously-labeled
-//! Partials.
-//!
-//! Return an iterator refering to the position of the first collated Partial,
-//! or the end of the collated collection if there are no collated Partials.
-//! Since collating is in-place, the Partials collection may be smaller
-//! (fewer Partials) after collating, and any iterators on the collection
-//! may be invalidated.
-//!
-//! \param partials is the collection of Partials to collate in-place
-//! \return the position of the end of the range of labeled Partials,
-//! which is either the end of the collection, or the position
-//! of the first collated Partial, composed of unlabeled Partials
-//! in the original collection.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
-//! must be a PartialList, otherwise it can be any container type
-//! storing Partials that supports at least bidirectional iterators.
-//!
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Container >
-typename Container::iterator
-Collator::collate( Container & partials )
-#else
-inline
-PartialList::iterator
-Collator::collate( PartialList & partials )
-#endif
-{
-#if ! defined(NO_TEMPLATE_MEMBERS)
- typedef typename Container::iterator Iterator;
-#else
- typedef PartialList::iterator Iterator;
-#endif
-
- // Partition the Partials into labeled and unlabeled,
- // and collate the unlabeled ones and replace the
- // unlabeled range.
- // (This requires bidirectional iterator support.)
- Iterator beginUnlabeled =
- std::partition( partials.begin(), partials.end(),
- std::not1( PartialUtils::isLabelEqual(0) ) );
- // this used to be a stable partition, which
- // is very much slower and seems unnecessary
-
- // cannot splice if this operation is to be generic
- // with respect to container, have to copy:
- PartialList collated( beginUnlabeled, partials.end() );
- // collated.splice( collated.end(), beginUnlabeled, partials.end() );
-
- // determine the label for the first collated Partial:
- Partial::label_type labelCollated = 1;
- if ( partials.begin() != beginUnlabeled )
- {
- labelCollated =
- 1 + std::max_element( partials.begin(), beginUnlabeled,
- PartialUtils::compareLabelLess() )->label();
- }
- if ( labelCollated < 1 )
- {
- labelCollated = 1;
- }
-
- // collate unlabeled (zero-labeled) Partials:
- collateAux( collated );
-
- // label the collated Partials:
- for ( Iterator it = collated.begin(); it != collated.end(); ++it )
- {
- it->setLabel( labelCollated++ );
- }
-
- // copy the collated Partials back into the source container
- // after the range of labeled Partials
- Iterator endCollated =
- std::copy( collated.begin(), collated.end(), beginUnlabeled );
-
- // remove extra Partials from the end of the source container
- if ( endCollated != partials.end() )
- {
- typename Iterator::difference_type numLabeled =
- std::distance( partials.begin(), beginUnlabeled );
-
- partials.erase( endCollated, partials.end() );
-
- // restore beginUnlabeled:
- beginUnlabeled = partials.begin();
- std::advance( beginUnlabeled, numLabeled );
- }
- return beginUnlabeled;
-}
-
-// ---------------------------------------------------------------------------
-// Function call operator
-// ---------------------------------------------------------------------------
-//! Function call operator: same as collate( PartialList & partials ).
-//!
-//! \sa Collator::collate( Container & partials )
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Container >
-typename Container::iterator Collator::operator()( Container & partials )
-#else
-inline
-PartialList::iterator Collator::operator()( PartialList & partials )
-#endif
-{
- return collate( partials );
-}
-
-// ---------------------------------------------------------------------------
-// collate
-// ---------------------------------------------------------------------------
-//! Static member that constructs an instance and applies
-//! it to a sequence of Partials. Collated Partials are
-//! labeled beginning with the label one more than the
-//! largest label in the orignal Partials.
-//!
-//! \post All Partials in the collection are uniquely-labeled,
-//! collated Partials are all at the end of the collection
-//! (after all labeled Partials).
-//! \param partials is the collection of Partials to collate in-place
-//! \param partialFadeTime is the time (in seconds) over
-//! which Partials joined by collating fade to
-//! and from zero amplitude.
-//! \param partialSilentTime is the minimum duration (in seconds)
-//! of the silent (zero-amplitude) gap between two
-//! Partials joined by collateation. (Default is
-//! 0.0001 (one tenth of a millisecond).
-//! \return the position of the first collated Partial
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
-//! must be a PartialList, otherwise it can be any container type
-//! storing Partials that supports at least bidirectional iterators.
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Container >
-typename Container::iterator
-Collator::collate( Container & partials, double partialFadeTime,
- double partialSilentTime )
-#else
-inline
-PartialList::iterator
-Collator::collate( PartialList & partials, double partialFadeTime,
- double partialSilentTime )
-#endif
-{
- Collator instance( partialFadeTime, partialSilentTime );
- return instance.collate( partials );
-}
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_COLLATOR_H */
diff --git a/loris_library/Source/include/loris/Dilator.h b/loris_library/Source/include/loris/Dilator.h
deleted file mode 100644
index 3370788..0000000
--- a/loris_library/Source/include/loris/Dilator.h
+++ /dev/null
@@ -1,410 +0,0 @@
-#ifndef INCLUDE_DILATOR_H
-#define INCLUDE_DILATOR_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Dilator.h
- *
- * Definition of class Dilator.
- *
- * Kelly Fitz, 26 Oct 1999
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#if defined(NO_TEMPLATE_MEMBERS)
-#include "PartialList.h"
-#endif
-
-#include
-
-// begin namespace
-namespace Loris {
-
-class Marker;
-class Partial;
-
-// ---------------------------------------------------------------------------
-// class Dilator
-//
-//! Class Dilator represents an algorithm for non-uniformly expanding
-//! and contracting the Partial parameter envelopes according to the initial
-//! and target (desired) times of temporal features.
-//!
-//! It is frequently necessary to redistribute temporal events in this way
-//! in preparation for a sound morph. For example, when morphing instrument
-//! tones, it is common to align the attack, sustain, and release portions
-//! of the source sounds by dilating or contracting those temporal regions.
-//!
-//! This same procedure can be applied to the Markers stored in AiffFile,
-//! SdifFile, and SpcFile (see Marker.h).
-//
-class Dilator
-{
-// -- instance variables --
-
- std::vector< double > _initial, _target; // time points
-
-// -- public interface --
-public:
-// -- construction --
-
- //! Construct a new Dilator with no time points.
- Dilator( void );
-
- //! Construct a new Dilator using a range of initial time points
- //! and a range of target (desired) time points. The client must
- //! ensure that the target range has at least as many elements as
- //! the initial range.
- //!
- //! \param ibegin is the beginning of a sequence of initial, or source,
- //! time points.
- //! \param iend is (one-past) the end of a sequence of initial, or
- //! source, time points.
- //! \param tbegin is the beginning of a sequence of target time points;
- //! this sequence must be as long as the sequence of initial time
- //! point described by ibegin and iend.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
- //! only const double * arguments.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- Dilator( Iter1 ibegin, Iter1 iend, Iter2 tbegin );
-#else
- inline
- Dilator( const double * ibegin, const double * iend, const double * tbegin );
-#endif
-
- // Use compiler-generated copy, assign, and destroy.
-
-// -- mutation --
-
- //! Insert a pair of initial and target time points.
- //!
- //! Specify a pair of initial and target time points to be used
- //! by this Dilator, corresponding, for example, to the initial
- //! and desired time of a particular temporal feature in an
- //! analyzed sound.
- //!
- //! \param i is an initial, or source, time point
- //! \param t is a target time point
- //!
- //! The time points will be sorted before they are used.
- //! If, in the sequences of initial and target time points, there are
- //! exactly the same number of initial time points preceding i as
- //! target time points preceding t, then time i will be warped to
- //! time t in the dilation process.
- void insert( double i, double t );
-
-// -- dilation --
-
- //! Replace the Partial envelope with a new envelope having the
- //! same Breakpoints at times computed to align temporal features
- //! in the sorted sequence of initial time points with their
- //! counterparts the sorted sequence of target time points.
- //!
- //! Depending on the specification of initial and target time
- //! points, the dilated Partial may have Breakpoints at times
- //! less than 0, even if the original Partial did not.
- //!
- //! It is possible to have duplicate time points in either sequence.
- //! Duplicate initial time points result in very localized stretching.
- //! Duplicate target time points result in very localized compression.
- //!
- //! If all initial time points are greater than 0, then an implicit
- //! time point at 0 is assumed in both initial and target sequences,
- //! so the onset of a sound can be stretched without explcitly specifying a
- //! zero point in each vector. (This seems most intuitive, and only looks
- //! like an inconsistency if clients are using negative time points in
- //! their Dilator, or Partials having Breakpoints before time 0, both
- //! of which are probably unusual circumstances.)
- //!
- //! \param p is the Partial to dilate.
- void dilate( Partial & p ) const;
-
- //! Function call operator: same as dilate( Partial & p ).
- void operator() ( Partial & p ) const;
-
- //! Compute a new time for the specified Marker using
- //! warpTime(), exactly as Partial Breakpoint times are
- //! recomputed. This can be used to dilate the Markers
- //! corresponding to a collection of Partials.
- //!
- //! \param m is the Marker whose time should be recomputed.
- void dilate( Marker & m ) const;
-
- //! Function call operator: same as dilate( Marker & p ).
- void operator() ( Marker & m ) const;
-
- //! Non-uniformly expand and contract the parameter envelopes of the each
- //! Partial in the specified half-open range according to this Dilator's
- //! stored initial and target (desired) times.
- //!
- //! \param dilate_begin is the beginning of a sequence of Partials to dilate.
- //! \param dilate_end is (one-past) the end of a sequence of Partials to dilate.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
- //! only PartialList::const_iterator arguments. Otherwise, this member
- //! also works for sequences of Markers.
- //!
- //! \sa Dilator::dilate( Partial & p ) const
- //! \sa Dilator::dilate( Marker & m ) const
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- void dilate( Iter dilate_begin, Iter dilate_end ) const;
-#else
- inline
- void dilate( PartialList::iterator dilate_begin,
- PartialList::iterator dilate_end ) const;
-#endif
-
- //! Function call operator: same as
- //! dilate( Iter dilate_begin, Iter dilate_end )
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
- //! only PartialList::const_iterator arguments. Otherwise, this member
- //! also works for sequences of Markers.
- //!
- //! \sa Dilator::dilate( Partial & p ) const
- //! \sa Dilator::dilate( Marker & m ) const
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- void operator() ( Iter dilate_begin, Iter dilate_end ) const;
-#else
- inline
- void operator() ( PartialList::iterator dilate_begin,
- PartialList::iterator dilate_end ) const;
-#endif
-
- //! Return the dilated time value corresponding to the specified initial time.
- //!
- //! \param currentTime is a pre-dilated time.
- //! \return the dilated time corresponding to the initial time currentTime
- double warpTime( double currentTime ) const;
-
-// -- static members --
-
- //! Static member that constructs an instance and applies
- //! it to a sequence of Partials.
- //! Construct a Dilator using the specified initial and
- //! target times, and apply it to a sequence of Partials.
- //!
- //! \param dilate_begin is the beginning of a sequence of Partials to dilate.
- //! \param dilate_end is (one-past) the end of a sequence of Partials to dilate.
- //! \param ibegin is the beginning of a sequence of initial, or source,
- //! time points.
- //! \param iend is (one-past) the end of a sequence of initial, or
- //! source, time points.
- //! \param tbegin is the beginning of a sequence of target time points;
- //! this sequence must be as long as the sequence of initial time
- //! point described by ibegin and iend.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
- //! only PartialList::const_iterator arguments. Otherwise, this member
- //! also works for sequences of Markers.
- //! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
- //! only const double * arguments for the times, otherwise, any iterator
- //! will do..
- //!
- //! \sa Dilator::dilate( Partial & p ) const
- //! \sa Dilator::dilate( Marker & m ) const
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename PartialsIter, typename TimeIter1, typename TimeIter2 >
- static
- void dilate( PartialsIter dilate_begin, PartialsIter dilate_end,
- TimeIter1 ibegin, TimeIter1 iend, TimeIter2 tbegin );
-#else
- static inline
- void dilate( PartialList::iterator dilate_begin,
- PartialList::iterator dilate_end,
- const double * ibegin, const double * iend,
- const double * tbegin );
-#endif
-
-}; // end of class Dilator
-
-
-// ---------------------------------------------------------------------------
-// constructor (sequences of time points)
-// ---------------------------------------------------------------------------
-//! Construct a new Dilator using a range of initial time points
-//! and a range of target (desired) time points. The client must
-//! ensure that the target range has at least as many elements as
-//! the initial range.
-//!
-//! \param ibegin is the beginning of a sequence of initial, or source,
-//! time points.
-//! \param iend is (one-past) the end of a sequence of initial, or
-//! source, time points.
-//! \param tbegin is the beginning of a sequence of target time points;
-//! this sequence must be as long as the sequence of initial time
-//! point described by ibegin and iend.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
-//! only const double * arguments.
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template
-Dilator::Dilator( Iter1 ibegin, Iter1 iend, Iter2 tbegin )
-#else
-inline
-Dilator::Dilator( const double * ibegin, const double * iend, const double * tbegin )
-#endif
-{
- while ( ibegin != iend )
- {
- insert( *ibegin++, *tbegin++ );
- }
-}
-
-// ---------------------------------------------------------------------------
-// dilate (sequence of Partials or Markers)
-// ---------------------------------------------------------------------------
-//! Non-uniformly expand and contract the parameter envelopes of the each
-//! Partial in the specified half-open range according to this Dilator's
-//! stored initial and target (desired) times.
-//!
-//! \param dilate_begin is the beginning of a sequence of Partials to dilate.
-//! \param dilate_end is (one-past) the end of a sequence of Partials to dilate.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
-//! only PartialList::const_iterator arguments. Otherwise, this member
-//! also works for sequences of Markers.
-//!
-//! \sa Dilator::dilate( Partial & p ) const
-//! \sa Dilator::dilate( Marker & m ) const
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template
-void Dilator::dilate( Iter dilate_begin, Iter dilate_end ) const
-#else
-inline
-void Dilator::dilate( PartialList::iterator dilate_begin,
- PartialList::iterator dilate_end ) const
-#endif
-{
- while ( dilate_begin != dilate_end )
- {
- dilate( *(dilate_begin++) );
- }
-}
-
-// ---------------------------------------------------------------------------
-// Function call operator (sequence of Partials or Markers)
-// ---------------------------------------------------------------------------
-//! Function call operator: same as
-//! dilate( Iter dilate_begin, Iter dilate_end )
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
-//! only PartialList::const_iterator arguments. Otherwise, this member
-//! also works for sequences of Markers.
-//!
-//! \sa Dilator::dilate( Partial & p ) const
-//! \sa Dilator::dilate( Marker & m ) const
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template
-void Dilator::operator() ( Iter dilate_begin, Iter dilate_end ) const
-#else
-inline
-void Dilator::operator() ( PartialList::iterator dilate_begin,
- PartialList::iterator dilate_end ) const
-#endif
-{
- dilate( dilate_begin, dilate_end );
-}
-
-// ---------------------------------------------------------------------------
-// Function call operator (single Partial)
-// ---------------------------------------------------------------------------
-//! Function call operator: same as dilate( Partial & p ).
-//!
-//! \sa Dilator::dilate( Partial & p ) const
-//
-inline
-void Dilator::operator() ( Partial & p ) const
-{
- dilate( p );
-}
-
-// ---------------------------------------------------------------------------
-// Function call operator (single Marker)
-// ---------------------------------------------------------------------------
-//! Function call operator: same as dilate( Marker & m ).
-//!
-//! \sa Dilator::dilate( Marker & m ) const
-//
-inline
-void Dilator::operator() ( Marker & m ) const
-{
- dilate( m );
-}
-
-// ---------------------------------------------------------------------------
-// dilate (static)
-// ---------------------------------------------------------------------------
-//! Static member that constructs an instance and applies
-//! it to a sequence of Partials.
-//! Construct a Dilator using the specified initial and
-//! target times, and apply it to a sequence of Partials.
-//!
-//! \param dilate_begin is the beginning of a sequence of Partials to dilate.
-//! \param dilate_end is (one-past) the end of a sequence of Partials to dilate.
-//! \param ibegin is the beginning of a sequence of initial, or source,
-//! time points.
-//! \param iend is (one-past) the end of a sequence of initial, or
-//! source, time points.
-//! \param tbegin is the beginning of a sequence of target time points;
-//! this sequence must be as long as the sequence of initial time
-//! point described by ibegin and iend.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
-//! only PartialList::const_iterator arguments. Otherwise, this member
-//! also works for sequences of Markers.
-//! If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts
-//! only const double * arguments for the times, otherwise, any iterator
-//! will do..
-//!
-//! \sa Dilator::dilate( Partial & p ) const
-//! \sa Dilator::dilate( Marker & m ) const
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename PartialsIter, typename TimeIter1, typename TimeIter2 >
-void Dilator::dilate( PartialsIter dilate_begin, PartialsIter dilate_end,
- TimeIter1 ibegin, TimeIter1 iend, TimeIter2 tbegin )
-#else
-inline
-void Dilator::dilate( PartialList::iterator dilate_begin,
- PartialList::iterator dilate_end,
- const double * ibegin, const double * iend,
- const double * tbegin )
-#endif
-{
- Dilator instance( ibegin, iend, tbegin );
- instance.dilate( dilate_begin, dilate_end );
-}
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_DILATOR_H */
diff --git a/loris_library/Source/include/loris/Distiller.h b/loris_library/Source/include/loris/Distiller.h
deleted file mode 100644
index f1672ce..0000000
--- a/loris_library/Source/include/loris/Distiller.h
+++ /dev/null
@@ -1,370 +0,0 @@
-#ifndef INCLUDE_DISTILLER_H
-#define INCLUDE_DISTILLER_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Distiller.h
- *
- * Definition of class Distiller.
- *
- * Kelly Fitz, 20 Oct 1999
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "Partial.h"
-#include "PartialList.h"
-#include "PartialUtils.h"
-
-#include "Notifier.h" // for debugging only
-
-#include
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class Distiller
-//
-//! Class Distiller represents an algorithm for "distilling" a group of
-//! Partials that logically represent a single component into a single
-//! Partial.
-//!
-//! The sound morphing algorithm in Loris requires that Partials in a
-//! given source be labeled uniquely, that is, no two Partials can have
-//! the same label. The Distiller enforces this condition. All Partials
-//! identified with a particular frequency channel (see Channelizer), and,
-//! therefore, having a common label, are distilled into a single Partial,
-//! leaving at most a single Partial per frequency channel and label.
-//! Channels that contain no Partials are not represented in the distilled
-//! data. Partials that are not labeled, that is, Partials having label 0,
-//! are are left unmodified at the end of the Partial sequence.
-//!
-//! Distillation modifies the Partial container (a PartialList). All
-//! Partials in the distilled range having a common label are replaced by
-//! a single Partial in the distillation process. Only labeled
-//! Partials are affected by distillation.
-//
-class Distiller
-{
-// -- instance variables --
-
- double _fadeTime, _gapTime; // distillation parameters
-
-// -- public interface --
-public:
-
-// -- global defaults and constants --
-
- enum
- {
-
- //! Default time in milliseconds over which Partials joined by
- //! distillation fade to and from zero amplitude. Divide by
- //! 1000 to use as a member function parameter. This parameter
- //! should be the same in Distiller, Sieve, and Collator.
- DefaultFadeTimeMs = 5,
-
- //! Default minimum duration in milliseconds of the silent
- //! (zero-amplitude) gap between two Partials joined by
- //! distillation. Divide by 1000 to use as a member function
- //! parameter. This parameter should be the same in Distiller,
- //! Sieve, and Collator.
- DefaultSilentTimeMs = 1
- };
-
-// -- construction --
-
- //! Construct a new Distiller using the specified fade time
- //! for gaps between Partials. When two non-overlapping Partials
- //! are distilled into a single Partial, the distilled Partial
- //! fades out at the end of the earlier Partial and back in again
- //! at the onset of the later one. The fade time is the time over
- //! which these fades occur. By default, use a 1 ms fade time.
- //! The gap time is the additional time over which a Partial faded
- //! out must remain at zero amplitude before it can fade back in.
- //! By default, use a gap time of one tenth of a millisecond, to
- //! prevent a pair of arbitrarily close null Breakpoints being
- //! inserted.
- //!
- //! \param partialFadeTime is the time (in seconds) over
- //! which Partials joined by distillation fade to
- //! and from zero amplitude. (Default is
- //! Distiller::DefaultFadeTime).
- //! \param partialSilentTime is the minimum duration (in seconds)
- //! of the silent (zero-amplitude) gap between two
- //! Partials joined by distillation. (Default is
- //! Distiller::DefaultSilentTime).
- explicit
- Distiller( double partialFadeTime = Distiller::DefaultFadeTimeMs/1000.0,
- double partialSilentTime = Distiller::DefaultSilentTimeMs/1000.0 );
-
- // Use compiler-generated copy, assign, and destroy.
-
-// -- distillation --
-
- //! Distill labeled Partials in a collection leaving only a single
- //! Partial per non-zero label.
- //!
- //! Unlabeled (zero-labeled) Partials are left unmodified at
- //! the end of the distilled Partials.
- //!
- //! Return an iterator refering to the position of the first unlabeled Partial,
- //! or the end of the distilled collection if there are no unlabeled Partials.
- //! Since distillation is in-place, the Partials collection may be smaller
- //! (fewer Partials) after distillation, and any iterators on the collection
- //! may be invalidated.
- //!
- //! \post All labeled Partials in the collection are uniquely-labeled,
- //! and all unlabeled Partials have been moved to the end of the
- //! sequence.
- //! \param partials is the collection of Partials to distill in-place
- //! \return the position of the end of the range of distilled Partials,
- //! which is either the end of the collection, or the position
- //! or the first unlabeled Partial.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
- //! must be a PartialList, otherwise it can be any container type
- //! storing Partials that supports at least bidirectional iterators.
- //!
- //! \sa Distiller::distill( Container & partials )
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Container >
- typename Container::iterator distill( Container & partials );
-#else
- inline
- PartialList::iterator distill( PartialList & partials );
-#endif
-
- //! Function call operator: same as distill( PartialList & partials ).
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Container >
- typename Container::iterator operator() ( Container & partials );
-#else
- PartialList::iterator operator() ( PartialList & partials );
-#endif
-
- //! Static member that constructs an instance and applies
- //! it to a sequence of Partials.
- //!
- //! \post All labeled Partials in the collection are uniquely-labeled,
- //! and all unlabeled Partials have been moved to the end of the
- //! sequence.
- //! \param partials is the collection of Partials to distill in-place
- //! \param partialFadeTime is the time (in seconds) over
- //! which Partials joined by distillation fade to
- //! and from zero amplitude.
- //! \param partialSilentTime is the minimum duration (in seconds)
- //! of the silent (zero-amplitude) gap between two
- //! Partials joined by distillation. (Default is
- //! Distiller::DefaultSilentTime).
- //! \return the position of the end of the range of distilled Partials,
- //! which is either the end of the collection, or the position
- //! or the first unlabeled Partial.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
- //! must be a PartialList, otherwise it can be any container type
- //! storing Partials that supports at least bidirectional iterators.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Container >
- static typename Container::iterator
- distill( Container & partials, double partialFadeTime,
- double partialSilentTime = DefaultSilentTimeMs/1000.0 );
-#else
- static inline PartialList::iterator
- distill( PartialList & partials, double partialFadeTime,
- double partialSilentTime = DefaultSilentTimeMs/1000.0 );
-#endif
-
-private:
-
-// -- helpers --
-
- //! Distill labeled Partials in a PartialList leaving only a single
- //! Partial per non-zero label.
- //!
- //! Unlabeled (zero-labeled) Partials are left unmodified at
- //! the end of the distilled Partials.
- //!
- //! Return an iterator refering to the position of the first unlabeled Partial,
- //! or the end of the distilled collection if there are no unlabeled Partials.
- //! Since distillation is in-place, the Partials collection may be smaller
- //! (fewer Partials) after distillation, and any iterators on the collection
- //! may be invalidated.
- //!
- //! \post All labeled Partials in the collection are uniquely-labeled,
- //! and all unlabeled Partials have been moved to the end of the
- //! sequence.
- //! \param partials is the collection of Partials to distill in-place
- //! \return the position of the end of the range of distilled Partials,
- //! which is either the end of the collection, or the position
- //! or the first unlabeled Partial.
- PartialList::iterator distill_list( PartialList & partials );
-
- //! Distill a list of Partials having a common label
- //! into a single Partial with that label, and append it
- //! to the distilled collection. If an empty list of Partials
- //! is passed, then an empty Partial having the specified
- //! label is appended.
- void distillOne( PartialList & partials, Partial::label_type label,
- PartialList & distilled );
-
-}; // end of class Distiller
-
-// ---------------------------------------------------------------------------
-// distill
-// ---------------------------------------------------------------------------
-//! Distill labeled Partials in a collection leaving only a single
-//! Partial per non-zero label.
-//!
-//! Unlabeled (zero-labeled) Partials are left unmodified at
-//! the end of the distilled Partials.
-//!
-//! Return an iterator refering to the position of the first unlabeled Partial,
-//! or the end of the distilled collection if there are no unlabeled Partials.
-//! Since distillation is in-place, the Partials collection may be smaller
-//! (fewer Partials) after distillation, and any iterators on the collection
-//! may be invalidated.
-//!
-//! \post All labeled Partials in the collection are uniquely-labeled,
-//! and all unlabeled Partials have been moved to the end of the
-//! sequence.
-//! \param partials is the collection of Partials to distill in-place
-//! \return the position of the end of the range of distilled Partials,
-//! which is either the end of the collection, or the position
-//! or the first unlabeled Partial.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
-//! must be a PartialList, otherwise it can be any container type
-//! storing Partials that supports at least bidirectional iterators.
-//!
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Container >
-typename Container::iterator Distiller::distill( Container & partials )
-{
- // This can be done so much more easily and
- // efficiently on a list than on other containers
- // that it is worth copying the Partials to a
- // list for distillation, and then transfering
- // them back.
- //
- // See below for a specialization for the case
- // of the Container being a list, so no copy
- // is needed.
- PartialList pl( partials.begin(), partials.end() );
- PartialList::iterator it = distill_list( pl );
-
- // pl has distilled Partials at beginning, and
- // unlabeled Partials at end:
- typename Container::iterator beginUnlabeled =
- std::copy( pl.begin(), it, partials.begin() );
-
- typename Container::iterator endUnlabeled =
- std::copy( it, pl.end(), beginUnlabeled );
-
-
- partials.erase( endUnlabeled, partials.end() );
-
- return beginUnlabeled;
-}
-
-// specialization for PartialList container
-template< >
-inline
-PartialList::iterator Distiller::distill( PartialList & partials )
-{
- debugger << "using PartialList version of distill to avoid copying" << endl;
- return distill_list( partials );
-}
-#else
-inline
-PartialList::iterator Distiller::distill( PartialList & partials )
-{
- return distill_list( partials );
-}
-#endif
-
-// ---------------------------------------------------------------------------
-// Function call operator
-// ---------------------------------------------------------------------------
-//! Function call operator: same as distill( PartialList & partials ).
-//!
-//! \sa Distiller::distill( Container & partials )
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Container >
-typename Container::iterator Distiller::operator()( Container & partials )
-#else
-inline
-PartialList::iterator Distiller::operator()( PartialList & partials )
-#endif
-{
- return distill( partials );
-}
-
-// ---------------------------------------------------------------------------
-// distill
-// ---------------------------------------------------------------------------
-//! Static member that constructs an instance and applies
-//! it to a sequence of Partials.
-//!
-//! \post All labeled Partials in the collection are uniquely-labeled,
-//! and all unlabeled Partials have been moved to the end of the
-//! sequence.
-//! \param partials is the collection of Partials to distill in-place
-//! \param partialFadeTime is the time (in seconds) over
-//! which Partials joined by distillation fade to
-//! and from zero amplitude.
-//! \param partialSilentTime is the minimum duration (in seconds)
-//! of the silent (zero-amplitude) gap between two
-//! Partials joined by distillation. (Default is
-//! Distiller::DefaultSilentTime).
-//! \return the position of the end of the range of distilled Partials,
-//! which is either the end of the collection, or the position
-//! or the first unlabeled Partial.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then partials
-//! must be a PartialList, otherwise it can be any container type
-//! storing Partials that supports at least bidirectional iterators.
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Container >
-typename Container::iterator
-Distiller::distill( Container & partials, double partialFadeTime,
- double partialSilentTime )
-#else
-inline
-PartialList::iterator
-Distiller::distill( PartialList & partials, double partialFadeTime,
- double partialSilentTime )
-#endif
-{
- Distiller instance( partialFadeTime, partialSilentTime );
- return instance.distill( partials );
-}
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_DISTILLER_H */
diff --git a/loris_library/Source/include/loris/Envelope.h b/loris_library/Source/include/loris/Envelope.h
deleted file mode 100644
index 832619a..0000000
--- a/loris_library/Source/include/loris/Envelope.h
+++ /dev/null
@@ -1,170 +0,0 @@
-#ifndef INCLUDE_ENVELOPE_H
-#define INCLUDE_ENVELOPE_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Envelope.h
- *
- * Definition of abstract interface class Envelope.
- *
- * Kelly Fitz, 21 July 2000
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include // for autoptr
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class Envelope
-//
-//! Envelope is an base class for objects representing real functions
-//! of time.
-//!
-//! Class Envelope is an abstract base class, specifying interface for
-//! prototypable (clonable) objects representing generic, real-valued
-//! (double) functions of one real-valued (double) time argument. Derived
-//! classes (like BreakpointEnvelope) must implement valueAt() and
-//! clone(), the latter to support the Prototype pattern. Clients of
-//! Envelope, like Morpher and Distiller, can use prototype Envelopes to
-//! make their own private Envelopes.
-//!
-//! \sa Distiller, Envelope, Morpher
-//
-class Envelope
-{
-// -- public interface --
-public:
-// -- construction --
-
- // allow compiler to generate constructors
-
- //! Destroy this Envelope (virtual to allow subclassing).
- virtual ~Envelope( void );
-
-// -- Envelope interface --
-
- //! Return an exact copy of this Envelope (following the Prototype
- //! pattern).
- virtual Envelope * clone( void ) const = 0;
-
- //! Return the value of this Envelope at the specified time.
- virtual double valueAt( double x ) const = 0;
-
-}; // end of abstract class Envelope
-
-
-// ---------------------------------------------------------------------------
-// class ScaleAndOffsetEnvelope
-//
-//! ScaleAndOffsetEnvelope is an derived Envelope class for objects
-//! representing envelopes having a scale and offset applied (in that order).
-
-class ScaleAndOffsetEnvelope : public Envelope
-{
-// -- public interface --
-public:
-// -- construction --
-
- //! Construct a new envelope that is a scaled and offset
- //! version of another.
- ScaleAndOffsetEnvelope( const Envelope & e, double scale, double offset ) :
- m_env( e.clone() ),
- m_scale( scale ),
- m_offset( offset )
- {
- }
-
- //! Construct a copy of an envelope.
- ScaleAndOffsetEnvelope( const ScaleAndOffsetEnvelope & rhs ) :
- m_env( rhs.m_env->clone() ),
- m_scale( rhs.m_scale ),
- m_offset( rhs.m_offset )
- {
- }
-
- //! Assignment from another envelope.
- ScaleAndOffsetEnvelope &
- operator=( const ScaleAndOffsetEnvelope & rhs )
- {
- if ( &rhs != this )
- {
- m_env.reset( rhs.m_env->clone() );
- m_scale = rhs.m_scale;
- m_offset = rhs.m_offset;
- }
- return *this;
- }
-
-// -- Envelope interface --
-
- //! Return an exact copy of this Envelope (following the Prototype
- //! pattern).
- ScaleAndOffsetEnvelope * clone( void ) const
- {
- return new ScaleAndOffsetEnvelope( *this );
- }
-
- //! Return the value of this Envelope at the specified time.
- virtual double valueAt( double x ) const
- {
- return m_offset + ( m_scale * m_env->valueAt( x ) );
- }
-
-// -- private member variables --
-
-private:
-
- std::auto_ptr< Envelope > m_env;
- double m_scale, m_offset;
-
-}; // end of class ScaleAndOffsetEnvelope
-
-
-// ---------------------------------------------------------------------------
-// math operators
-// ---------------------------------------------------------------------------
-
-inline
-ScaleAndOffsetEnvelope
-operator*( const Envelope & e, double x )
-{
- return ScaleAndOffsetEnvelope( e, x, 0 );
-}
-
-inline
-ScaleAndOffsetEnvelope
-operator*( double x, const Envelope & e )
-{
- return e * x;
-}
-
-
-
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_ENVELOPE_H */
diff --git a/loris_library/Source/include/loris/Exception.h b/loris_library/Source/include/loris/Exception.h
deleted file mode 100644
index e21355c..0000000
--- a/loris_library/Source/include/loris/Exception.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef INCLUDE_EXCEPTION_H_DEPRECATED
-#define INCLUDE_EXCEPTION_H_DEPRECATED
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Exception.h
- *
- * This file formerly defined class Exception, a generic exception class, and
- * commonly-used derived exception classes, but the name caused build problems
- * on case-insensitive systems having a system header called exception.h, so
- * the name has been changed to LorisExceptions.h. This file is included as
- * legacy support. New code should use LorisExceptions.h.
- *
- * Kelly Fitz, 17 Aug 1999
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-#include "LorisExceptions.h"
-
-#endif /* ndef INCLUDE_EXCEPTION_H_DEPRECATED */
diff --git a/loris_library/Source/include/loris/F0Estimate.h b/loris_library/Source/include/loris/F0Estimate.h
deleted file mode 100644
index a20e81e..0000000
--- a/loris_library/Source/include/loris/F0Estimate.h
+++ /dev/null
@@ -1,135 +0,0 @@
-#ifndef INCLUDE_F0ESTIMATE_H
-#define INCLUDE_F0ESTIMATE_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * F0Estimate.h
- *
- * Implementation of an iterative alrogithm for computing an
- * estimate of fundamental frequency from a sequence of sinusoidal
- * frequencies and amplitudes using a likelihood estimator
- * adapted from Quatieri's Speech Signal Processing text. The
- * algorithm here takes advantage of the fact that spectral peaks
- * have already been identified and extracted in the analysis/modeling
- * process.
- *
- * Kelly Fitz, 28 March 2006
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class F0Estimate
-//
-//! Represents a configuration of an iterative alrogithm for computing an
-//! estimate of fundamental frequency from a sequence of sinusoidal
-//! frequencies and amplitudes using a likelihood estimator adapted
-//! from Quatieri's Speech Signal Processing text. This algorithm takes
-//! advantage of the fact that spectral peaks have already been identified
-//! and extracted in the analysis/modeling process.
-//!
-//! The algorithm consists of the following steps:
-//! 1) Identify candidate F0s as the integer divisors of the sinusoidal
-//! frequencies provided, within the specified range (this algorithm
-//! relies on the reasonable assumption that for any frequency recognized
-//! as a likely F0, at least one of the sinusoidal frequencies must
-//! represent a harmonic, the likelihood function makes this same
-//! assumption)
-//! 2) Select the highest frequency candidate (within range) that maximizes
-//! the likelihood function (because all subharmonics of the true F0 will
-//! be equal in likelihood to the true F0, but no higher frequency can
-//! be as likely).
-//! 2a) Check the likelihood of integer multiples of the best candidate,
-//! choose the highest multiple (within the specified range) that
-//! as likely as the best candidate frequency to be the new best
-//! candidate.
-//! 3) Refine the best candidate using the secant method for refining the
-//! root of the derivative of the likelihood function in the neighborhood
-//! of the best candidate (because a peak in the likelihood function is
-//! a root of the derivative of that function).
-//
-
-class F0Estimate
-{
-private:
-
- double m_frequency; //! estimated fundamental frequency in Hz
- double m_confidence; //! normalized confidence for this estimate,
- //! equal to 1.0 when all frequencies are perfect
- //! harmonics of this estimate's frequency
-
-public:
-
- // --- lifecycle ---
-
- //! Construct from parameters of the iterative F0 estimation
- //! algorithm. Find candidate F0 estimates as integer divisors
- //! of the peak frequencies, pick the highest frequency of the
- //! most likely candidates, and refine that estiamte using the
- //! secant method.
- //!
- //! Store the frequency and the normalized value of the
- //! likelihood function at that frequency (1.0 indicates that
- //! all the peaks are perfect harmonics of the estimated
- //! frequency).
-
- F0Estimate( const std::vector & amps,
- const std::vector & freqs,
- double fmin, double fmax,
- double resolution );
-
- // default copy/assign/destroy are OK
-
-
- // Not sure whether or why these would be useful.
- //
- // F0Estimate( void ) : m_frequency( 0 ), m_confidence( 0 ) {}
- // F0Estimate( double f, double c ) : m_frequency( f ), m_confidence( c ) {}
-
-
- // --- accessors ---
-
- //! Return the F0 frequency estimate, in Hz, for this estimate.
-
- double frequency( void ) const { return m_frequency; }
-
- //! Return the normalized confidence for this estimate,
- //! equal to 1.0 when all frequencies are perfect
- //! harmonics of this estimate's frequency.
-
- double confidence( void ) const { return m_confidence; }
-
-
-
-}; // end of class F0Estimate
-
-
-} // end of namespace Loris
-
-#endif // ndef INCLUDE_F0ESTIMATE_H
diff --git a/loris_library/Source/include/loris/Filter.h b/loris_library/Source/include/loris/Filter.h
deleted file mode 100644
index c4ddfc6..0000000
--- a/loris_library/Source/include/loris/Filter.h
+++ /dev/null
@@ -1,250 +0,0 @@
-#ifndef INCLUDE_FILTER_H
-#define INCLUDE_FILTER_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Filter.h
- *
- * Definition of class Loris::Filter, a generic digital filter of
- * arbitrary order having both feed-forward and feedback coefficients.
- *
- * Kelly Fitz, 1 Sept 1999
- * revised 9 Oct 2009
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "LorisExceptions.h"
-#include "Notifier.h"
-
-#include
-#include
-#include
-#include
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class Filter
-//
-//! Filter is an Direct Form II realization of a filter specified
-//! by its difference equation coefficients and (optionally) gain,
-//! applied to the filter output (defaults to 1.). Coefficients are
-//! specified and stored in order of increasing delay.
-//!
-//! Implements the rational transfer function
-//!
-//! -1 -nb
-//! b[0] + b[1]z + ... + b[nb] z
-//! Y(z) = G ---------------------------------- X(z)
-//! -1 -na
-//! a[0] + a[1]z + ... + a[na] z
-//!
-//! where b[k] are the feed forward coefficients, and a[k] are the feedback
-//! coefficients. If a[0] is not 1, then both a and b are normalized by a[0].
-//! G is the additional filter gain, and is unity if unspecified.
-//!
-//!
-//! Filter is implemented using a std::deque to store the filter state,
-//! and relies on the efficiency of that class. If deque is not implemented
-//! using some sort of circular buffer (as it should be -- deque is guaranteed
-//! to be efficient for repeated insertion and removal at both ends), then
-//! this filter class will be slow.
-//
-class Filter
-{
-public:
-
-// --- lifecycle ---
-
- // default construction
- //! Construct a filter with an all-pass unity gain response.
- Filter( void );
-
- // initialized construction
- //! Initialize a Filter having the specified coefficients, and
- //! order equal to the larger of the two coefficient ranges.
- //! Coefficients in the sequences are stored in increasing order
- //! (lowest order coefficient first).
- //!
- //! If template members are allowed, then the coefficients
- //! can be stored in any kind of iterator range, otherwise,
- //! they must be in an array of doubles.
- //!
- //! \param ffwdbegin is the beginning of a sequence of feed-forward coefficients
- //! \param ffwdend is the end of a sequence of feed-forward coefficients
- //! \param fbackbegin is the beginning of a sequence of feedback coefficients
- //! \param fbackend is the end of a sequence of feedback coefficients
- //! \param gain is an optional gain scale applied to the filtered signal
- //
-#if !defined(NO_TEMPLATE_MEMBERS)
- template
- Filter( IterT1 ffwdbegin, IterT1 ffwdend, // feed-forward coeffs
- IterT2 fbackbegin, IterT2 fbackend, // feedback coeffs
- double gain = 1. );
-#else
- Filter( const double * ffwdbegin, const double * ffwdend, // feed-forward coeffs
- const double * fbackbegin, const double * fbackend, // feedback coeffs
- double gain = 1. );
-#endif
-
-
- // copy constructor
- //! Make a copy of another digital filter.
- //! Do not copy the filter state (delay line).
- Filter( const Filter & other );
-
- // assignment operator
- //! Make a copy of another digital filter.
- //! Do not copy the filter state (delay line).
- Filter & operator=( const Filter & rhs );
-
- //! Destructor is virtual to enable subclassing. Subclasses may specialize
- //! construction, and may add functionality, but for efficiency, the filtering
- //! operation is non-virtual.
- ~Filter( void );
-
-
-// --- filtering ---
-
- //! Compute a filtered sample from the next input sample.
- //!
- //! \param input is the next input sample
- //! \return the next output sample
- double apply( double input );
-
- //! Function call operator, same as sample().
- //!
- //! \sa apply
- double operator() ( double input ) { return apply(input); }
-
-// --- access/mutation ---
-
- //! Provide access to the numerator (feed-forward) coefficients
- //! of this filter. The coefficients are stored in order of increasing
- //! delay (lowest order coefficient first).
-
- std::vector< double > numerator( void );
-
- //! Provide access to the numerator (feed-forward) coefficients
- //! of this filter. The coefficients are stored in order of increasing
- //! delay (lowest order coefficient first).
-
- const std::vector< double > numerator( void ) const;
-
- //! Provide access to the denominator (feedback) coefficients
- //! of this filter. The coefficients are stored in order of increasing
- //! delay (lowest order coefficient first).
-
- std::vector< double > denominator( void );
-
- //! Provide access to the denominator (feedback) coefficients
- //! of this filter. The coefficients are stored in order of increasing
- //! delay (lowest order coefficient first).
-
- const std::vector< double > denominator( void ) const;
-
-
- //! Clear the filter state.
- void clear( void );
-
-
-private:
-
-// --- implementation ---
-
- //! single delay line for Direct-Form II implementation
- std::deque< double > m_delayline;
-
- //! feed-forward coefficients
- std::vector< double > m_ffwdcoefs;
-
- //! feedback coefficients
- std::vector< double > m_fbackcoefs;
-
- //! filter gain (applied to output)
- double m_gain;
-
-}; // end of class Filter
-
-
-
-// ---------------------------------------------------------------------------
-// constructor
-// ---------------------------------------------------------------------------
-//! Initialize a Filter having the specified coefficients, and
-//! order equal to the larger of the two coefficient ranges.
-//! Coefficients in the sequences are stored in increasing order
-//! (lowest order coefficient first).
-//!
-//! If template members are allowed, then the coefficients
-//! can be stored in any kind of iterator range, otherwise,
-//! they must be in an array of doubles.
-//!
-//! \param ffwdbegin is the beginning of a sequence of feed-forward coefficients
-//! \param ffwdend is the end of a sequence of feed-forward coefficients
-//! \param fbackbegin is the beginning of a sequence of feedback coefficients
-//! \param fbackend is the end of a sequence of feedback coefficients
-//! \param gain is an optional gain scale applied to the filtered signal
-//
-#if !defined(NO_TEMPLATE_MEMBERS)
-template
-Filter::Filter( IterT1 ffwdbegin, IterT1 ffwdend, // feed-forward coeffs
- IterT2 fbackbegin, IterT2 fbackend, // feedback coeffs
- double gain ) :
-#else
-inline
-Filter::Filter( const double * ffwdbegin, const double * ffwdend, // feed-forward coeffs
- const double * fbackbegin, const double * fbackend, // feedback coeffs
- double gain ) :
-#endif
- m_ffwdcoefs( ffwdbegin, ffwdend ),
- m_fbackcoefs( fbackbegin, fbackend ),
- m_delayline( std::max( ffwdend-ffwdbegin, fbackend-fbackbegin ) - 1, 0. ),
- m_gain( gain )
-{
- if ( *fbackbegin == 0. )
- {
- Throw( InvalidObject,
- "Tried to create a Filter with feeback coefficient at zero delay equal to 0.0" );
- }
-
- // normalize the coefficients by 1/a[0], if a[0] is not equal to 1.0
- // (already checked for a[0] == 0 above)
- if ( *fbackbegin != 1. )
- {
- // scale all filter coefficients by a[0]:
- std::transform( m_ffwdcoefs.begin(), m_ffwdcoefs.end(), m_ffwdcoefs.begin(),
- std::bind2nd( std::divides(), *fbackbegin ) );
- std::transform( m_fbackcoefs.begin(), m_fbackcoefs.end(), m_fbackcoefs.begin(),
- std::bind2nd( std::divides(), *fbackbegin ) );
- m_fbackcoefs[0] = 1.;
- }
-}
-
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_FILTER_H */
diff --git a/loris_library/Source/include/loris/FourierTransform.h b/loris_library/Source/include/loris/FourierTransform.h
deleted file mode 100644
index 34867ee..0000000
--- a/loris_library/Source/include/loris/FourierTransform.h
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef INCLUDE_FOURIERTRANSFORM_H
-#define INCLUDE_FOURIERTRANSFORM_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * FourierTransform.h
- *
- * Definition of class Loris::FourierTransform, providing a simplified
- * uniform interface to the FFTW library (www.fftw.org), version 2.1.3
- * or newer (including version 3), or to the General Purpose FFT package
- * by Takuya OOURA, http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html if
- * FFTW is unavailable.
- *
- * Kelly Fitz, 2 Jun 2006
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-#include
-#include
-
-// begin namespace
-namespace Loris {
-
-// insulating implementation class, defined in FourierTransform.C
-class FTimpl;
-
-// ---------------------------------------------------------------------------
-// class FourierTransform
-//
-//! FourierTransform provides a simplified interface to the FFTW library
-//! (www.fftw.org). Loris uses the FFTW library to perform efficient
-//! Fourier transforms of arbitrary length. Clients store and access
-//! the in-place transform data as a sequence of std::complex< double >.
-//! Samples are stored in the FourierTransform instance using subscript
-//! or iterator access, the transform is computed by the transform member,
-//! and the transformed samples replace the input samples, and are
-//! accessed by subscript or iterator. FourierTransform computes a complex
-//! transform, so it can be used to invert a transform of real samples
-//! as well. Uses the standard library complex class, which implements
-//! arithmetic operations.
-//!
-//! Supports FFTW versions 2 and 3.
-//! Does not make use of FFTW "wisdom" to speed up transform computation.
-//!
-//! If FFTW is unavailable, uses instead the General Purpose FFT package
-//! by Takuya OOURA, http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html defined
-//! in fftsg.c for power-of-two transforms, and a very slow direct DFT
-//! implementation for non-PO2 transforms.
-//
-class FourierTransform
-{
-// -- public interface --
-public:
-
- //! An unsigned integral type large enough
- //! to represent the length of any transform.
- typedef std::vector< std::complex< double > >::size_type size_type;
-
- //! The type of a non-const iterator of (complex) transform samples.
- typedef std::vector< std::complex< double > >::iterator iterator;
-
- //! The type of a const iterator of (complex) transform samples.
- typedef std::vector< std::complex< double > >::const_iterator const_iterator;
-
-// --- lifecycle ---
-
- //! Initialize a new FourierTransform of the specified size.
- //!
- //! \param len is the length of the transform in samples (the
- //! number of samples in the transform)
- //! \throw RuntimeError if the necessary buffers cannot be
- //! allocated, or there is an error configuring FFTW.
- FourierTransform( size_type len );
-
- //! Initialize a new FourierTransform that is a copy of another,
- //! having the same size and the same buffer contents.
- //!
- //! \param rhs is the instance to copy
- //! \throw RuntimeError if the necessary buffers cannot be
- //! allocated, or there is an error configuring FFTW.
- FourierTransform( const FourierTransform & rhs );
-
- //! Free the resources associated with this FourierTransform.
- ~FourierTransform( void );
-
-// --- operators ---
-
- //! Make this FourierTransform a copy of another, having
- //! the same size and buffer contents.
- //!
- //! \param rhs is the instance to copy
- //! \return a refernce to this instance
- //! \throw RuntimeError if the necessary buffers cannot be
- //! allocated, or there is an error configuring FFTW.
- FourierTransform & operator= ( const FourierTransform & rhs );
-
-
-// --- access/mutation ---
-
- //! Access (read/write) a transform sample by index.
- //! Use this member to fill the transform buffer before
- //! computing the transform, and to access the samples
- //! after computing the transform. (inlined for speed)
- //!
- //! \param index is the index or rank of the complex
- //! transform sample to access. Zero is the first
- //! position in the buffer.
- //! \return non-const reference to the std::complex< double >
- //! at the specified position in the buffer.
- std::complex< double > & operator[] ( size_type index )
- {
- return _buffer[ index ];
- }
-
- //! Access (read-only) a transform sample by index.
- //! Use this member to fill the transform buffer before
- //! computing the transform, and to access the samples
- //! after computing the transform. (inlined for speed)
- //!
- //! \param index is the index or rank of the complex
- //! transform sample to access. Zero is the first
- //! position in the buffer.
- //! \return const reference to the std::complex< double >
- //! at the specified position in the buffer.
- const std::complex< double > & operator[] ( size_type index ) const
- {
- return _buffer[ index ];
- }
-
- //! Return an iterator refering to the beginning of the sequence of
- //! complex samples in the transform buffer.
- //!
- //! \return a non-const iterator refering to the first position
- //! in the transform buffer.
- iterator begin( void )
- {
- return _buffer.begin();
- }
-
- //! Return an iterator refering to the end of the sequence of
- //! complex samples in the transform buffer.
- //!
- //! \return a non-const iterator refering to one past the last
- //! position in the transform buffer.
- iterator end( void )
- {
- return _buffer.end();
- }
-
- //! Return a const iterator refering to the beginning of the sequence of
- //! complex samples in the transform buffer.
- //!
- //! \return a const iterator refering to the first position
- //! in the transform buffer.
- const_iterator begin( void ) const
- {
- return _buffer.begin();
- }
-
- //! Return a const iterator refering to the end of the sequence of
- //! complex samples in the transform buffer.
- //!
- //! \return a const iterator refering to one past the last
- //! position in the transform buffer.
- const_iterator end( void ) const
- {
- return _buffer.end();
- }
-
-// --- operations ---
-
- //! Compute the Fourier transform of the samples stored in the
- //! transform buffer. The samples stored in the transform buffer
- //! (accessed by index or by iterator) are replaced by the
- //! transformed samples, in-place.
- void transform( void );
-
-// --- inquiry ---
-
- //! Return the length of the transform (in samples).
- //!
- //! \return the length of the transform in samples.
- size_type size( void ) const ;
-
-// -- instance variables --
-private:
-
- //! buffer containing the complex transform input before
- //! computing the transform, and the complex transform output
- //! after computing the transform
- std::vector< std::complex< double > > _buffer;
-
- // insulating implementation instance (defined in
- // FourierTransform.C), conceals interface to FFTW
- FTimpl * _impl;
-
-}; // end of class FourierTransform
-
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_FOURIERTRANSFORM_H */
diff --git a/loris_library/Source/include/loris/FrequencyReference.h b/loris_library/Source/include/loris/FrequencyReference.h
deleted file mode 100644
index 366c57f..0000000
--- a/loris_library/Source/include/loris/FrequencyReference.h
+++ /dev/null
@@ -1,132 +0,0 @@
-#ifndef INCLUDE_FREQUENCYREFERENCE_H
-#define INCLUDE_FREQUENCYREFERENCE_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * FrequencyReference.h
- *
- * Definition of class FrequencyReference.
- *
- * Kelly Fitz, 3 Dec 2001
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "Envelope.h"
-#include "PartialList.h"
-#include
-
-// begin namespace
-namespace Loris {
-
-class LinearEnvelope;
-
-// ---------------------------------------------------------------------------
-// class FrequencyReference
-//
-//! Class FrequencyReference represents a reference frequency envelope
-//! derived from an estimate of the fundamental frequency of a given range
-//! of Partials within in a specified frequency range. This reference envelope
-//! can be used for channelizing the Partials in preparation for morphing
-//! (see Channelizer.h).
-//!
-//! FrequencyReference implements the Envelope interface (see
-//! Envelope.h).
-//
-class FrequencyReference : public Envelope
-{
-// -- instance variables --
- std::auto_ptr< LinearEnvelope > _env;
-
-// -- public interface --
-public:
-// -- construction --
-
- //! Construct a new fundamental FrequencyReference derived from the
- //! specified half-open (STL-style) range of Partials that lies
- //! within the speficied average frequency range. Construct the
- //! reference envelope with approximately numSamps points.
- //!
- //! \param begin The beginning of a range of Partials from which to
- //! construct a frequency refence envelope.
- //! \param end The end of a range of Partials from which to
- //! construct a frequency refence envelope.
- //! \param minFreq The minimum expected fundamental frequency.
- //! \param maxFreq The maximum expected fundamental frequency.
- //! \param numSamps The approximate number of estimate of the
- //! fundamental frequency from which to construct the
- //! frequency reference envelope.
- FrequencyReference( PartialList::const_iterator begin,
- PartialList::const_iterator end,
- double minFreq, double maxFreq, long numSamps );
-
- //! Construct a new fundamental FrequencyReference derived from the
- //! specified half-open (STL-style) range of Partials that lies
- //! within the speficied average frequency range. Construct the
- //! reference envelope from fundamental estimates taken every
- //! five milliseconds.
- //!
- //! \param begin The beginning of a range of Partials from which to
- //! construct a frequency refence envelope.
- //! \param end The end of a range of Partials from which to
- //! construct a frequency refence envelope.
- //! \param minFreq The minimum expected fundamental frequency.
- //! \param maxFreq The maximum expected fundamental frequency.
- FrequencyReference( PartialList::const_iterator begin,
- PartialList::const_iterator end,
- double minFreq, double maxFreq );
-
-
- //! Construct a new FrequencyReference that is an exact copy of the
- //! specified FrequencyReference.
- FrequencyReference( const FrequencyReference & other );
-
- //! Assignment operator: make this FrequencyReference an exact copy
- //! of the specified FrequencyReference.
- FrequencyReference & operator= ( const FrequencyReference & other );
-
- //! Destroy this FrequencyReference.
- ~FrequencyReference();
-
-// -- conversion to LinearEnvelope --
-
- //! Return a LinearEnvelope that evaluates indentically to this
- //! FrequencyReference at all time.
- LinearEnvelope envelope( void ) const;
-
-// -- Envelope interface --
-
- //! Return an exact copy of this FrequencyReference (following the
- //! Prototype pattern).
- virtual FrequencyReference * clone( void ) const;
-
- //! Return the frequency value (in Hz) of this FrequencyReference at the
- //! specified time.
- virtual double valueAt( double x ) const;
-
-}; // end of class FrequencyReference
-
-} // end of namespace Loris
-
-#endif // ndef INCLUDE_FREQUENCYREFERENCE_H
diff --git a/loris_library/Source/include/loris/Fundamental.h b/loris_library/Source/include/loris/Fundamental.h
deleted file mode 100644
index 5971408..0000000
--- a/loris_library/Source/include/loris/Fundamental.h
+++ /dev/null
@@ -1,737 +0,0 @@
-#ifndef INCLUDE_FUNDAMENTAL_H
-#define INCLUDE_FUNDAMENTAL_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Fundamental.h
- *
- * Definition of classes for computing an estimate of time-varying
- * fundamental frequency from either a sequence of samples or a
- * collection of Partials using a frequency domain maximum likelihood
- * algorithm adapted from Quatieri's speech signal processing textbook.
- *
- * Kelly Fitz, 25 March 2008
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "LinearEnvelope.h"
-#include "PartialList.h"
-#include "F0Estimate.h"
-
-#include
-#include
-
-// begin namespace
-namespace Loris {
-
-class ReassignedSpectrum;
-
-// ---------------------------------------------------------------------------
-// class FundamentalEstimator
-//
-//! Base class for fundamental estimation, common storage for member
-//! variable parameters, type definitions, and constants.
-
-class FundamentalEstimator
-{
-public:
-
-// -- types --
-
- typedef F0Estimate value_type;
-
-// -- constants --
-
- enum {
-
- DefaultAmpFloor = -60, //! the default absolute amplitude threshold in dB
-
- DefaultAmpRange = 30, //! the default floating amplitude threshold in dB
-
- DefaultFreqCeiling = 4000, //! the default frequency threshold in Hz
-
- DefaultPrecisionOver100 = 10, //! the default frequency precision in 1/100 Hz
-
- DefaultMinConfidencePct = 90 //! the default required percent confidence to
- //! return an estimate (100 is absolute confidence)
- };
-
-
-// -- lifecycle --
-
-protected:
-
- //! Construct a new estimator with specified precision and
- //! other parameters given default values.
- //!
- //! The specified precision is used to terminate the iterative
- //! estimation procedure.
- //!
- //! \param precisionHz is the precision in Hz with which the
- //! fundamental estimates will be made.
- FundamentalEstimator( double precisionHz );
-
-public:
-
- //! Destructor
- virtual ~FundamentalEstimator( void );
-
-
- // compiler-generated copy and assignment are OK
-
-
-// -- parameter access --
-
- //! Return the absolute amplitude threshold in (negative) dB,
- //! below which spectral peaks will not be considered in the
- //! estimation of the fundamental (default is 30 dB).
- double ampFloor( void ) const;
-
- //! Return the amplitude range in dB,
- //! relative to strongest peak in a frame, floating
- //! amplitude threshold (negative) below which spectral
- //! peaks will not be considered in the estimation of
- //! the fundamental (default is 30 dB).
- double ampRange( void ) const;
-
- //! Return the frequency ceiling in Hz, the
- //! frequency threshold above which spectral
- //! peaks will not be considered in the estimation of
- //! the fundamental (default is 10 kHz).
- double freqCeiling( void ) const;
-
- //! Return the precision of the estimate in Hz, the
- //! fundamental frequency will be estimated to
- //! within this range (default is 0.1 Hz).
- double precision( void ) const;
-
-// -- parameter mutation --
-
- //! Set the absolute amplitude threshold in (negative) dB,
- //! below which spectral peaks will not be considered in the
- //! estimation of the fundamental (default is 30 dB).
- //!
- //! \param x is the new value of this parameter.
- void setAmpFloor( double x );
-
- //! Set the amplitude range in dB,
- //! relative to strongest peak in a frame, floating
- //! amplitude threshold (negative) below which spectral
- //! peaks will not be considered in the estimation of
- //! the fundamental (default is 30 dB).
- //!
- //! \param x is the new value of this parameter.
- void setAmpRange( double x );
-
- //! Set the frequency ceiling in Hz, the
- //! frequency threshold above which spectral
- //! peaks will not be considered in the estimation of
- //! the fundamental (default is 10 kHz). Must be
- //! greater than the lower bound.
- //!
- //! \param x is the new value of this parameter.
- void setFreqCeiling( double x );
-
- //! Set the precision of the estimate in Hz, the
- //! fundamental frequency will be estimated to
- //! within this range (default is 0.1 Hz).
- //!
- //! \param x is the new value of this parameter.
- void setPrecision( double x );
-
-
-protected:
-
-// -- parameter member variables --
-
-
- double m_precision; //! in Hz, fundamental frequency will be estimated to
- //! within this range (default is 0.1 Hz)
-
- double m_ampFloor; //! absolute amplitude threshold below which spectral
- //! peaks will not be considered in the estimation of
- //! the fundamental (default is equivalent to 60 dB
- //! quieter than a full scale sinusoid)
-
- double m_ampRange; //! floating amplitude threshold relative to the peak
- //! having the largest magnitude below which spectral
- //! peaks will not be considered in the estimation of
- //! the fundamental (default is equivalent to 30 dB)
-
- double m_freqCeiling; //! in Hz, frequency threshold above which spectral
- //! peaks will not be considered in the estimation of
- //! the fundamental (default is 10 kHz)
-
-
-}; // end of base class FundamentalEstimator
-
-
-
-// ---------------------------------------------------------------------------
-// class FundamentalFromSamples
-//
-//! Class FundamentalFromSamples represents an algorithm for
-//! time-varying fundamental frequency estimation based on
-//! time-frequency reassigned spectral analysis of a sequence
-//! of samples. This class is adapted from the Analyzer class
-//! (see Analyzer.h), and performs the same spectral analysis
-//! and peak extraction, but does not form Partials.
-//!
-//! For more information about Reassigned Bandwidth-Enhanced
-//! Analysis and the Reassigned Bandwidth-Enhanced Additive Sound
-//! Model, refer to the Loris website: www.cerlsoundgroup.org/Loris/.
-//
-class FundamentalFromSamples : public FundamentalEstimator
-{
-// -- public interface --
-
-public:
-
-// -- lifecycle --
-
- //! Construct a new estimator configured with the given
- //! analysis window width (main lobe, zero-to-zero). All other
- //! spectrum analysis parameters are computed from the specified
- //! window width.
- //!
- //! The specified precision is used to terminate the iterative
- //! estimation procedure. If unspecified, the default value,
- //! DefaultPrecisionOver100 * 100 is used.
- //!
- //! \param windowWidthHz is the main lobe width of the Kaiser
- //! analysis window in Hz.
- //!
- //! \param precisionHz is the precision in Hz with which the
- //! fundamental estimates will be made.
- FundamentalFromSamples( double winWidthHz,
- double precisionHz = DefaultPrecisionOver100 * 0.01 );
-
-
-
- //! Destructor
- ~FundamentalFromSamples( void );
-
-// -- fundamental frequency estimation --
-
- // buildEnvelope
- //
- //! Construct a linear envelope from fundamental frequency
- //! estimates taken at the specified interval in seconds
- //! starting at tbeg (seconds) and ending before tend (seconds).
- //!
- //! \param samps is the beginning of a sequence of samples
- //! \param sampsEnd is the end of the sequence of samples
- //! \param sampleRate is the sampling rate (in Hz) associated
- //! with the sequence of samples (used to compute frequencies
- //! in Hz, and to convert the time from seconds to samples)
- //! \param tbeg is the beginning of the time interval (in seconds)
- //! \param tend is the end of the time interval (in seconds)
- //! \param interval is the time between breakpoints in the
- //! fundamental frequency envelope (in seconds)
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param confidenceThreshold is the minimum confidence level
- //! resuired for a fundamental frequency estimate to be
- //! added to the envelope. Lower confidence estimates are
- //! not added, the envelope returned will not contain
- //! breakpoints at times associated with low confidence
- //! estimates
- //! \return a LinearEnvelope composed of breakpoints corresponding to
- //! the fundamental frequency estimates at samples of the span
- //! tbeg to tend at the specified sampling interval, only estimates
- //! having confidence level exceeding the specified confidence
- //! threshold are added to the envelope
- LinearEnvelope buildEnvelope( const double * sampsBeg,
- const double * sampsEnd,
- double sampleRate,
- double tbeg, double tend,
- double interval,
- double lowerFreqBound, double upperFreqBound,
- double confidenceThreshold );
-
- // buildEnvelope
- //
- //! Construct a linear envelope from fundamental frequency
- //! estimates taken at the specified interval in seconds
- //! starting at tbeg (seconds) and ending before tend (seconds).
- //!
- //! \param samps is the beginning of a sequence of samples
- //! \param nsamps is the length of the sequence of samples
- //! \param sampleRate is the sampling rate (in Hz) associated
- //! with the sequence of samples (used to compute frequencies
- //! in Hz, and to convert the time from seconds to samples)
- //! \param tbeg is the beginning of the time interval (in seconds)
- //! \param tend is the end of the time interval (in seconds)
- //! \param interval is the time between breakpoints in the
- //! fundamental frequency envelope (in seconds)
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param confidenceThreshold is the minimum confidence level
- //! resuired for a fundamental frequency estimate to be
- //! added to the envelope. Lower confidence estimates are
- //! not added, the envelope returned will not contain
- //! breakpoints at times associated with low confidence
- //! estimates
- //! \return a LinearEnvelope composed of breakpoints corresponding to
- //! the fundamental frequency estimates at samples of the span
- //! tbeg to tend at the specified sampling interval, only estimates
- //! having confidence level exceeding the specified confidence
- //! threshold are added to the envelope
- LinearEnvelope buildEnvelope( const double * sampsBeg,
- unsigned long nsamps,
- double sampleRate,
- double tbeg, double tend,
- double interval,
- double lowerFreqBound, double upperFreqBound,
- double confidenceThreshold )
- {
- return buildEnvelope( sampsBeg, sampsBeg + nsamps, sampleRate,
- tbeg, tend, interval,
- lowerFreqBound, upperFreqBound,
- confidenceThreshold );
- }
-
-
- // buildEnvelope
- //
- //! Construct a linear envelope from fundamental frequency
- //! estimates taken at the specified interval in seconds
- //! starting at tbeg (seconds) and ending before tend (seconds).
- //!
- //! \param samps is the sequence of samples
- //! \param sampleRate is the sampling rate (in Hz) associated
- //! with the sequence of samples (used to compute frequencies
- //! in Hz, and to convert the time from seconds to samples)
- //! \param tbeg is the beginning of the time interval (in seconds)
- //! \param tend is the end of the time interval (in seconds)
- //! \param interval is the time between breakpoints in the
- //! fundamental frequency envelope (in seconds)
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param confidenceThreshold is the minimum confidence level
- //! resuired for a fundamental frequency estimate to be
- //! added to the envelope. Lower confidence estimates are
- //! not added, the envelope returned will not contain
- //! breakpoints at times associated with low confidence
- //! estimates
- //! \return a LinearEnvelope composed of breakpoints corresponding to
- //! the fundamental frequency estimates at samples of the span
- //! tbeg to tend at the specified sampling interval, only estimates
- //! having confidence level exceeding the specified confidence
- //! threshold are added to the envelope
- LinearEnvelope buildEnvelope( const std::vector< double > & samps,
- double sampleRate,
- double tbeg, double tend,
- double interval,
- double lowerFreqBound, double upperFreqBound,
- double confidenceThreshold )
- {
- return buildEnvelope( &samps[0], &samps[0] + samps.size(), sampleRate,
- tbeg, tend, interval,
- lowerFreqBound, upperFreqBound,
- confidenceThreshold );
- }
-
-
- // estimateAt
- //
- //! Return an estimate of the fundamental frequency computed
- //! at the specified time. The F0Estimate returned stores the
- //! estimate of the fundamental frequency (in Hz) and the
- //! relative confidence (from 0 to 1) associated with that
- //! estimate.
- //!
- //! \param sampsBeg is the beginning of a sequence of samples
- //! \param sampsEnd is the end of the sequence of samples
- //! \param sampleRate is the sampling rate (in Hz) associated
- //! with the sequence of samples (used to compute frequencies
- //! in Hz, and to convert the time from seconds to samples)
- //! \param time is the time in seconds at which to attempt to estimate
- //! the fundamental frequency
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \return the estimate of fundamental frequency in Hz and the
- //! confidence associated with that estimate (see
- //! F0Estimate.h)
-
- value_type estimateAt( const double * sampsBeg,
- const double * sampsEnd,
- double sampleRate,
- double time,
- double lowerFreqBound, double upperFreqBound );
-
- // estimateAt
- //
- //! Return an estimate of the fundamental frequency computed
- //! at the specified time. The F0Estimate returned stores the
- //! estimate of the fundamental frequency (in Hz) and the
- //! relative confidence (from 0 to 1) associated with that
- //! estimate.
- //!
- //! \param samps is the beginning of a sequence of samples
- //! \param nsamps is the length of the sequence of samples
- //! \param sampleRate is the sampling rate (in Hz) associated
- //! with the sequence of samples (used to compute frequencies
- //! in Hz, and to convert the time from seconds to samples)
- //! \param time is the time in seconds at which to attempt to estimate
- //! the fundamental frequency
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \return the estimate of fundamental frequency in Hz and the
- //! confidence associated with that estimate (see
- //! F0Estimate.h)
-
- value_type estimateAt( const double * sampsBeg,
- unsigned long nsamps,
- double sampleRate,
- double time,
- double lowerFreqBound, double upperFreqBound )
- {
- return estimateAt( sampsBeg, sampsBeg + nsamps, sampleRate,
- time, lowerFreqBound, upperFreqBound );
- }
-
- // estimateAt
- //
- //! Return an estimate of the fundamental frequency computed
- //! at the specified time. The F0Estimate returned stores the
- //! estimate of the fundamental frequency (in Hz) and the
- //! relative confidence (from 0 to 1) associated with that
- //! estimate.
- //!
- //! \param samps is the sequence of samples
- //! \param sampleRate is the sampling rate (in Hz) associated
- //! with the sequence of samples (used to compute frequencies
- //! in Hz, and to convert the time from seconds to samples)
- //! \param time is the time in seconds at which to attempt to estimate
- //! the fundamental frequency
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \return the estimate of fundamental frequency in Hz and the
- //! confidence associated with that estimate (see
- //! F0Estimate.h)
-
- value_type estimateAt( const std::vector< double > & samps,
- double sampleRate,
- double time,
- double lowerFreqBound, double upperFreqBound )
- {
- return estimateAt( &samps[0], &samps[0] + samps.size(), sampleRate,
- time, lowerFreqBound, upperFreqBound );
- }
-
-
-
-// -- spectral analysis parameter access/mutation --
-
- //! Return the frequency-domain main lobe width (in Hz measured
- //! between zero-crossings) of the analysis window used in spectral
- //! analysis.
- double windowWidth( void ) const;
-
- //! Set the frequency-domain main lobe width (in Hz measured
- //! between zero-crossings) of the analysis window used in spectral
- //! analysis.
- //!
- //! \param w is the new main lobe width in Hz
- void setWindowWidth( double w );
-
-
-
-// -- private auxiliary functions --
-
-private:
-
- // buildSpectrumAnalyzer
- //
- //! Construct the ReassignedSpectrum that will be used to perform
- //! spectral analysis from which peak frequencies and amplitudes
- //! will be drawn. This construction is performed in a lazy fashion,
- //! and needs to be done again when certain of the parameters change.
- //!
- //! \param srate is the sampling frequency in Hz, needed to compute
- //! analysis window parameters
- void buildSpectrumAnalyzer( double srate );
-
-
- // collectFreqsAndAmps
- //
- //! Perform spectral analysis on a sequence of samples, using
- //! an analysis window centered at the specified time in seconds.
- //! Collect the frequencies and amplitudes of the peaks and return
- //! them in the vectors provided.
- //!
- //! \param samps is the beginning of a sequence of samples
- //! \param nsamps is the length of the sequence of Partials
- //! \param sampleRate is the sampling rate (in Hz) associated
- //! with the sequence of samples (used to compute frequencies
- //! in Hz, and to convert the time from seconds to samples)
- //! \param frequencies is a vector in which to store a sequence of
- //! frequencies to be used to estimate the most likely
- //! fundamental frequency
- //! \param amplitudes is a vector in which to store a sequence of
- //! amplitudes to be used to estimate the most likely
- //! fundamental frequency
- //! \param time is the time in seconds at which to collect frequencies
- //! and amplitudes of spectral peaks
-
- void collectFreqsAndAmps( const double * samps,
- unsigned long nsamps,
- double sampleRate,
- std::vector< double > & frequencies,
- std::vector< double > & amplitudes,
- double time );
-
-
-// -- private member variables --
-
- std::auto_ptr< ReassignedSpectrum > m_spectrum;
- //! the spectrum analyzer
-
- double m_cacheSampleRate; //! the sample rate used to construct the
-
- double m_windowWidth; //! the width of the main lobe of the window to
- //! be used in spectral analysis, in Hz
-
-// disallow these until they are implemented
-
- FundamentalFromSamples( const FundamentalFromSamples & );
- FundamentalFromSamples & operator= ( const FundamentalFromSamples & );
-
-}; // end of class FundamentalFromSamples
-
-
-
-// ---------------------------------------------------------------------------
-// class FundamentalFromPartials
-//
-//! Class FundamentalFromPartials represents an algorithm for
-//! time-varying fundamental frequency estimation from instantaneous
-//! Partial amplitudes and frequencies based on a likelihood
-//! estimator adapted from Quatieri's Speech Signal Processing text
-
-class FundamentalFromPartials : public FundamentalEstimator
-{
-// -- public interface --
-
-public:
-
-// -- lifecycle --
-
- //! Construct a new estimator.
- //!
- //! The specified precision is used to terminate the iterative
- //! estimation procedure. If unspecified, the default value,
- //! DefaultPrecisionOver100 * 100 is used.
- //!
- //! \param precisionHz is the precision in Hz with which the
- //! fundamental estimates will be made.
- FundamentalFromPartials( double precisionHz = DefaultPrecisionOver100 * 0.01 );
-
-
- //! Destructor
- ~FundamentalFromPartials( void );
-
- //! Construct a copy of an estimator. Nothing much to do since this class
- //! has no data members.
- FundamentalFromPartials( const FundamentalFromPartials & );
-
- //! Pass the assignment opertion up to the base class.
- FundamentalFromPartials & operator= ( const FundamentalFromPartials & );
-
-// -- fundamental frequency estimation --
-
- // buildEnvelope
- //
- //! Construct a linear envelope from fundamental frequency
- //! estimates taken at the specified interval in seconds
- //! starting at tbeg (seconds) and ending before tend (seconds).
- //!
- //! \param begin_partials is the beginning of a sequence of Partials
- //! \param end_partials is the end of a sequence of Partials
- //! \param tbeg is the beginning of the time interval (in seconds)
- //! \param tend is the end of the time interval (in seconds)
- //! \param interval is the time between breakpoints in the
- //! fundamental frequency envelope (in seconds)
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param confidenceThreshold is the minimum confidence level
- //! resuired for a fundamental frequency estimate to be
- //! added to the envelope. Lower confidence estimates are
- //! not added, the envelope returned will not contain
- //! breakpoints at times associated with low confidence
- //! estimates
- //! \return a LinearEnvelope composed of breakpoints corresponding to
- //! the fundamental frequency estimates at samples of the span
- //! tbeg to tend at the specified sampling interval, only estimates
- //! having confidence level exceeding the specified confidence
- //! threshold are added to the envelope
- LinearEnvelope buildEnvelope( PartialList::const_iterator begin_partials,
- PartialList::const_iterator end_partials,
- double tbeg, double tend,
- double interval,
- double lowerFreqBound, double upperFreqBound,
- double confidenceThreshold );
-
- // buildEnvelope
- //
- //! Construct a linear envelope from fundamental frequency
- //! estimates taken at the specified interval in seconds
- //! starting at tbeg (seconds) and ending before tend (seconds).
- //!
- //! \param partials is the sequence of Partials
- //! \param tbeg is the beginning of the time interval (in seconds)
- //! \param tend is the end of the time interval (in seconds)
- //! \param interval is the time between breakpoints in the
- //! fundamental frequency envelope (in seconds)
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param confidenceThreshold is the minimum confidence level
- //! resuired for a fundamental frequency estimate to be
- //! added to the envelope. Lower confidence estimates are
- //! not added, the envelope returned will not contain
- //! breakpoints at times associated with low confidence
- //! estimates
- //! \return a LinearEnvelope composed of breakpoints corresponding to
- //! the fundamental frequency estimates at samples of the span
- //! tbeg to tend at the specified sampling interval, only estimates
- //! having confidence level exceeding the specified confidence
- //! threshold are added to the envelope
- LinearEnvelope buildEnvelope( const PartialList & partials,
- double tbeg, double tend,
- double interval,
- double lowerFreqBound, double upperFreqBound,
- double confidenceThreshold )
- {
- return buildEnvelope( partials.begin(), partials.end(),
- tbeg, tend, interval,
- lowerFreqBound, upperFreqBound,
- confidenceThreshold );
- }
-
-
- // estimateAt
- //
- //! Return an estimate of the fundamental frequency computed
- //! at the specified time. The F0Estimate returned stores the
- //! estimate of the fundamental frequency (in Hz) and the
- //! relative confidence (from 0 to 1) associated with that
- //! estimate.
- //!
- //! \param begin_partials is the beginning of a sequence of Partials
- //! \param end_partials is the end of a sequence of Partials
- //! \param time is the time in seconds at which to attempt to estimate
- //! the fundamental frequency
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \return the estimate of fundamental frequency in Hz and the
- //! confidence associated with that estimate (see
- //! F0Estimate.h)
- value_type estimateAt( PartialList::const_iterator begin_partials,
- PartialList::const_iterator end_partials,
- double time,
- double lowerFreqBound, double upperFreqBound );
-
- // estimateAt
- //
- //! Return an estimate of the fundamental frequency computed
- //! at the specified time. The F0Estimate returned stores the
- //! estimate of the fundamental frequency (in Hz) and the
- //! relative confidence (from 0 to 1) associated with that
- //! estimate.
- //!
- //! \param partials is the sequence of Partials
- //! \param time is the time in seconds at which to attempt to estimate
- //! the fundamental frequency
- //! \param lowerFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \param upperFreqBound is the lower bound on the fundamental
- //! frequency estimate (in Hz)
- //! \return the estimate of fundamental frequency in Hz and the
- //! confidence associated with that estimate (see
- //! F0Estimate.h)
- value_type estimateAt( const PartialList & partials,
- double time,
- double lowerFreqBound, double upperFreqBound )
- {
- return estimateAt( partials.begin(), partials.end(),
- time,
- lowerFreqBound, upperFreqBound );
- }
-
-
-
-// -- private auxiliary functions --
-
-private:
-
- // collectFreqsAndAmps
- //
- //! Collect the frequencies and amplitudes of a range of partials
- //! at the specified time and return them in the vectors provided.
- //!
- //! \param begin_partials is the beginning of a sequence of Partials
- //! \param end_partials is the end of a sequence of Partials
- //! \param frequencies is a vector in which to store a sequence of
- //! frequencies to be used to estimate the most likely
- //! fundamental frequency
- //! \param amplitudes is a vector in which to store a sequence of
- //! amplitudes to be used to estimate the most likely
- //! fundamental frequency
- //! \param time is the time in seconds at which to collect frequencies
- //! and amplitudes of the Partials
- void collectFreqsAndAmps( PartialList::const_iterator begin_partials,
- PartialList::const_iterator end_partials,
- std::vector< double > & frequencies,
- std::vector< double > & amplitudes,
- double time );
-
-
-
-}; // end of class FundamentalFromPartials
-
-
-
-} // end of namespace Loris
-
-#endif // ndef INCLUDE_FUNDAMENTAL_H
diff --git a/loris_library/Source/include/loris/Harmonifier.h b/loris_library/Source/include/loris/Harmonifier.h
deleted file mode 100644
index b1b04d8..0000000
--- a/loris_library/Source/include/loris/Harmonifier.h
+++ /dev/null
@@ -1,441 +0,0 @@
-#ifndef INCLUDE_HARMONIFIER_H
-#define INCLUDE_HARMONIFIER_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * Harmonifier.h
- *
- * Definition of class Harmonifier.
- *
- * Kelly Fitz, 26 Oct 2005
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-#include "Envelope.h"
-#include "LorisExceptions.h"
-#include "Partial.h"
-#include "PartialUtils.h"
-
-#include // for find
-#include // for auto_ptr
-
-// begin namespace
-namespace Loris {
-
-
-// ---------------------------------------------------------------------------
-// Class Harmonifier
-//
-//! A Harmonifier uses a reference frequency envelope to make the
-//! frequencies of labeled Partials harmonic. The amount of frequency
-//! adjustment can be controlled by a time-varying envelope, and a
-//! threshold can be supplied so that only quiet Partials are affected.
-//
-class Harmonifier
-{
-// -- instance variables --
-
- Partial _refPartial; //! the Partial whose frequency supplies the
- //! reference frequency envelope.
-
- double _freqFixThresholdDb; //! amplitude threshold below which Partial
- //! frequencies are corrected according to
- //! a reference Partial, if specified.
-
- std::auto_ptr< Envelope > _weight; //! weighting function, when 1 harmonic
- //! frequencies are used, when 0 breakpoint
- //! frequencies are unmodified.
-
-// -- public interface --
-public:
-
-// -- lifecycle --
-
- //! Construct a new Harmonifier that applies the specified
- //! reference Partial to fix the frequencies of Breakpoints
- //! whose amplitude is below threshold_dB (0 by default,
- //! to apply only to quiet Partials, specify a threshold,
- //! like -90).
- Harmonifier( const Partial & ref, double threshold_dB = 0 );
-
- //! Construct a new Harmonifier that applies the specified
- //! reference Partial to fix the frequencies of Breakpoints
- //! whose amplitude is below threshold_dB (0 by default,
- //! to apply only to quiet Partials, specify a threshold,
- //! like -90). The Envelope is a time-varying weighting
- //! on the harmonifing process. When 1, harmonic frequencies
- //! are used, when 0, breakpoint frequencies are unmodified.
- Harmonifier( const Partial & ref, const Envelope & env,
- double threshold_dB = 0 );
-
- //! Construct a new Harmonifier that applies the specified
- //! reference Partial to fix the frequencies of Breakpoints
- //! whose amplitude is below threshold_dB (0 by default,
- //! to apply only to quiet Partials, specify a threshold,
- //! like -90). The reference Partial is the first Partial
- //! in the range [b,e) having the specified label.
- //
- //! \throw InvalidArgument if no Partial in the range [b,e)
- //! has the specified label.
- //
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- Harmonifier( Iter b, Iter e, Partial::label_type refLabel,
- double threshold_dB = 0 );
-#else
- inline
- Harmonifier( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel, double threshold_dB = 0 );
-#endif
-
- //! Construct a new Harmonifier that applies the specified
- //! reference Partial to fix the frequencies of Breakpoints
- //! whose amplitude is below threshold_dB (0 by default,
- //! to apply only to quiet Partials, specify a threshold,
- //! like -90). The reference Partial is the first Partial
- //! in the range [b,e) having the specified label.
- //!
- //! The Envelope is a time-varying weighting
- //! on the harmonifing process. When 1, harmonic frequencies
- //! are used, when 0, breakpoint frequencies are unmodified.
- //
- //! \throw InvalidArgument if no Partial in the range [b,e)
- //! has the specified label.
- //
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- Harmonifier( Iter b, Iter e, Partial::label_type refLabel,
- const Envelope & env, double threshold_dB = 0 );
-#else
- inline
- Harmonifier( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel, const Envelope & env,
- double threshold_dB = 0 );
-#endif
-
- //! Destructor.
- ~Harmonifier( void );
-
- // use compiler-generated copy and assign.
-
-// -- operation --
-
- //! Apply the reference envelope to a Partial.
- void harmonify( Partial & p ) const;
-
- //! Apply the reference envelope to all Partials in a range.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template
- void harmonify( Iter b, Iter e );
-#else
- inline
- void harmonify( PartialList::iterator b, PartialList::iterator e );
-#endif
-
-// -- static members --
-
- //! Static member that constructs an instance and applies
- //! it to a sequence of Partials.
- //! Construct a Harmonifier using as reference the Partial in
- //! the specified range labeled refLabel, then apply
- //! the instance to all Partials in the range.
- //!
- //! \param b is the beginning of the range of Partials to harmonify
- //! \param e is (one-past) the end of the range of Partials to harmonify
- //! \param refLabel is the label of the Partial in [b,e) to
- //! use as reference Partial. The reference Partial is the first
- //! Partial in the range [b,e) having the specified label.
- //! \param threshold_dB is the amplitude below which breakpoint
- //! frequencies are harmonified (0 by default, to apply
- //! only to quiet Partials, specify a threshold, like -90).
- //!
- //! \throw InvalidArgument if no Partial in the range [b,e)
- //! has the specified label.
- //! \throw InvalidArgument if refLabel is non-positive.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
- //! must be PartialList::iterators, otherwise they can be any type
- //! of iterators over a sequence of Partials.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Iter >
- static
- void harmonify( Iter b, Iter e,
- Partial::label_type refLabel,
- double threshold_dB = 0 );
-#else
- static inline
- void harmonify( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel,
- double threshold_dB = 0 );
-#endif
-
- //! Static member that constructs an instance and applies
- //! it to a sequence of Partials.
- //! Construct a Harmonifier using as reference the Partial in
- //! the specified range labeled refLabel, then apply
- //! the instance to all Partials in the range.
- //!
- //! \param b is the beginning of the range of Partials to harmonify
- //! \param e is (one-past) the end of the range of Partials to harmonify
- //! \param refLabel is the label of the Partial in [b,e) to
- //! use as reference Partial. The reference Partial is the first
- //! Partial in the range [b,e) having the specified label.
- //! \param env is a weighting envelope to apply to the harmonification
- //! process: when env is 1, use harmonic frequencies, when env
- //! is 0, breakpoint frequencies are unmodified.
- //! \param threshold_dB is the amplitude below which breakpoint
- //! frequencies are harmonified (0 by default, to apply
- //! only to quiet Partials, specify a threshold, like -90).
- //!
- //! \throw InvalidArgument if no Partial in the range [b,e)
- //! has the specified label.
- //! \throw InvalidArgument if refLabel is non-positive.
- //!
- //! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
- //! must be PartialList::iterators, otherwise they can be any type
- //! of iterators over a sequence of Partials.
-#if ! defined(NO_TEMPLATE_MEMBERS)
- template< typename Iter >
- static
- void harmonify( Iter b, Iter e,
- Partial::label_type refLabel,
- const Envelope & env, double threshold_dB = 0 );
-#else
- static inline
- void harmonify( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel,
- const Envelope & env, double threshold_dB = 0 );
-#endif
-
-private:
-
-// -- helpers --
-
- //! Return the default weighing envelope (always 1).
- //! Used in template constructors.
- static Envelope * createDefaultEnvelope( void );
-
-};
-
-// ---------------------------------------------------------------------------
-// constructor
-// ---------------------------------------------------------------------------
-//! Construct a new Harmonifier that applies the specified
-//! reference Partial to fix the frequencies of Breakpoints
-//! whose amplitude is below threshold_dB (0 by default,
-//! to apply only to quiet Partials, specify a threshold,
-//! like -90). The reference Partial is the first Partial
-//! in the range [b,e) having the specified label.
-//! \throw InvalidArgument if no Partial in the range [b,e)
-//! has the specified label.
-//! \throw InvalidArgument if refLabel is non-positive.
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template
-Harmonifier::Harmonifier( Iter b, Iter e, Partial::label_type refLabel,
- double threshold_dB ) :
-#else
-inline
-Harmonifier::Harmonifier( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel, double threshold_dB ) :
-#endif
- _freqFixThresholdDb( threshold_dB ),
- _weight( createDefaultEnvelope() )
-{
- if ( 1 > refLabel )
- {
- Throw( InvalidArgument, "The reference label must be positive." );
- }
-
- b = std::find_if( b, e, PartialUtils::isLabelEqual( refLabel ) );
- if ( b == e )
- {
- Throw( InvalidArgument, "no Partial has the specified reference label" );
- }
-
- if ( 0 == b->numBreakpoints() )
- {
- Throw( InvalidArgument,
- "Cannot use an empty reference Partial in Harmonizer" );
- }
- _refPartial = *b;
-}
-
-// ---------------------------------------------------------------------------
-// constructor
-// ---------------------------------------------------------------------------
-//! Construct a new Harmonifier that applies the specified
-//! reference Partial to fix the frequencies of Breakpoints
-//! whose amplitude is below threshold_dB (0 by default,
-//! to apply only to quiet Partials, specify a threshold,
-//! like -90). The reference Partial is the first Partial
-//! in the range [b,e) having the specified label.
-//!
-//! The Envelope is a time-varying weighting
-//! on the harmonifing process. When 1, harmonic frequencies
-//! are used, when 0, breakpoint frequencies are unmodified.
-//!
-//! \throw InvalidArgument if no Partial in the range [b,e)
-//! has the specified label.
-//! \throw InvalidArgument if refLabel is non-positive.
-//
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template
-Harmonifier::Harmonifier( Iter b, Iter e, Partial::label_type refLabel,
- const Envelope & env, double threshold_dB ) :
-#else
-inline
-Harmonifier::Harmonifier( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel, const Envelope & env,
- double threshold_dB ) :
-#endif
- _freqFixThresholdDb( threshold_dB ),
- _weight( env.clone() )
-{
- if ( 1 > refLabel )
- {
- Throw( InvalidArgument, "The reference label must be positive." );
- }
-
- b = std::find_if( b, e, PartialUtils::isLabelEqual( refLabel ) );
- if ( b == e )
- {
- Throw( InvalidArgument, "no Partial has the specified reference label" );
- }
-
- if ( 0 == b->numBreakpoints() )
- {
- Throw( InvalidArgument,
- "Cannot use an empty reference Partial in Harmonizer" );
- }
- _refPartial = *b;
-}
-
-// ---------------------------------------------------------------------------
-// harmonify
-// ---------------------------------------------------------------------------
-//! Apply the reference envelope to all Partials in a range.
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template
-void Harmonifier::harmonify( Iter b, Iter e )
-#else
-inline
-void Harmonifier::harmonify( PartialList::iterator b, PartialList::iterator e )
-#endif
-{
- while ( b != e )
- {
- harmonify( *b );
- ++b;
- }
-}
-
-// ---------------------------------------------------------------------------
-// harmonify (STATIC)
-// ---------------------------------------------------------------------------
-//! Static member that constructs an instance and applies
-//! it to a sequence of Partials.
-//! Construct a Harmonifier using as reference the Partial in
-//! the specified range labeled refLabel, then apply
-//! the instance to all Partials in the range.
-//!
-//! \param b is the beginning of the range of Partials to harmonify
-//! \param e is (one-past) the end of the range of Partials to harmonify
-//! \param refLabel is the label of the Partial in [b,e) to
-//! use as reference Partial. The reference Partial is the first
-//! Partial in the range [b,e) having the specified label.
-//! \param threshold_dB is the amplitude below which breakpoint
-//! frequencies are harmonified (0 by default, to apply
-//! only to quiet Partials, specify a threshold, like -90).
-//!
-//! \throw InvalidArgument if no Partial in the range [b,e)
-//! has the specified label.
-//! \throw InvalidArgument if refLabel is non-positive.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
-//! must be PartialList::iterators, otherwise they can be any type
-//! of iterators over a sequence of Partials.
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Iter >
-void Harmonifier::harmonify( Iter b, Iter e,
- Partial::label_type refLabel,
- double threshold_dB )
-#else
-inline
-void Harmonifier::harmonify( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel,
- double threshold_dB )
-#endif
-{
- Harmonifier instance( b, e, refLabel, threshold_dB );
- instance.harmonify( b, e );
-}
-
-// ---------------------------------------------------------------------------
-// harmonify (STATIC)
-// ---------------------------------------------------------------------------
-//! Static member that constructs an instance and applies
-//! it to a sequence of Partials.
-//! Construct a Harmonifier using as reference the Partial in
-//! the specified range labeled refLabel, then apply
-//! the instance to all Partials in the range.
-//!
-//! \param b is the beginning of the range of Partials to harmonify
-//! \param e is (one-past) the end of the range of Partials to harmonify
-//! \param refLabel is the label of the Partial in [b,e) to
-//! use as reference Partial. The reference Partial is the first
-//! Partial in the range [b,e) having the specified label.
-//! \param env is a weighting envelope to apply to the harmonification
-//! process: when env is 1, use harmonic frequencies, when env
-//! is 0, breakpoint frequencies are unmodified.
-//! \param threshold_dB is the amplitude below which breakpoint
-//! frequencies are harmonified (0 by default, to apply
-//! only to quiet Partials, specify a threshold, like -90).
-//!
-//! \throw InvalidArgument if no Partial in the range [b,e)
-//! has the specified label.
-//! \throw InvalidArgument if refLabel is non-positive.
-//!
-//! If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end
-//! must be PartialList::iterators, otherwise they can be any type
-//! of iterators over a sequence of Partials.
-#if ! defined(NO_TEMPLATE_MEMBERS)
-template< typename Iter >
-void Harmonifier::harmonify( Iter b, Iter e,
- Partial::label_type refLabel,
- const Envelope & env, double threshold_dB )
-#else
-inline
-void Harmonifier::harmonify( PartialList::iterator b, PartialList::iterator e,
- Partial::label_type refLabel,
- const Envelope & env, double threshold_dB )
-#endif
-{
- Harmonifier instance( b, e, refLabel, env, threshold_dB );
- instance.harmonify( b, e );
-}
-
-} // namespace Loris
-
-#endif /* ndef INCLUDE_HARMONIFIER_H */
diff --git a/loris_library/Source/include/loris/ImportLemur.h b/loris_library/Source/include/loris/ImportLemur.h
deleted file mode 100644
index e887e64..0000000
--- a/loris_library/Source/include/loris/ImportLemur.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef INCLUDE_IMPORTLEMUR_H
-#define INCLUDE_IMPORTLEMUR_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * ImportLemur.h
- *
- * Definition of class Loris::ImportLemur for importing Partials stored
- * in Lemur 5 alpha files.
- *
- * Kelly Fitz, 10 Sept 1999
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "PartialList.h"
-#include "LorisExceptions.h"
-#include
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class ImportLemur
-//
-class ImportLemur
-{
-// -- instance variables --
- PartialList _partials; // collect Partials here
-
-// -- public interface --
-public:
-// construction:
-// (compiler can generate destructor)
- ImportLemur( const std::string & fname, double bweCutoff = 1000 );
-
-// PartialList access:
- PartialList & partials( void ) { return _partials; }
- const PartialList & partials( void ) const { return _partials; }
-
-// -- unimplemented --
-private:
- ImportLemur( const ImportLemur & other );
- ImportLemur & operator = ( const ImportLemur & rhs );
-
-}; // end of class ImportLemur
-
-// ---------------------------------------------------------------------------
-// class ImportException
-//
-// Class of exceptions thrown when there is an error importing
-// Partials.
-//
-class ImportException : public Exception
-{
-public:
- ImportException( const std::string & str, const std::string & where = "" ) :
- Exception( std::string("Import Error -- ").append( str ), where ) {}
-};
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_IMPORTLEMUR_H */
diff --git a/loris_library/Source/include/loris/KaiserWindow.h b/loris_library/Source/include/loris/KaiserWindow.h
deleted file mode 100644
index d0ba494..0000000
--- a/loris_library/Source/include/loris/KaiserWindow.h
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef INCLUDE_KAISERWINDOW_H
-#define INCLUDE_KAISERWINDOW_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * KaiserWindow.h
- *
- * Definition of class Loris::KaiserWindow.
- *
- * Kelly Fitz, 14 Dec 1999
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include
-
-// begin namespace
-namespace Loris {
-
-// ---------------------------------------------------------------------------
-// class KaiserWindow
-//
-//! Computes samples of a Kaiser window
-//! function (see Kaiser and Schafer, 1980) for windowing FFT data.
-//
-class KaiserWindow
-{
-// -- public interface --
-public:
-
- // -- window building --
-
- //! Build a new Kaiser analysis window having the specified shaping
- //! parameter. See Oppenheim and Schafer: "Digital Signal Processing"
- //! (1975), p. 452 for further explanation of the Kaiser window. Also,
- //! see Kaiser and Schafer, 1980.
- //!
- //! \param win is the vector that will store the window
- //! samples. The number of samples computed will be
- //! equal to the length of this vector. Any previous
- //! contents will be overwritten.
- //! \param shape is the Kaiser shaping parameter, controlling
- //! the sidelobe rejection level.
- static void buildWindow( std::vector< double > & win, double shape );
-
- //! Build a new time-derivative Kaiser analysis window having the
- //! specified shaping parameter, for computing frequency reassignment.
- //! The closed form for the time derivative can be obtained from the
- //! property of modified Bessel functions that the derivative of the
- //! zeroeth order function is equal to the first order function.
- //!
- //! \param win is the vector that will store the window
- //! samples. The number of samples computed will be
- //! equal to the length of this vector. Any previous
- //! contents will be overwritten.
- //! \param shape is the Kaiser shaping parameter, controlling
- //! the sidelobe rejection level.
- static void buildTimeDerivativeWindow( std::vector< double > & win, double shape );
-
-
- // -- window parameter estimation --
-
- //! Compute a shaping parameter that will achieve the specified
- //! level of sidelobe rejection.
- //!
- //! \param atten is the desired sidelobe attenuation in
- //! positive decibels (e.g. 65 dB)
- //! \returns the Kaiser shaping paramater
- static double computeShape( double atten );
-
- //! Compute the necessary length in samples of a Kaiser window
- //! having the specified shaping parameter that has the
- //! desired main lobe width.
- //!
- //! \param width is the desired main lobe width expressed
- //! as a fraction of the sample rate.
- //! \param alpha is the Kaiser shaping parameter (the
- //! main lobe width is influenced primarily by the
- //! window length,but also by the shape).
- //! \returns the window length in samples
- static unsigned long computeLength( double width, double alpha );
-
-// construction is not allowed:
-private:
- KaiserWindow( void );
-
-}; // end of class KaiserWindow
-
-} // end of namespace Loris
-
-#endif /* ndef INCLUDE_KAISERWINDOW_H */
diff --git a/loris_library/Source/include/loris/LinearEnvelope.h b/loris_library/Source/include/loris/LinearEnvelope.h
deleted file mode 100644
index be06f69..0000000
--- a/loris_library/Source/include/loris/LinearEnvelope.h
+++ /dev/null
@@ -1,303 +0,0 @@
-#ifndef INCLUDE_LINEARENVELOPE_H
-#define INCLUDE_LINEARENVELOPE_H
-/*
- * This is the Loris C++ Class Library, implementing analysis,
- * manipulation, and synthesis of digitized sounds using the Reassigned
- * Bandwidth-Enhanced Additive Sound Model.
- *
- * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * LinearEnvelope.h
- *
- * Definition of class LinearEnvelope.
- *
- * Kelly Fitz, 23 April 2005
- * loris@cerlsoundgroup.org
- *
- * http://www.cerlsoundgroup.org/Loris/
- *
- */
-
-#include "Envelope.h"
-#include