Skip to content

Commit

Permalink
Introduce the problem
Browse files Browse the repository at this point in the history
The example code reproduces the problem found in the original Aquila
repository's list of issues: zsiciarz#55

Build the workshop target and run it with a path to the tone.wav file
passed as an argument
  • Loading branch information
aniawsz committed Nov 11, 2022
1 parent 1262f6c commit 004516c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ add_subdirectory(fft_filter)
add_subdirectory(spectrogram)
add_subdirectory(mfcc_calculation)
add_subdirectory(dtw_path_recovery)

add_subdirectory(workshop)
8 changes: 8 additions & 0 deletions examples/workshop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
################################################################################
#
# AM modulation example.
#
################################################################################

aquila_example(workshop)
aquila_example(generate_test_wavfile)
19 changes: 19 additions & 0 deletions examples/workshop/generate_test_wavfile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "aquila/source/WaveFile.h"
#include "aquila/source/generator/SineGenerator.h"

#include <iostream>

int main(int argc, char *argv[])
{
if (argc < 2)
{
std::cout << "Usage: generate_test_wavfile <FILENAME>" << std::endl;
return 1;
}

const auto sampleRate = 44100;
Aquila::SineGenerator sineGenerator(sampleRate);
sineGenerator.setFrequency(220).setAmplitude(255).generate(sampleRate*12-5);

Aquila::WaveFile::save(sineGenerator, argv[1]);
}
Binary file added examples/workshop/short-tone.wav
Binary file not shown.
Binary file added examples/workshop/tone.wav
Binary file not shown.
27 changes: 27 additions & 0 deletions examples/workshop/workshop.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "aquila/source/WaveFile.h"
#include "aquila/transform/Mfcc.h"

#include <iostream>

int main(int argc, char *argv[])
{
if (argc < 2)
{
std::cout << "Usage: read_wavs <FILENAME>" << std::endl;
return 1;
}

Aquila::WaveFile wav(argv[1]);

const auto numSamples = wav.getSamplesCount();

Aquila::Mfcc mfcc(numSamples);
const auto mfccValues = mfcc.calculate(wav);

for (const auto val : mfccValues)
{
std::cout << val << " ";
}

std::cout << std::endl;
}

0 comments on commit 004516c

Please sign in to comment.