Ajouts de musique et irrKlang.
This commit is contained in:
68
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06.Recording.cbp
vendored
Normal file
68
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06.Recording.cbp
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE CodeBlocks_project_file>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="1"/>
|
||||
<Project>
|
||||
<Option title="06.Recording"/>
|
||||
<Option makefile="Makefile"/>
|
||||
<Option makefile_is_custom="0"/>
|
||||
<Option active_target="1"/>
|
||||
<Option compiler="0"/>
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="..\..\bin\win32-gcc\06.Recording.exe"/>
|
||||
<Option working_dir="."/>
|
||||
<Option object_output="Debug"/>
|
||||
<Option deps_output=".deps"/>
|
||||
<Option type="1"/>
|
||||
<Option compiler="0"/>
|
||||
<Option projectResourceIncludeDirsRelation="1"/>
|
||||
<Compiler>
|
||||
<Add option="-DWIN32"/>
|
||||
<Add option="-D_DEBUG"/>
|
||||
<Add option="-D_CONSOLE"/>
|
||||
<Add option="-W"/>
|
||||
<Add option="-O0"/>
|
||||
<Add directory="..\..\include"/>
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add directory="..\..\lib\win32-gcc"/>
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="..\..\bin\win32-gcc\06.Recording.exe"/>
|
||||
<Option working_dir="."/>
|
||||
<Option object_output="Release"/>
|
||||
<Option deps_output=".deps"/>
|
||||
<Option type="1"/>
|
||||
<Option compiler="0"/>
|
||||
<Option projectResourceIncludeDirsRelation="1"/>
|
||||
<Compiler>
|
||||
<Add option="-DWIN32"/>
|
||||
<Add option="-DNDEBUG"/>
|
||||
<Add option="-D_CONSOLE"/>
|
||||
<Add option="-W"/>
|
||||
<Add option="-g"/>
|
||||
<Add directory="..\..\include"/>
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add directory="..\..\lib\win32-gcc"/>
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Os"/>
|
||||
<Add option="-O1"/>
|
||||
<Add option="-O"/>
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s"/>
|
||||
<Add library="..\..\lib\win32-gcc\libirrklang.a"/>
|
||||
</Linker>
|
||||
<Unit filename="main.cpp">
|
||||
<Option compilerVar="CPP"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
</Unit>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
17
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06.Recording.sln
vendored
Normal file
17
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06.Recording.sln
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "06.Recording", "06.Recording.vcproj", "{BF01F846-8239-4712-8C60-0E17DF3FECA1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BF01F846-8239-4712-8C60-0E17DF3FECA1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{BF01F846-8239-4712-8C60-0E17DF3FECA1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
186
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06.Recording.vcproj
vendored
Normal file
186
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06.Recording.vcproj
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="06.Recording"
|
||||
ProjectGUID="{BF01F846-8239-4712-8C60-0E17DF3FECA1}"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../bin/win32-visualstudio/06.Recording.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../../lib/win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(OutDir)/06.Recording.pdb"
|
||||
SubSystem="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>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../bin/win32-visualstudio/06.Recording.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../lib/win32-visualstudio"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="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>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
90
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06_Recording.dsp
vendored
Normal file
90
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06_Recording.dsp
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
# Microsoft Developer Studio Project File - Name="06_Recording" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** NICHT BEARBEITEN **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=06_Recording - Win32 Debug
|
||||
!MESSAGE Dies ist kein g<>ltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
|
||||
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f<>hren Sie den Befehl
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "06_Recording.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE Sie k<>nnen beim Ausf<73>hren von NMAKE eine Konfiguration angeben
|
||||
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "06_Recording.mak" CFG="06_Recording - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE F<>r die Konfiguration stehen zur Auswahl:
|
||||
!MESSAGE
|
||||
!MESSAGE "06_Recording - Win32 Release" (basierend auf "Win32 (x86) Console Application")
|
||||
!MESSAGE "06_Recording - Win32 Debug" (basierend auf "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "06_Recording - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "06_Recording___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "06_Recording___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "06_Recording___Win32_Release"
|
||||
# PROP Intermediate_Dir "06_Recording___Win32_Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0xc07 /d "NDEBUG"
|
||||
# ADD RSC /l 0xc07 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../../bin/win32-visualstudio/06.Recording.exe" /libpath:"../../lib/Win32-visualStudio"
|
||||
|
||||
!ELSEIF "$(CFG)" == "06_Recording - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0xc07 /d "_DEBUG"
|
||||
# ADD RSC /l 0xc07 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../bin/win32-visualstudio/06.Recording.exe" /pdbtype:sept /libpath:"../../lib/Win32-visualStudio"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "06_Recording - Win32 Release"
|
||||
# Name "06_Recording - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
29
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06_Recording.dsw
vendored
Normal file
29
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/06_Recording.dsw
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GEL<45>SCHT WERDEN!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "06_Recording"=.\06_Recording.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
127
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/main.cpp
vendored
Normal file
127
SQCSim2021/external/irrKlang-1.6.0/examples/06.Recording/main.cpp
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
// This example will show how to record and play back audio. Additionally,
|
||||
// the example shows how to write recorded audio out into a .WAV file.
|
||||
// Audio recording is currently only supported on windows, so this
|
||||
// example won't work on Linux or MacOS for now.
|
||||
|
||||
// Lets start: include the irrKlang headers and other input/output stuff
|
||||
// needed to print and get user input from the console. And as exlained
|
||||
// in the first tutorial, we use the namespace irr and audio and
|
||||
// link to the irrKlang.dll file.
|
||||
#include <stdio.h>
|
||||
#include <irrKlang.h>
|
||||
|
||||
// include console I/O methods (conio.h for windows, our wrapper in linux)
|
||||
#if defined(WIN32)
|
||||
#include <conio.h>
|
||||
#else
|
||||
#include "../common/conio.h"
|
||||
#endif
|
||||
#pragma comment(lib, "irrKlang.lib") // link with irrKlang.dll
|
||||
|
||||
|
||||
using namespace irrklang;
|
||||
|
||||
void writeWaveFile(const char* filename, SAudioStreamFormat format, void* data);
|
||||
|
||||
// The following will simply start up the irrklang engine, create an audio recorder, record
|
||||
// some audio when the user presses a key, and save that data to a wave file. Additionally,
|
||||
// the data is added into the sound engine and played back as well.
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
ISoundEngine* engine = createIrrKlangDevice();
|
||||
IAudioRecorder* recorder = createIrrKlangAudioRecorder(engine);
|
||||
|
||||
if (!engine || !recorder)
|
||||
{
|
||||
printf("Could not create audio engine or audio recoder\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\nPress any key to start recording audio...\n");
|
||||
getch();
|
||||
|
||||
// record some audio
|
||||
|
||||
recorder->startRecordingBufferedAudio();
|
||||
|
||||
printf("\nRECORDING. Press any key to stop...\n");
|
||||
getch();
|
||||
|
||||
recorder->stopRecordingAudio();
|
||||
|
||||
printf("\nRecording done, recorded %dms of audio.\n",
|
||||
recorder->getAudioFormat().FrameCount * 1000 / recorder->getAudioFormat().SampleRate );
|
||||
printf("Press any key to play back recorded audio...\n");
|
||||
getch();
|
||||
|
||||
// write the recorded audio as wave file
|
||||
writeWaveFile("recorded.wav", recorder->getAudioFormat(), recorder->getRecordedAudioData());
|
||||
|
||||
// play the recorded audio
|
||||
recorder->addSoundSourceFromRecordedAudio("myRecordedVoice");
|
||||
engine->play2D("myRecordedVoice", true);
|
||||
|
||||
// wait until user presses a key
|
||||
printf("\nPress any key to quit...");
|
||||
getch();
|
||||
|
||||
recorder->drop();
|
||||
engine->drop(); // delete engine
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// writes the recorded audio data into a .WAV file
|
||||
void writeWaveFile(const char* filename, SAudioStreamFormat format, void* data)
|
||||
{
|
||||
if (!data)
|
||||
{
|
||||
printf("Could not save recorded data to %s, nothing recorded\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* file = fopen(filename, "wb");
|
||||
|
||||
if (file)
|
||||
{
|
||||
// write wave header
|
||||
unsigned short formatType = 1;
|
||||
unsigned short numChannels = format.ChannelCount;
|
||||
unsigned long sampleRate = format.SampleRate;
|
||||
unsigned short bitsPerChannel = format.getSampleSize() * 8;
|
||||
unsigned short bytesPerSample = format.getFrameSize() ;
|
||||
unsigned long bytesPerSecond = format.getBytesPerSecond();
|
||||
unsigned long dataLen = format.getSampleDataSize();
|
||||
|
||||
const int fmtChunkLen = 16;
|
||||
const int waveHeaderLen = 4 + 8 + fmtChunkLen + 8;
|
||||
|
||||
unsigned long totalLen = waveHeaderLen + dataLen;
|
||||
|
||||
fwrite("RIFF", 4, 1, file);
|
||||
fwrite(&totalLen, 4, 1, file);
|
||||
fwrite("WAVE", 4, 1, file);
|
||||
fwrite("fmt ", 4, 1, file);
|
||||
fwrite(&fmtChunkLen, 4, 1, file);
|
||||
fwrite(&formatType, 2, 1, file);
|
||||
fwrite(&numChannels, 2, 1, file);
|
||||
fwrite(&sampleRate, 4, 1, file);
|
||||
fwrite(&bytesPerSecond, 4, 1, file);
|
||||
fwrite(&bytesPerSample, 2, 1, file);
|
||||
fwrite(&bitsPerChannel, 2, 1, file);
|
||||
|
||||
// write data
|
||||
|
||||
fwrite("data", 4, 1, file);
|
||||
fwrite(&dataLen, 4, 1, file);
|
||||
fwrite(data, dataLen, 1, file);
|
||||
|
||||
// finish
|
||||
|
||||
printf("Saved audio as %s\n", filename);
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
printf("Could not open %s to write audio data\n", filename);
|
||||
}
|
Reference in New Issue
Block a user