MCPcopy Create free account
hub / github.com/adamstark/AudioFile / loadAudioFileAndPrintSummary

Function loadAudioFileAndPrintSummary

examples/examples.cpp:74–103  ·  view source on GitHub ↗

=======================================================================

Source from the content-addressed store, hash-verified

72
73 //=======================================================================
74 void loadAudioFileAndPrintSummary()
75 {
76 //---------------------------------------------------------------
77 std::cout << "**********************" << std::endl;
78 std::cout << "Running Example: Load Audio File and Print Summary" << std::endl;
79 std::cout << "**********************" << std::endl << std::endl;
80
81 //---------------------------------------------------------------
82 // 1. Set a file path to an audio file on your machine
83 const std::string filePath = std::string (PROJECT_BINARY_DIR) + "/test-audio.wav";
84
85 //---------------------------------------------------------------
86 // 2. Create an AudioFile object and load the audio file
87
88 AudioFile<float> a;
89 bool loadedOK = a.load (filePath);
90
91 /** If you hit this assert then the file path above
92 probably doesn't refer to a valid audio file */
93 assert (loadedOK);
94
95 //---------------------------------------------------------------
96 // 3. Let's print out some key details
97
98 std::cout << "Bit Depth: " << a.getBitDepth() << std::endl;
99 std::cout << "Sample Rate: " << a.getSampleRate() << std::endl;
100 std::cout << "Num Channels: " << a.getNumChannels() << std::endl;
101 std::cout << "Length in Seconds: " << a.getLengthInSeconds() << std::endl;
102 std::cout << std::endl;
103 }
104
105 //=======================================================================
106 void loadAudioFileAndProcessSamples()

Callers 1

mainFunction · 0.85

Calls 5

loadMethod · 0.80
getBitDepthMethod · 0.80
getSampleRateMethod · 0.80
getNumChannelsMethod · 0.80
getLengthInSecondsMethod · 0.80

Tested by

no test coverage detected