From 97245f61ab738c2b0e962610e5935f7e2587e8c6 Mon Sep 17 00:00:00 2001 From: Dimitri Date: Thu, 11 Feb 2016 10:36:42 -0800 Subject: [PATCH] fileData as a shared ptr --- examples/src/Main.cpp | 78 +++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/examples/src/Main.cpp b/examples/src/Main.cpp index 2f96ad2..5857e47 100644 --- a/examples/src/Main.cpp +++ b/examples/src/Main.cpp @@ -23,67 +23,67 @@ int main(int argc, const char **argv) try AudioDevice myDevice(2, desiredSampleRate); myDevice.Open(myDevice.info.id); - AudioData * fileData = new AudioData(); + std::shared_ptr fileData = std::make_shared(); NyquistIO loader; if (argc > 1) { std::string cli_arg = std::string(argv[1]); - loader.Load(fileData, cli_arg); + loader.Load(fileData.get(), cli_arg); } else { // Circular libnyquist testing - //loader.Load(fileData, "encoded.wav"); + //loader.Load(fileData.get(), "encoded.wav"); // 1-channel wave - loader.Load(fileData, "test_data/1ch/44100/8/test.wav"); - //loader.Load(fileData, "test_data/1ch/44100/16/test.wav"); - //loader.Load(fileData, "test_data/1ch/44100/24/test.wav"); - //loader.Load(fileData, "test_data/1ch/44100/32/test.wav"); - //loader.Load(fileData, "test_data/1ch/44100/64/test.wav"); - + //loader.Load(fileData.get(), "test_data/1ch/44100/8/test.wav"); + //loader.Load(fileData.get(), "test_data/1ch/44100/16/test.wav"); + //loader.Load(fileData.get(), "test_data/1ch/44100/24/test.wav"); + //loader.Load(fileData.get(), "test_data/1ch/44100/32/test.wav"); + //loader.Load(fileData.get(), "test_data/1ch/44100/64/test.wav"); + // 2-channel wave - //loader.Load(fileData, "test_data/2ch/44100/8/test.wav"); - //loader.Load(fileData, "test_data/2ch/44100/16/test.wav"); - //loader.Load(fileData, "test_data/2ch/44100/24/test.wav"); - //loader.Load(fileData, "test_data/2ch/44100/32/test.wav"); - //loader.Load(fileData, "test_data/2ch/44100/64/test.wav"); - - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_44_16_mono-ima4-reaper.wav"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_44_16_stereo-ima4-reaper.wav"); + //loader.Load(fileData.get(), "test_data/2ch/44100/8/test.wav"); + //loader.Load(fileData.get(), "test_data/2ch/44100/16/test.wav"); + //loader.Load(fileData.get(), "test_data/2ch/44100/24/test.wav"); + //loader.Load(fileData.get(), "test_data/2ch/44100/32/test.wav"); + //loader.Load(fileData.get(), "test_data/2ch/44100/64/test.wav"); + + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_44_16_mono-ima4-reaper.wav"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_44_16_stereo-ima4-reaper.wav"); // Multi-channel wave - //loader.Load(fileData, "test_data/ad_hoc/6_channel_44k_16b.wav"); + //loader.Load(fileData.get(), "test_data/ad_hoc/6_channel_44k_16b.wav"); // 1 + 2 channel ogg - //loader.Load(fileData, "test_data/ad_hoc/LR_Stereo.ogg"); - //loader.Load(fileData, "test_data/ad_hoc/TestLaugh_44k.ogg"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeat.ogg"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeatMono.ogg"); - //loader.Load(fileData, "test_data/ad_hoc/BlockWoosh_Stereo.ogg"); - + //loader.Load(fileData.get(), "test_data/ad_hoc/LR_Stereo.ogg"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestLaugh_44k.ogg"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat.ogg"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeatMono.ogg"); + //loader.Load(fileData.get(), "test_data/ad_hoc/BlockWoosh_Stereo.ogg"); + // 1 + 2 channel flac - //loader.Load(fileData, "test_data/ad_hoc/KittyPurr8_Stereo_Dithered.flac"); - //loader.Load(fileData, "test_data/ad_hoc/KittyPurr16_Stereo.flac"); - //loader.Load(fileData, "test_data/ad_hoc/KittyPurr16_Mono.flac"); - //loader.Load(fileData, "test_data/ad_hoc/KittyPurr24_Stereo.flac"); + //loader.Load(fileData.get(), "test_data/ad_hoc/KittyPurr8_Stereo_Dithered.flac"); + //loader.Load(fileData.get(), "test_data/ad_hoc/KittyPurr16_Stereo.flac"); + //loader.Load(fileData.get(), "test_data/ad_hoc/KittyPurr16_Mono.flac"); + //loader.Load(fileData.get(), "test_data/ad_hoc/KittyPurr24_Stereo.flac"); // 2-channel opus - //loader.Load(fileData, "test_data/ad_hoc/detodos.opus"); // "Firefox: From All, To All" - + //loader.Load(fileData.get(), "test_data/ad_hoc/detodos.opus"); // "Firefox: From All, To All" + // 1 + 2 channel wavepack - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_Float32.wv"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_Float32_Mono.wv"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_Int16.wv"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_Int24.wv"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_Int32.wv"); - //loader.Load(fileData, "test_data/ad_hoc/TestBeat_Int24_Mono.wv"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_Float32.wv"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_Float32_Mono.wv"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_Int16.wv"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_Int24.wv"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_Int32.wv"); + //loader.Load(fileData.get(), "test_data/ad_hoc/TestBeat_Int24_Mono.wv"); // 1 + 2 channel musepack - //loader.Load(fileData, "test_data/ad_hoc/44_16_stereo.mpc"); - //loader.Load(fileData, "test_data/ad_hoc/44_16_mono.mpc"); + //loader.Load(fileData.get(), "test_data/ad_hoc/44_16_stereo.mpc"); + loader.Load(fileData.get(), "test_data/ad_hoc/44_16_mono.mpc"); } // Libnyquist does not (currently) perform sample rate conversion @@ -106,7 +106,7 @@ int main(int argc, const char **argv) try myDevice.Play(fileData->samples); } - int encoderStatus = WavEncoder::WriteFile({2, PCM_16, DITHER_NONE }, fileData, "encoded.wav"); + int encoderStatus = WavEncoder::WriteFile({2, PCM_16, DITHER_NONE }, fileData.get(), "encoded.wav"); std::cout << "Encoder Status: " << encoderStatus << std::endl; return EXIT_SUCCESS;