Compare commits

...

2 Commits

Author SHA1 Message Date
rkcf 3742e75309 Add: skeleton wtpp.cpp with Wavetable class
Refs: #2
2023-02-25 14:02:21 -06:00
rkcf 541af6a701 Fix: change C++ version in makefile 2023-02-25 14:01:32 -06:00
2 changed files with 59 additions and 2 deletions

View File

@ -3,11 +3,11 @@ CC = /usr/bin/clang++
GDB = /usr/bin/gdb
OLEVEL = -O2
CFLAGS = -Wall -std=c++20 $(OLEVEL) -o $(PROJ)
CFLAGS = -Wall -std=c++17 $(OLEVEL) -o $(PROJ)
OBJECTS = src/wtpp.cpp
build:
build: clean
$(CC) $(CFLAGS) $(OBJECTS)
clean:

57
src/wtpp.cpp Normal file
View File

@ -0,0 +1,57 @@
#include <array>
#include <cstdint>
#include <iostream>
#include <string>
#include <type_traits>
static const std::uint_fast32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate
static const std::uint_fast8_t DEFAULT_BIT_DEPTH = 12;
class Wavetable
{
private:
std::uint_fast16_t m_id {};
std::string m_name {};
std::array<std::uint_fast32_t, 1024> m_table;
public:
Wavetable(std::uint_fast16_t id, std::string name)
: m_id{ id }, m_name{ name }, m_table {}
{
// Do nothing
}
std::string name()
{
std::string id_str = std::to_string(m_id);
id_str.append(": ");
id_str.append(m_name);
return id_str;
}
};
/* Logs a message */
static void log(std::string message)
{
std::cout << "wtpp: " << message << '\n';
}
/* Generates basic sine wave table */
static Wavetable gen_sin_tbl()
{
Wavetable table = {0, "sine"};
return table;
}
int main()
{
// Generate wavetables
log("Generating wavetables");
// Generate sine table
Wavetable sin_tbl = gen_sin_tbl();
log(sin_tbl.name());
return 0;
}