diff options
| author | nakeee <nakeee@gmail.com> | 2009-03-25 19:03:32 +0000 |
|---|---|---|
| committer | nakeee <nakeee@gmail.com> | 2009-03-25 19:03:32 +0000 |
| commit | 8cfc83259909ee3b64f7062ce23d4e513a36bafe (patch) | |
| tree | 3fb62d0a9906cf2cc6cb0c4b1eaca9f4c6e19243 /Source/Core/Common | |
| parent | fd3ca6789503e7bbb085d311c9743bae5de83cb7 (diff) | |
moved wavefile to audiocommon, you might need to add audiocommon include/lib paths to DSP-LLE on windows
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2753 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Common.vcproj | 8 | ||||
| -rw-r--r-- | Source/Core/Common/Src/SConscript | 3 | ||||
| -rw-r--r-- | Source/Core/Common/Src/WaveFile.cpp | 134 | ||||
| -rw-r--r-- | Source/Core/Common/Src/WaveFile.h | 55 |
4 files changed, 1 insertions, 199 deletions
diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index b4d79b346c..e112791a24 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -817,14 +817,6 @@ >
</File>
<File
- RelativePath=".\Src\WaveFile.cpp"
- >
- </File>
- <File
- RelativePath=".\Src\WaveFile.h"
- >
- </File>
- <File
RelativePath=".\Src\x64Analyzer.cpp"
>
</File>
diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index 097763d39f..001d77e9a9 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -16,7 +16,7 @@ files = [ "FileUtil.cpp", "Hash.cpp", "IniFile.cpp", - "LogManager.cpp", + "LogManager.cpp", "MappedFile.cpp", "MathUtil.cpp", "MemArena.cpp", @@ -33,7 +33,6 @@ files = [ "Thunk.cpp", "Timer.cpp", "Thread.cpp", - "WaveFile.cpp", "x64Emitter.cpp", "x64Analyzer.cpp", ] diff --git a/Source/Core/Common/Src/WaveFile.cpp b/Source/Core/Common/Src/WaveFile.cpp deleted file mode 100644 index 500cce8fbc..0000000000 --- a/Source/Core/Common/Src/WaveFile.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2003-2008 Dolphin Project. - -// 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 2.0. - -// 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 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#include "Common.h" -#include "WaveFile.h" - -enum {BUF_SIZE = 32*1024}; - -WaveFileWriter::WaveFileWriter() -{ - conv_buffer = 0; - skip_silence = false; -} - -WaveFileWriter::~WaveFileWriter() -{ - delete [] conv_buffer; - Stop(); -} - -bool WaveFileWriter::Start(const char *filename) -{ - if (!conv_buffer) - conv_buffer = new short[BUF_SIZE]; - - // Check if the file is already open - if (file) - { - PanicAlert("The file %s was alrady open, the file header will not be written.", filename); - return false; - } - - file = fopen(filename, "wb"); - if (!file) - { - PanicAlert("The file %s could not be opened for writing. Please check if it's already opened by another program.", filename); - return false; - } - - // --------------------------------------------------------- - // Write file header - // --------------- - Write4("RIFF"); - Write(100 * 1000 * 1000); // write big value in case the file gets truncated - Write4("WAVE"); - Write4("fmt "); - Write(16); // size of fmt block - Write(0x00020001); //two channels, uncompressed - //const u32 sample_rate = 32000; - const u32 sample_rate = 48000; - Write(sample_rate); - Write(sample_rate * 2 * 2); //two channels, 16bit - Write(0x00100004); - Write4("data"); - Write(100 * 1000 * 1000 - 32); - // We are now at offset 44 - if (ftell(file) != 44) - PanicAlert("wrong offset: %i", ftell(file)); - // --------------------------- - - return true; -} - -void WaveFileWriter::Stop() -{ - if (!file) - return; - // u32 file_size = (u32)ftell(file); - fseek(file, 4, SEEK_SET); - Write(audio_size + 36); - fseek(file, 40, SEEK_SET); - Write(audio_size); - fclose(file); - file = 0; -} - -void WaveFileWriter::Write(u32 value) -{ - fwrite(&value, 4, 1, file); -} - -void WaveFileWriter::Write4(const char *ptr) -{ - fwrite(ptr, 4, 1, file); -} - -void WaveFileWriter::AddStereoSamples(const short *sample_data, int count) -{ - if (!file) - PanicAlert("WaveFileWriter - file not open."); - if (skip_silence) { - bool all_zero = true; - for (int i = 0; i < count * 2; i++) - if (sample_data[i]) all_zero = false; - if (all_zero) return; - } - fwrite(sample_data, count * 4, 1, file); - audio_size += count * 4; -} - -void WaveFileWriter::AddStereoSamplesBE(const short *sample_data, int count) -{ - if (!file) - PanicAlert("WaveFileWriter - file not open."); - if (count > BUF_SIZE * 2) - PanicAlert("WaveFileWriter - buffer too small (count = %i).", count); - if (skip_silence) { - bool all_zero = true; - for (int i = 0; i < count * 2; i++) - if (sample_data[i]) - all_zero = false; - if (all_zero) - return; - } - for (int i = 0; i < count * 2; i++) { - conv_buffer[i] = Common::swap16((u16)sample_data[i]); - } - fwrite(conv_buffer, count * 4, 1, file); - audio_size += count * 4; -} diff --git a/Source/Core/Common/Src/WaveFile.h b/Source/Core/Common/Src/WaveFile.h deleted file mode 100644 index b9a6528155..0000000000 --- a/Source/Core/Common/Src/WaveFile.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2003-2008 Dolphin Project. - -// 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 2.0. - -// 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 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -// WaveFileWriter - -// Simple utility class to make it easy to write long 16-bit stereo -// audio streams to disk. -// Use Start() to start recording to a file, and AddStereoSamples to add wave data. -// The float variant will convert from -1.0-1.0 range and clamp. -// Alternatively, AddSamplesBE for big endian wave data. -// If Stop is not called when it destructs, the destructor will call Stop(). - -#ifndef _WAVEFILE_H -#define _WAVEFILE_H - -#include <stdio.h> - -class WaveFileWriter -{ - FILE *file; - bool skip_silence; - u32 audio_size; - short *conv_buffer; - void Write(u32 value); - void Write4(const char *ptr); - -public: - WaveFileWriter(); - ~WaveFileWriter(); - - bool Start(const char *filename); - void Stop(); - - void SetSkipSilence(bool skip) { skip_silence = skip; } - - void AddStereoSamples(const short *sample_data, int count); - void AddStereoSamplesBE(const short *sample_data, int count); // big endian - u32 GetAudioSize() { return audio_size; } -}; - -#endif // _WAVEFILE_H |
