From 2a924dd7ceeeb8abd0d6ee5085c247861c6257a6 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Mon, 3 Jan 2022 17:25:10 -0800 Subject: [PATCH] Removes WAVUtil.h from Gems/Micropohone Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- Gems/Microphone/Code/CMakeLists.txt | 2 - .../Code/Include/Microphone/WAVUtil.h | 108 ------------------ Gems/Microphone/Code/microphone_files.cmake | 1 - 3 files changed, 111 deletions(-) delete mode 100644 Gems/Microphone/Code/Include/Microphone/WAVUtil.h diff --git a/Gems/Microphone/Code/CMakeLists.txt b/Gems/Microphone/Code/CMakeLists.txt index 873d05e98d..bde4f59e4e 100644 --- a/Gems/Microphone/Code/CMakeLists.txt +++ b/Gems/Microphone/Code/CMakeLists.txt @@ -17,8 +17,6 @@ ly_add_target( PLATFORM_INCLUDE_FILES ${pal_source_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake INCLUDE_DIRECTORIES - PRIVATE - Include PUBLIC Source BUILD_DEPENDENCIES diff --git a/Gems/Microphone/Code/Include/Microphone/WAVUtil.h b/Gems/Microphone/Code/Include/Microphone/WAVUtil.h deleted file mode 100644 index 9fdcc95a97..0000000000 --- a/Gems/Microphone/Code/Include/Microphone/WAVUtil.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include - -namespace Audio -{ - struct WAVHeader - { - AZ::u8 riffTag[4]; - AZ::u32 fileSize; - AZ::u8 waveTag[4]; - AZ::u8 fmtTag[4]; - AZ::u32 fmtSize; - AZ::u16 audioFormat; - AZ::u16 channels; - AZ::u32 sampleRate; - AZ::u32 byteRate; - AZ::u16 blockAlign; - AZ::u16 bitsPerSample; - AZ::u8 dataTag[4]; - AZ::u32 dataSize; - - // defaults to 16 KHz 16 bit mono PCM format - inline WAVHeader() - : fileSize { 0 } - , fmtSize { 16 } - , audioFormat { 1 } - , channels { 1 } - , sampleRate { 16000 } - , bitsPerSample { 16 } - , byteRate { 16000 * 2 } // 16 bit is 2 bytes per sample - , blockAlign { 2 } - , dataSize { 0 } - { - memcpy(riffTag, "RIFF", 4); - memcpy(waveTag, "WAVE", 4); - memcpy(fmtTag, "fmt ", 4); - memcpy(dataTag, "data", 4); - } - }; - - - class WAVUtil - { - public: - WAVHeader m_wavHeader; - - inline WAVUtil(AZ::u32 sampleRate, AZ::u16 bitsPerSample, AZ::u16 channels, bool isFloat) - { - m_wavHeader.sampleRate = sampleRate; - m_wavHeader.bitsPerSample = bitsPerSample; - m_wavHeader.channels = channels; - m_wavHeader.byteRate = static_cast(sampleRate * channels * (bitsPerSample / 8)); - m_wavHeader.audioFormat = isFloat ? 3 : 1; // 1 = PCM 3 = IEEE Float - } - - // Set the wav buffer to use for class operations. This buffer should have reserved - // space at the beginning of the buffer in the amount of sizeof(WAVHeader) which - // this function will write over. The remaining data should be sound data that - // matches your format - inline bool SetBuffer(AZ::u8* buffer, AZStd::size_t bufferSize) - { - if(buffer == nullptr || bufferSize <= sizeof(WAVHeader)) - { - return false; - } - m_buffer = buffer; - m_bufferSize = bufferSize; - m_wavHeader.fileSize = bufferSize - 8; // the 'RIFF' tag and filesize aren't counted in this. - m_wavHeader.dataSize = bufferSize - sizeof(WAVHeader); - AZ::u8* headerBuff = reinterpret_cast(&m_wavHeader); - ::memcpy(m_buffer, headerBuff, sizeof(WAVHeader)); - return true; - } - - inline bool WriteWAVToFile(const AZStd::string& filePath) - { - if(m_buffer == nullptr || m_bufferSize == 0) - { - AZ_TracePrintf("WAVUtil", "WAV buffer invalid, unable to write file. Buffer Ptr: %d, Buffer Size: %d\n", m_buffer, m_bufferSize); - return false; - } - AZ::IO::FileIOStream fileStream(filePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary); - if (fileStream.IsOpen()) - { - [[maybe_unused]] auto bytesWritten = fileStream.Write(m_bufferSize, m_buffer); - AZ_TracePrintf("WAVUtil", "Wrote WAV file: %s, %d bytes\n", filePath.c_str(), bytesWritten); - return true; - } - else - { - AZ_TracePrintf("WAVUtil", "Unable to write WAV file, can't open stream for file %s\n", filePath.c_str()); - return false; - } - } - - private: - AZ::u8* m_buffer = nullptr; - AZStd::size_t m_bufferSize = 0; - - }; -} diff --git a/Gems/Microphone/Code/microphone_files.cmake b/Gems/Microphone/Code/microphone_files.cmake index 7ae423e995..4a8acf232d 100644 --- a/Gems/Microphone/Code/microphone_files.cmake +++ b/Gems/Microphone/Code/microphone_files.cmake @@ -11,5 +11,4 @@ set(FILES Source/MicrophoneSystemComponent.h Source/SimpleDownsample.cpp Source/SimpleDownsample.h - Include/Microphone/WAVUtil.h )