mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-06 03:39:50 +00:00
Added DSP example plugin.
This commit is contained in:
parent
643ca57f58
commit
ac5b03ccc2
@ -36,6 +36,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpg123decoder", "src\contri
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flacdecoder", "src\contrib\flacdecoder\flacdecoder.vcproj", "{465EF178-91C1-4068-BE1D-F9616ECCB6DE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dsp_example_echo", "src\contrib\dsp_example_echo\dsp_example_echo.vcproj", "{2BCB82E5-B163-4812-8C29-17335FF45A2B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@ -86,6 +88,10 @@ Global
|
||||
{465EF178-91C1-4068-BE1D-F9616ECCB6DE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{465EF178-91C1-4068-BE1D-F9616ECCB6DE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{465EF178-91C1-4068-BE1D-F9616ECCB6DE}.Release|Win32.Build.0 = Release|Win32
|
||||
{2BCB82E5-B163-4812-8C29-17335FF45A2B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2BCB82E5-B163-4812-8C29-17335FF45A2B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2BCB82E5-B163-4812-8C29-17335FF45A2B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2BCB82E5-B163-4812-8C29-17335FF45A2B}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -97,5 +103,6 @@ Global
|
||||
{05A68577-4991-44CF-822E-60292A9A4D5A} = {092264AD-38B7-401D-8E67-B56756A141E4}
|
||||
{04118CC2-DE10-4627-A695-2219428C7D59} = {092264AD-38B7-401D-8E67-B56756A141E4}
|
||||
{465EF178-91C1-4068-BE1D-F9616ECCB6DE} = {092264AD-38B7-401D-8E67-B56756A141E4}
|
||||
{2BCB82E5-B163-4812-8C29-17335FF45A2B} = {092264AD-38B7-401D-8E67-B56756A141E4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
102
src/contrib/dsp_example_echo/DSPEcho.cpp
Normal file
102
src/contrib/dsp_example_echo/DSPEcho.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2007, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include "pch.h"
|
||||
#include "DSPEcho.h"
|
||||
|
||||
DSPEcho::DSPEcho()
|
||||
:internalBuffer(NULL)
|
||||
,channels(0)
|
||||
,bufferSampleSize(0)
|
||||
,bufferPosition(0)
|
||||
,sampleRate(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DSPEcho::~DSPEcho(){
|
||||
delete this->internalBuffer;
|
||||
}
|
||||
|
||||
|
||||
void DSPEcho::Destroy(){
|
||||
delete this;
|
||||
}
|
||||
|
||||
void DSPEcho::SetBuffer(const IBuffer *inputBuffer){
|
||||
if(inputBuffer->Channels()!=this->channels || inputBuffer->SampleRate()!=this->sampleRate){
|
||||
|
||||
this->channels = inputBuffer->Channels();
|
||||
this->sampleRate = inputBuffer->SampleRate();
|
||||
this->bufferSampleSize = this->sampleRate; // 1 second
|
||||
|
||||
delete this->internalBuffer;
|
||||
this->internalBuffer = new float[this->channels*this->bufferSampleSize];
|
||||
|
||||
// empty the internal buffer
|
||||
for(long i=0;i<this->channels*this->bufferSampleSize;++i){
|
||||
this->internalBuffer[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DSPEcho::ProcessBuffers(const IBuffer *inputBuffer,IBuffer *outputBuffer){
|
||||
this->SetBuffer(inputBuffer);
|
||||
|
||||
// loop though the buffer and apply echo
|
||||
long bufferLength( this->channels*inputBuffer->Samples() );
|
||||
float *inBuffer = inputBuffer->BufferPointer();
|
||||
float *outBuffer = outputBuffer->BufferPointer();
|
||||
long internalBufferSize(this->channels*this->bufferSampleSize);
|
||||
|
||||
long echo1distance(internalBufferSize-((long)(0.3*(double)this->sampleRate))*this->channels);
|
||||
long echo2distance(internalBufferSize-((long)(0.6*(double)this->sampleRate))*this->channels);
|
||||
|
||||
for(long i(0);i<bufferLength;++i){
|
||||
float inSample(inBuffer[i]);
|
||||
float outSample(inSample);
|
||||
//add a 0.5 of 0.3 seconds away
|
||||
outSample += 0.5f*this->internalBuffer[(this->bufferPosition+echo1distance)%internalBufferSize];
|
||||
//add a 0.2 of 0.6 seconds away
|
||||
outSample += 0.2f*this->internalBuffer[(this->bufferPosition+echo2distance)%internalBufferSize];
|
||||
|
||||
// set the out buffer
|
||||
outBuffer[i] = outSample;
|
||||
// Save the insample to internal buffer
|
||||
this->internalBuffer[this->bufferPosition] = inSample;
|
||||
this->bufferPosition = (this->bufferPosition+1)%internalBufferSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
55
src/contrib/dsp_example_echo/DSPEcho.h
Normal file
55
src/contrib/dsp_example_echo/DSPEcho.h
Normal file
@ -0,0 +1,55 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2007, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <core/audio/IDSP.h>
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
||||
class DSPEcho : public IDSP{
|
||||
public:
|
||||
DSPEcho();
|
||||
~DSPEcho();
|
||||
|
||||
virtual void Destroy();
|
||||
virtual bool ProcessBuffers(const IBuffer *inputBuffer,IBuffer *outputBuffer);
|
||||
private:
|
||||
|
||||
void SetBuffer(const IBuffer *inputBuffer);
|
||||
|
||||
float *internalBuffer;
|
||||
long bufferSampleSize;
|
||||
long bufferPosition;
|
||||
int channels;
|
||||
long sampleRate;
|
||||
};
|
66
src/contrib/dsp_example_echo/dsp_echo_plugin.cpp
Normal file
66
src/contrib/dsp_example_echo/dsp_echo_plugin.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2008, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include <core/IPlugin.h>
|
||||
#include "DSPEcho.h"
|
||||
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class DSPEchoPlugin : public musik::core::IPlugin
|
||||
{
|
||||
void Destroy() { delete this; };
|
||||
|
||||
const utfchar* Name() { return TEXT("DSP echo example"); };
|
||||
const utfchar* Version() { return TEXT("1"); };
|
||||
const utfchar* Author() { return TEXT("Daniel Önnerby"); };
|
||||
};
|
||||
|
||||
extern "C" __declspec(dllexport) musik::core::IPlugin* GetPlugin()
|
||||
{
|
||||
return new DSPEchoPlugin();
|
||||
}
|
||||
|
||||
|
||||
extern "C" __declspec(dllexport) musik::core::audio::IDSP* GetDSP()
|
||||
{
|
||||
return new DSPEcho();
|
||||
}
|
209
src/contrib/dsp_example_echo/dsp_example_echo.vcproj
Normal file
209
src/contrib/dsp_example_echo/dsp_example_echo.vcproj
Normal file
@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="dsp_example_echo"
|
||||
ProjectGUID="{2BCB82E5-B163-4812-8C29-17335FF45A2B}"
|
||||
RootNamespace="dsp_example_echo"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)/plugins"
|
||||
IntermediateDirectory="./obj/$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../..;../../3rdparty/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib "
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../../3rdparty/lib"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)/plugins"
|
||||
IntermediateDirectory="./obj/$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../..;../../3rdparty/include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib "
|
||||
AdditionalLibraryDirectories="../../3rdparty/lib"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
LinkTimeCodeGeneration="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="plugin"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\dsp_echo_plugin.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DSPEcho.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DSPEcho.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pch.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pch.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
37
src/contrib/dsp_example_echo/pch.cpp
Normal file
37
src/contrib/dsp_example_echo/pch.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2008, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pch.h"
|
42
src/contrib/dsp_example_echo/pch.h
Normal file
42
src/contrib/dsp_example_echo/pch.h
Normal file
@ -0,0 +1,42 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2008, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Precompiled headers
|
||||
#pragma once
|
||||
|
||||
#include <core/config.h>
|
||||
|
||||
#include "vld/vld.h"
|
@ -53,7 +53,7 @@ BufferPtr Buffer::Create(){
|
||||
return BufferPtr(new Buffer());
|
||||
}
|
||||
|
||||
long Buffer::SampleRate(){
|
||||
long Buffer::SampleRate() const{
|
||||
return this->sampleRate;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ void Buffer::SetSampleRate(long sampleRate){
|
||||
this->sampleRate = sampleRate;
|
||||
}
|
||||
|
||||
int Buffer::Channels(){
|
||||
int Buffer::Channels() const{
|
||||
return this->channels;
|
||||
}
|
||||
|
||||
@ -70,11 +70,11 @@ void Buffer::SetChannels(int channels){
|
||||
this->ResizeBuffer();
|
||||
}
|
||||
|
||||
float* Buffer::BufferPointer(){
|
||||
float* Buffer::BufferPointer() const{
|
||||
return this->buffer;
|
||||
}
|
||||
|
||||
long Buffer::Samples(){
|
||||
long Buffer::Samples() const{
|
||||
return this->sampleSize;
|
||||
}
|
||||
|
||||
@ -83,6 +83,13 @@ void Buffer::SetSamples(long samples){
|
||||
this->ResizeBuffer();
|
||||
}
|
||||
|
||||
void Buffer::CopyFormat(BufferPtr fromBuffer){
|
||||
this->sampleSize = fromBuffer->Samples();
|
||||
this->channels = fromBuffer->Channels();
|
||||
this->sampleRate = fromBuffer->SampleRate();
|
||||
this->ResizeBuffer();
|
||||
}
|
||||
|
||||
void Buffer::ResizeBuffer(){
|
||||
long requiredBufferSize( this->sampleSize * this->channels );
|
||||
if(requiredBufferSize>this->internalBufferSize){
|
||||
@ -98,11 +105,11 @@ void Buffer::ResizeBuffer(){
|
||||
}
|
||||
}
|
||||
|
||||
long Buffer::Bytes(){
|
||||
long Buffer::Bytes() const{
|
||||
return this->internalBufferSize*sizeof(float);
|
||||
}
|
||||
|
||||
double Buffer::Position(){
|
||||
double Buffer::Position() const{
|
||||
return this->position;
|
||||
}
|
||||
|
||||
|
@ -54,17 +54,18 @@ class Buffer : public IBuffer {
|
||||
public:
|
||||
~Buffer(void);
|
||||
|
||||
virtual long SampleRate();
|
||||
virtual long SampleRate() const;
|
||||
virtual void SetSampleRate(long sampleRate);
|
||||
virtual int Channels();
|
||||
virtual int Channels() const;
|
||||
virtual void SetChannels(int channels);
|
||||
virtual float* BufferPointer();
|
||||
virtual long Samples();
|
||||
virtual float* BufferPointer() const;
|
||||
virtual long Samples() const;
|
||||
virtual void SetSamples(long samples);
|
||||
virtual long Bytes();
|
||||
virtual double Position();
|
||||
virtual long Bytes() const;
|
||||
virtual double Position() const;
|
||||
|
||||
bool Append(BufferPtr appendBuffer);
|
||||
void CopyFormat(BufferPtr fromBuffer);
|
||||
|
||||
private:
|
||||
// Methods
|
||||
|
@ -40,14 +40,14 @@ namespace musik { namespace core { namespace audio {
|
||||
|
||||
class IBuffer {
|
||||
public:
|
||||
virtual long SampleRate() = 0;
|
||||
virtual long SampleRate() const = 0;
|
||||
virtual void SetSampleRate(long sampleRate) = 0;
|
||||
virtual int Channels() = 0;
|
||||
virtual int Channels() const = 0;
|
||||
virtual void SetChannels(int channels) = 0;
|
||||
virtual float* BufferPointer() = 0;
|
||||
virtual long Samples() = 0;
|
||||
virtual float* BufferPointer() const = 0;
|
||||
virtual long Samples() const = 0;
|
||||
virtual void SetSamples(long samples) = 0;
|
||||
virtual long Bytes() = 0;
|
||||
virtual long Bytes() const = 0;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -42,7 +42,7 @@ namespace musik { namespace core { namespace audio {
|
||||
class IDSP {
|
||||
public:
|
||||
virtual void Destroy() = 0;
|
||||
virtual bool ProcessBuffers(const IBuffer *inputBuffer,IBuffer *outputBuffer);
|
||||
virtual bool ProcessBuffers(const IBuffer *inputBuffer,IBuffer *outputBuffer) = 0;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -174,6 +174,9 @@ BufferPtr Stream::GetNextBuffer(){
|
||||
|
||||
// Now lets loop through all DSP plugins
|
||||
for(Dsps::iterator dsp=this->dsps.begin();dsp!=this->dsps.end();++dsp){
|
||||
oldBuffer->CopyFormat(currentBuffer);
|
||||
oldBuffer->position = currentBuffer->position;
|
||||
|
||||
if( (*dsp)->ProcessBuffers(currentBuffer.get(),oldBuffer.get()) ){
|
||||
// Success in processing DSP, swap the buffers
|
||||
currentBuffer.swap(oldBuffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user