chenlh
2026-03-26 36e42207da4c088b5bfd96f2cfc8944f890440d7
新增DelayMono模块
已添加12个文件
9418 ■■■■■ 文件已修改
cbb_DelayMono/VSPrj/Delay_Mono.sln 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/VSPrj/Delay_Mono.vcxproj 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/VSPrj/Delay_Mono.vcxproj.filters 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/VSPrj/Delay_Mono.vcxproj.user 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/VSPrj/ain.wav 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/VSPrj/aout.wav 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/VSPrj/test.cpp 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/delay_mono.cpp 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/delay_mono.h 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/delay_mono_wrapper.cpp 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/delay_mono_wrapper.h 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/dr_wav.h 9060 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cbb_DelayMono/VSPrj/Delay_Mono.sln
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35828.75 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Delay_Mono", "Delay_Mono.vcxproj", "{5BB388E2-2080-4163-9D07-8A03E172419A}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|x64 = Debug|x64
        Debug|x86 = Debug|x86
        Release|x64 = Release|x64
        Release|x86 = Release|x86
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Debug|x64.ActiveCfg = Debug|x64
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Debug|x64.Build.0 = Debug|x64
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Debug|x86.ActiveCfg = Debug|Win32
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Debug|x86.Build.0 = Debug|Win32
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Release|x64.ActiveCfg = Release|x64
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Release|x64.Build.0 = Release|x64
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Release|x86.ActiveCfg = Release|Win32
        {5BB388E2-2080-4163-9D07-8A03E172419A}.Release|x86.Build.0 = Release|Win32
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {0E6C52A2-6834-455A-B51C-FA54691B3464}
    EndGlobalSection
EndGlobal
cbb_DelayMono/VSPrj/Delay_Mono.vcxproj
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\delay_mono.cpp" />
    <ClCompile Include="..\delay_mono_wrapper.cpp" />
    <ClCompile Include="test.cpp" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\delay_mono.h" />
    <ClInclude Include="..\delay_mono_wrapper.h" />
    <ClInclude Include="..\dr_wav.h" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <VCProjectVersion>17.0</VCProjectVersion>
    <Keyword>Win32Proj</Keyword>
    <ProjectGuid>{5bb388e2-2080-4163-9d07-8a03e172419a}</ProjectGuid>
    <RootNamespace>DelayMono</RootNamespace>
    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="Shared">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);DR_WAV_IMPLEMENTATION</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
      <AdditionalIncludeDirectories>E:\Algorithm\Effect\Delay\Delay_Mono;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
cbb_DelayMono/VSPrj/Delay_Mono.vcxproj.filters
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Filter Include="源文件">
      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
      <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
    </Filter>
    <Filter Include="头文件">
      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
      <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
    </Filter>
    <Filter Include="资源文件">
      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
    </Filter>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\delay_mono.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="..\delay_mono_wrapper.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="test.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\delay_mono.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="..\delay_mono_wrapper.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="..\dr_wav.h">
      <Filter>头文件</Filter>
    </ClInclude>
  </ItemGroup>
</Project>
cbb_DelayMono/VSPrj/Delay_Mono.vcxproj.user
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup />
</Project>
cbb_DelayMono/VSPrj/ain.wav
Binary files differ
cbb_DelayMono/VSPrj/aout.wav
Binary files differ
cbb_DelayMono/VSPrj/test.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,88 @@
#include <iostream>
#include <vector>
#include "delay_mono.h"
#include "delay_mono_wrapper.h"
#include "dr_wav.h"
int ch = 1;
int n = 1024;
float sample_rate = 48000;
float wetdry = 90;
float delay_time = 900;
float feedback = 68;
float high_ratio = 0.7;
float hpf = 150;
float lpf = 13000;
bool processWavFile(const char* inputPath, const char* outputPath, void *handle, int sampleRate = 48000, int blockSize = 64)
{
    int i;
    Delay_mono *h = (Delay_mono *)handle;
    // ----- è¯»å–输入 WAV -----
    drwav wavIn;
    if (!drwav_init_file(&wavIn, inputPath, NULL)) {
        std::cerr << "Err:Can't open input file " << inputPath << std::endl;
        return false;
    }
    if (wavIn.sampleRate != sampleRate) {
        std::cerr << " Warning:sampleRate is not correct " << std::endl;
    }
    int channels = wavIn.channels;
    drwav_uint64 totalLen = wavIn.totalPCMFrameCount;
    std::cout << "InputFile:" << inputPath << "\n"
        << "SampleRate:" << sampleRate << " Hz\n"
        << "Channels:" << channels << "\n"
        << "Frames:" << totalLen << std::endl;
    std::vector<float> inPcm(totalLen * channels);
    drwav_read_pcm_frames_f32(&wavIn, totalLen, inPcm.data());
    drwav_uninit(&wavIn);
    std::vector<float> outPcm(totalLen * channels, 0.0f);
    int frames = totalLen / n - 1;
    for (i = 0; i < frames; i++) {
        delay_mono_wrapper_process(h, wavIn.sampleRate, wetdry, delay_time, feedback, high_ratio, hpf, lpf, inPcm.data() + i * n, outPcm.data() + i * n);
    }
    // ----- å†™å…¥è¾“出 WAV(浮点格式)-----
    drwav_data_format format;
    format.container = drwav_container_riff;
    format.format = DR_WAVE_FORMAT_IEEE_FLOAT;
    format.channels = channels;
    format.sampleRate = sampleRate;
    format.bitsPerSample = 32;
    drwav wavOut;
    if (!drwav_init_file_write(&wavOut, outputPath, &format, NULL)) {
        std::cerr << "Err:can't output wav file: " << outputPath << std::endl;
        return false;
    }
    drwav_write_pcm_frames(&wavOut, totalLen, outPcm.data());
    drwav_uninit(&wavOut);
    std::cout << "\n Output wav file:" << outputPath << std::endl;
    return 0;
}
int main()
{
    void *work;
    delay_mono_wrapper_init(&work, ch, n, sample_rate, wetdry, delay_time, feedback, high_ratio, hpf, lpf);
    processWavFile("ain.wav", "aout.wav", work, sample_rate, n);
    delay_mono_wrapper_delete(work);
}
cbb_DelayMono/delay_mono.cpp
Binary files differ
cbb_DelayMono/delay_mono.h
Binary files differ
cbb_DelayMono/delay_mono_wrapper.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
#include "delay_mono.h"
#include "delay_mono_wrapper.h"
static int ch,n,L;
static float *y[32];
void delay_mono_wrapper_init(void **p, int channels, int frame_size, double sample_rate, double wet_dry, double set_delay, double feed_back, double high_ratio, double hpf, double lpf)
{
    Delay_mono_param param = {sample_rate, wet_dry, set_delay, feed_back, high_ratio, hpf, lpf};
    *(Delay_mono **)p = delay_mono_new(channels, frame_size, &param);
    ch = channels;
    n = frame_size;
}
void delay_mono_wrapper_process(void *p, double sample_rate, double wet_dry, double set_delay, double feed_back, double high_ratio, double hpf, double lpf, float *src, float *dst)
{
    int i;
    Delay_mono_param param = {sample_rate, wet_dry, set_delay, feed_back, high_ratio, hpf, lpf};
    L = ch * n;
    for(i = 0; i < L; i ++)
        dst[i] = src[i];
    for(i = 0; i < ch; i ++)
        y[i] = dst + i * n;
    delay_mono_process((Delay_mono *)p, y, &param);
}
void delay_mono_wrapper_delete(void *p)
{
    delay_mono_delete((Delay_mono *)p);
}
cbb_DelayMono/delay_mono_wrapper.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
#ifndef DELAY_MONO_WRAPPER_H
#define DELAY_MONO_WRAPPER_H
void delay_mono_wrapper_init(void **p, int channels, int frame_size, double sample_rate, double wet_dry, double set_delay, double feed_back, double high_ratio, double hpf, double lpf);
void delay_mono_wrapper_process(void *p, double sample_rate, double wet_dry, double set_delay, double feed_back, double high_ratio, double hpf, double lpf, float *src, float *dst);
void delay_mono_wrapper_delete(void *p);
#endif
cbb_DelayMono/dr_wav.h
¶Ô±ÈÐÂÎļþ
ÎļþÌ«´ó