Compare commits

..

No commits in common. "7938a3f0ed0d695ce301427af579f967acdc5b3b" and "33b615261fe18611c8357be93d750570a982cd2b" have entirely different histories.

8 changed files with 37 additions and 55 deletions

View File

@ -5,7 +5,7 @@ OLEVEL = -O2
CFLAGS = -Wall -std=c++17 $(OLEVEL) -o $(PROJ)
OBJECTS = src/wtpp.cpp src/wave.cpp src/wavetable.cpp src/generators.cpp src/common.cpp
OBJECTS = src/wtpp.cpp src/wave.cpp src/wavetable.cpp src/generators.cpp
build:
$(CC) $(CFLAGS) $(OBJECTS)

View File

@ -1,8 +0,0 @@
#include <string>
#include <iostream>
#include "common.h"
void clog(std::string message)
{
std::cout << "wtpp: " << message << '\n';
}

View File

@ -1,27 +0,0 @@
/*! @file common.h
@brief Header for constants, types, utilities
*/
#ifndef COMMON_H_
#define COMMON_H_
#include <cstdint>
#include <string>
/*!
Constants
*/
const uint32_t DEFAULT_SAMPLE_RATE = 22050; /*!< 22.05 kHz sampling rate */
const uint8_t DEFAULT_BIT_DEPTH = 12; /*!< 12bit samples */
const uint16_t DEFAULT_N_SAMPLES = 1024; /*!< 1024 samples per wave cycle */
const uint16_t DEFAULT_N_WAVES = 64; /*!< Number of Wave cycle objects in Wavetable */
/*!
TYPES
*/
/*! Logs a message to console
@param message The string to be logged
*/
void clog(std::string message);
#endif // COMMON_H_

View File

@ -1,4 +1,3 @@
#include <cmath>
#include "generators.h"
#include "wave.h"

View File

@ -4,6 +4,9 @@
#ifndef GENERATORS_H_
#define GENERATORS_H_
#include "math.h"
#include <cstdint>
#include "wave.h"
/*! Generate sine wave data

View File

@ -4,17 +4,18 @@
#ifndef WAVE_H_
#define WAVE_H_
#include "common.h"
#include <array>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>
#include <array>
#include <cstdint>
using sample_table_t = std::array<float_t, DEFAULT_N_SAMPLES>; /*!< Array of waveform sample data*/
#include <math.h>
const uint16_t DEFAULT_N_SAMPLES = 1024;
using sample_table_t = std::array<float_t, DEFAULT_N_SAMPLES>;
/*! @class Wave wave.h "wave.h"
@brief Single cycle wave object with lookup table
@brief Single cycle wave object with lookup table
*/
class Wave
{

View File

@ -10,7 +10,10 @@
#include "wave.h"
using wave_table_t = std::array<Wave, DEFAULT_N_WAVES>; /*!< Array of Wave objects */
/* Number of Wave cycle objects in table */
const uint16_t DEFAULT_N_WAVES = 256;
using wave_table_t = std::array<Wave, DEFAULT_N_WAVES>;
/*! @class Wavetable wavetable.h "wavetable.h"
@brief Object containing a table of single cycle Wave objects

View File

@ -1,19 +1,30 @@
#include <array>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>
#include <type_traits>
#include <math.h>
#include "ini.h"
#include "common.h"
#include "wave.h"
#include "generators.h"
#include "wavetable.h"
static const uint32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate
static const uint8_t DEFAULT_BIT_DEPTH = 12;
/*! Logs a message
@param message The string to be logged
*/
static void log(std::string message)
{
std::cout << "wtpp: " << message << '\n';
}
int main()
{
clog("Generating wave cycle lookup tables");
log("Generating wave cycle lookup tables");
Wave sin_wave, squ_wave, saw_wave, tri_wave, isaw_wave;
// Calculate fundamental wave values
@ -30,21 +41,21 @@ int main()
tri_wave.setTable(tri_vals);
isaw_wave.setTable(isaw_vals);
clog("Printing head of sine table");
log("Printing head of sine table");
sin_wave.print_head();
clog("Printing head of square table");
log("Printing head of square table");
squ_wave.print_head();
clog("Printing head of saw table");
log("Printing head of saw table");
saw_wave.print_head();
clog("Printing head of triangle table");
log("Printing head of triangle table");
tri_wave.print_head();
clog("Printing head of inverse saw table");
log("Printing head of inverse saw table");
isaw_wave.print_head();
// Create wave table of all fundamental Wave objects
wave_table_t fundies = {sin_wave, squ_wave, saw_wave, tri_wave, isaw_wave};
Wavetable wt_01{"Fundamental Waves", fundies};
clog(wt_01.name());
log(wt_01.name());
// Write sine wave table to file
sin_wave.export_csv("data/sine.csv");