-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
451 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include "WAVFile.h" | ||
|
||
CWAVFile::CWAVFile() | ||
{ | ||
m_pData = NULL; | ||
} | ||
|
||
CWAVFile::~CWAVFile() | ||
{ | ||
if (m_pData) | ||
{ | ||
delete[]m_pData; | ||
m_pData = NULL; | ||
} | ||
} | ||
|
||
bool CWAVFile::LoadFile(const char* strFile) | ||
{ | ||
if (!strFile) | ||
{ | ||
printf("strFile is null. \n"); | ||
return false; | ||
} | ||
FILE* pFile = fopen(strFile, "rb"); | ||
if (!pFile) | ||
{ | ||
printf("fopen is failed. \n"); | ||
return false; | ||
} | ||
fseek(pFile, 0, SEEK_END); | ||
m_iSize = ftell(pFile); | ||
byte_ptr pData = new byte[m_iSize]; | ||
fseek(pFile, 0, SEEK_SET); | ||
if (m_iSize != fread(pData, sizeof(byte), m_iSize, pFile)) | ||
{ | ||
printf("read file is failed. \n"); | ||
return false; | ||
} | ||
fclose(pFile); | ||
|
||
bool bResult = ReadData(pData, m_iSize); | ||
delete[]pData; | ||
pData = NULL; | ||
return bResult; | ||
} | ||
|
||
bool CWAVFile::SaveFile(const char* strFile, RECT rt) | ||
{ | ||
return true; | ||
} | ||
|
||
void CWAVFile::Display() | ||
{ | ||
printf("************************ RIFF HEADER ************************\n"); | ||
printf("\t RiffID \t : %s \n", BytesToStr(m_RiffHeader.szRiffID, 4).c_str()); | ||
printf("\t RiffSize \t : %d \n", m_RiffHeader.dwRiffSize); | ||
printf("\t RiffFormat \t : %s \n", BytesToStr(m_RiffHeader.szRiffFormat, 4).c_str()); | ||
|
||
printf("************************ FMT BLOCK ************************\n"); | ||
printf("\t szFmtID \t : %s \n", BytesToStr(m_FmtBlock.szFmtID, 4).c_str()); | ||
printf("\t dwFmtSize \t : %d \n", m_FmtBlock.dwFmtSize); | ||
printf("\t wFormatTag \t : %d \n", m_FmtBlock.wavFormat.wFormatTag); | ||
printf("\t wChannels \t : %d \n", m_FmtBlock.wavFormat.wChannels); | ||
printf("\t dwSamplesPerSec \t : %d \n", m_FmtBlock.wavFormat.dwSamplesPerSec); | ||
printf("\t dwAvgBytesPerSec \t : %d \n", m_FmtBlock.wavFormat.dwAvgBytesPerSec); | ||
printf("\t wBlockAlign \t : %d \n", m_FmtBlock.wavFormat.wBlockAlign); | ||
printf("\t wBitsPerSample \t : %d \n", m_FmtBlock.wavFormat.wBitsPerSample); | ||
|
||
printf("************************ DATA HEADER ************************\n"); | ||
printf("\t szDataID \t : %s \n", BytesToStr(m_DataHeader.szDataID, 4).c_str()); | ||
printf("\t dwDataSize \t : %d \n", m_DataHeader.dwDataSize); | ||
|
||
printf("************************ WAVE DATA ************************\n"); | ||
int iSize = min(100, m_DataHeader.dwDataSize); | ||
for (int i = 0; i < iSize; i++) | ||
{ | ||
printf(" %02X ", m_pData[i]); | ||
} | ||
printf(" ..."); | ||
} | ||
|
||
bool CWAVFile::ReadData(byte_ptr pData, int iSize) | ||
{ | ||
// RIFF_HEADER; | ||
int iRiffHeaderSize = sizeof(m_RiffHeader); | ||
memcpy(&m_RiffHeader, pData, iRiffHeaderSize); | ||
pData += iRiffHeaderSize; | ||
// FMT_BLOCK; | ||
int iFmtBlockSize = sizeof(m_FmtBlock); | ||
memcpy(&m_FmtBlock, pData, iFmtBlockSize); | ||
pData += iFmtBlockSize; | ||
// DATA_HEADER; | ||
int iDataHeaderSize = sizeof(m_DataHeader); | ||
memcpy(&m_DataHeader, pData, iDataHeaderSize); | ||
pData += iDataHeaderSize; | ||
|
||
if (m_pData) | ||
{ | ||
delete []m_pData; | ||
} | ||
int iDataSize = m_DataHeader.dwDataSize; | ||
m_pData = new byte[iDataSize]; | ||
memcpy(m_pData, pData, iDataSize); | ||
|
||
return true; | ||
} | ||
|
||
bool CWAVFile::WriteData(byte_ptr pData, int &iSize, double dStart, double dEnd) | ||
{ | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
#include "bytes.h" | ||
#include <windows.h> | ||
|
||
struct RIFF_HEADER | ||
{ | ||
byte szRiffID[4]; // 'R','I','F','F' | ||
DWORD dwRiffSize; | ||
byte szRiffFormat[4]; // 'W','A','V','E' | ||
}; | ||
|
||
struct WAVE_FORMAT | ||
{ | ||
WORD wFormatTag; | ||
WORD wChannels; | ||
DWORD dwSamplesPerSec; | ||
DWORD dwAvgBytesPerSec; | ||
WORD wBlockAlign; | ||
WORD wBitsPerSample; | ||
}; | ||
|
||
struct FMT_BLOCK | ||
{ | ||
byte szFmtID[4]; // 'f','m','t',' ' | ||
DWORD dwFmtSize; | ||
WAVE_FORMAT wavFormat; | ||
}; | ||
|
||
struct DATA_HEADER | ||
{ | ||
byte szDataID[4]; // 'd','a','t','a ' | ||
DWORD dwDataSize; | ||
}; | ||
|
||
class CWAVFile | ||
{ | ||
public: | ||
CWAVFile(); | ||
~CWAVFile(); | ||
|
||
public: | ||
// 加载文件,读取数据; | ||
bool LoadFile(const char* strFile); | ||
|
||
bool SaveFile(const char* strFile, RECT rt = { 0 }); | ||
|
||
// 显示; | ||
void Display(); | ||
|
||
protected: | ||
// 解析数据; | ||
bool ReadData(byte_ptr pData, int iSize); | ||
// 打包数据; | ||
bool WriteData(byte_ptr pData, int &iSize, double dStart, double dEnd); | ||
|
||
public: | ||
RIFF_HEADER m_RiffHeader; | ||
FMT_BLOCK m_FmtBlock; | ||
DATA_HEADER m_DataHeader; | ||
byte* m_pData; | ||
int m_iSize; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.21005.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WAV_Parse", "WAV_Parse.vcxproj", "{8B8D8E52-408E-4596-ADC8-B586ECE18DA1}" | ||
EndProject | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BMP_Parse", "..\BMP_Parse\BMP_Parse.vcxproj", "{40DF3618-E7AE-4272-A075-B2CB810EFFCC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8B8D8E52-408E-4596-ADC8-B586ECE18DA1}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{8B8D8E52-408E-4596-ADC8-B586ECE18DA1}.Debug|Win32.Build.0 = Debug|Win32 | ||
{8B8D8E52-408E-4596-ADC8-B586ECE18DA1}.Release|Win32.ActiveCfg = Release|Win32 | ||
{8B8D8E52-408E-4596-ADC8-B586ECE18DA1}.Release|Win32.Build.0 = Release|Win32 | ||
{40DF3618-E7AE-4272-A075-B2CB810EFFCC}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{40DF3618-E7AE-4272-A075-B2CB810EFFCC}.Debug|Win32.Build.0 = Debug|Win32 | ||
{40DF3618-E7AE-4272-A075-B2CB810EFFCC}.Release|Win32.ActiveCfg = Release|Win32 | ||
{40DF3618-E7AE-4272-A075-B2CB810EFFCC}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" 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> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{8B8D8E52-408E-4596-ADC8-B586ECE18DA1}</ProjectGuid> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<Keyword>ManagedCProj</Keyword> | ||
<RootNamespace>WAV_Parse</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<CLRSupport>true</CLRSupport> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<CLRSupport>true</CLRSupport> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</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> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
<OutDir>../bin_d</OutDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
</ClCompile> | ||
<Link> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalDependencies /> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
</ClCompile> | ||
<Link> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalDependencies /> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="bytes.cpp" /> | ||
<ClCompile Include="main.cpp" /> | ||
<ClCompile Include="WAVFile.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="bytes.h" /> | ||
<ClInclude Include="WAVFile.h" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
Oops, something went wrong.