parent
541af6a701
commit
3742e75309
|
|
@ -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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue