From 302131d534cf0a434d6311119ae019e79a6330b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=9D=CE=B1=CF=81=CE=BF=CF=85=CF=83=CE=AD=C2=B7=CE=BC?= =?UTF-8?q?=C2=B7=CE=B3=CE=B9=CE=BF=CF=85=CE=BC=CE=B5=CE=BC=CE=AF=C2=B7?= =?UTF-8?q?=CE=A7=CE=B9=CE=BD=CE=B1=CE=BA=CE=AC=CE=BD=CE=BD=CE=B1?= <40709280+NaruseMioShirakana@users.noreply.github.com> Date: Thu, 18 May 2023 13:16:28 +0800 Subject: [PATCH] Delete Wav.cpp --- CppDataProcess/Wav.cpp | 151 ----------------------------------------- 1 file changed, 151 deletions(-) delete mode 100644 CppDataProcess/Wav.cpp diff --git a/CppDataProcess/Wav.cpp b/CppDataProcess/Wav.cpp deleted file mode 100644 index c2b7e8a..0000000 --- a/CppDataProcess/Wav.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "Wav.hpp" - -Wav::Wav(const wchar_t* Path) :header(WAV_HEADER()) { - char buf[1024]; - FILE* stream; - _wfreopen_s(&stream, Path, L"rb", stderr); - if (stream == nullptr) { - throw (std::exception("File not exists")); - } - fread(buf, 1, HEAD_LENGTH, stream); - int pos = 0; - while (pos < HEAD_LENGTH) { - if ((buf[pos] == 'R') && (buf[pos + 1] == 'I') && (buf[pos + 2] == 'F') && (buf[pos + 3] == 'F')) { - pos += 4; - break; - } - ++pos; - } - if (pos >= HEAD_LENGTH) - throw (std::exception("Don't order fried rice (annoyed)")); - header.ChunkSize = *(int*)&buf[pos]; - pos += 8; - while (pos < HEAD_LENGTH) { - if ((buf[pos] == 'f') && (buf[pos + 1] == 'm') && (buf[pos + 2] == 't')) { - pos += 4; - break; - } - ++pos; - } - if (pos >= HEAD_LENGTH) - throw (std::exception("Don't order fried rice (annoyed)")); - header.Subchunk1Size = *(int*)&buf[pos]; - pos += 4; - header.AudioFormat = *(short*)&buf[pos]; - pos += 2; - header.NumOfChan = *(short*)&buf[pos]; - pos += 2; - header.SamplesPerSec = *(int*)&buf[pos]; - pos += 4; - header.bytesPerSec = *(int*)&buf[pos]; - pos += 4; - header.blockAlign = *(short*)&buf[pos]; - pos += 2; - header.bitsPerSample = *(short*)&buf[pos]; - pos += 2; - while (pos < HEAD_LENGTH) { - if ((buf[pos] == 'd') && (buf[pos + 1] == 'a') && (buf[pos + 2] == 't') && (buf[pos + 3] == 'a')) { - pos += 4; - break; - } - ++pos; - } - if (pos >= HEAD_LENGTH) - throw (std::exception("Don't order fried rice (annoyed)")); - header.Subchunk2Size = *(int*)&buf[pos]; - pos += 4; - StartPos = pos; - Data = new char[header.Subchunk2Size + 1]; - fseek(stream, StartPos, SEEK_SET); - fread(Data, 1, header.Subchunk2Size, stream); - if (stream != nullptr) { - fclose(stream); - } - SData = reinterpret_cast(Data); - dataSize = header.Subchunk2Size / 2; -} - -Wav::Wav(const Wav& input) :header(WAV_HEADER()) { - Data = new char[(input.header.Subchunk2Size + 1)]; - if (Data == nullptr) { throw std::exception("OOM"); } - memcpy(header.RIFF, input.header.RIFF, 4); - memcpy(header.fmt, input.header.fmt, 4); - memcpy(header.WAVE, input.header.WAVE, 4); - memcpy(header.Subchunk2ID, input.header.Subchunk2ID, 4); - header.ChunkSize = input.header.ChunkSize; - header.Subchunk1Size = input.header.Subchunk1Size; - header.AudioFormat = input.header.AudioFormat; - header.NumOfChan = input.header.NumOfChan; - header.SamplesPerSec = input.header.SamplesPerSec; - header.bytesPerSec = input.header.bytesPerSec; - header.blockAlign = input.header.blockAlign; - header.bitsPerSample = input.header.bitsPerSample; - header.Subchunk2Size = input.header.Subchunk2Size; - StartPos = input.StartPos; - memcpy(Data, input.Data, input.header.Subchunk2Size); - SData = reinterpret_cast(Data); - dataSize = header.Subchunk2Size / 2; -} - -Wav::Wav(Wav&& input) noexcept -{ - Data = input.Data; - input.Data = nullptr; - memcpy(header.RIFF, input.header.RIFF, 4); - memcpy(header.fmt, input.header.fmt, 4); - memcpy(header.WAVE, input.header.WAVE, 4); - memcpy(header.Subchunk2ID, input.header.Subchunk2ID, 4); - header.ChunkSize = input.header.ChunkSize; - header.Subchunk1Size = input.header.Subchunk1Size; - header.AudioFormat = input.header.AudioFormat; - header.NumOfChan = input.header.NumOfChan; - header.SamplesPerSec = input.header.SamplesPerSec; - header.bytesPerSec = input.header.bytesPerSec; - header.blockAlign = input.header.blockAlign; - header.bitsPerSample = input.header.bitsPerSample; - header.Subchunk2Size = input.header.Subchunk2Size; - StartPos = input.StartPos; - SData = reinterpret_cast(Data); - dataSize = header.Subchunk2Size / 2; -} - -Wav& Wav::operator=(Wav&& input) noexcept -{ - destory(); - Data = input.Data; - input.Data = nullptr; - memcpy(header.RIFF, input.header.RIFF, 4); - memcpy(header.fmt, input.header.fmt, 4); - memcpy(header.WAVE, input.header.WAVE, 4); - memcpy(header.Subchunk2ID, input.header.Subchunk2ID, 4); - header.ChunkSize = input.header.ChunkSize; - header.Subchunk1Size = input.header.Subchunk1Size; - header.AudioFormat = input.header.AudioFormat; - header.NumOfChan = input.header.NumOfChan; - header.SamplesPerSec = input.header.SamplesPerSec; - header.bytesPerSec = input.header.bytesPerSec; - header.blockAlign = input.header.blockAlign; - header.bitsPerSample = input.header.bitsPerSample; - header.Subchunk2Size = input.header.Subchunk2Size; - StartPos = input.StartPos; - SData = reinterpret_cast(Data); - dataSize = header.Subchunk2Size / 2; - return *this; -} - -Wav& Wav::cat(const Wav& input) -{ - if (header.AudioFormat != 1) return *this; - if (header.SamplesPerSec != input.header.bitsPerSample || header.NumOfChan != input.header.NumOfChan) return *this; - char* buffer = new char[(int64_t)header.Subchunk2Size + (int64_t)input.header.Subchunk2Size + 1]; - if (buffer == nullptr)return *this; - memcpy(buffer, Data, header.Subchunk2Size); - memcpy(buffer + header.Subchunk2Size, input.Data, input.header.Subchunk2Size); - header.ChunkSize += input.header.Subchunk2Size; - header.Subchunk2Size += input.header.Subchunk2Size; - delete[] Data; - Data = buffer; - SData = reinterpret_cast(Data); - dataSize = header.Subchunk2Size / 2; - return *this; -}