moved things to namespace

master
Rachel Fae Fox (foxiepaws) 2020-03-10 01:02:31 -04:00
parent 966746932d
commit 694eab3b7c
13 changed files with 42 additions and 19 deletions

2
.gitignore vendored
View File

@ -4,6 +4,8 @@ fmtest
*.w16 *.w16
*.wav *.wav
.#a .#a
bin/
lib/
build/ build/
*.dSYM *.dSYM
a.out a.out

View File

@ -3,6 +3,7 @@ SRCDIR ?= src
INCDIR += -I${SRCDIR} INCDIR += -I${SRCDIR}
OBJDIR ?= build OBJDIR ?= build
BINDIR ?= bin BINDIR ?= bin
LIBDIR ?= lib
INSTALLDIR ?= /usr/local/bin INSTALLDIR ?= /usr/local/bin
TARGET ?= amalgam TARGET ?= amalgam
@ -21,7 +22,8 @@ SRC = $(wildcard ${SRCDIR}/*/*.cpp)
OBJ = ${SRC:${SRCDIR}/%.cpp=${OBJDIR}/%.o} OBJ = ${SRC:${SRCDIR}/%.cpp=${OBJDIR}/%.o}
BINS = $(wildcard ${SRCDIR}/*.cpp) BINS = $(wildcard ${SRCDIR}/*.cpp)
ALLOBJ = ${SRC:${SRCDIR}/%.cpp=${OBJDIR}/%.o} ${BINS:${SRCDIR}/%.cpp=${OBJDIR}/%.o} ALLOBJ = ${SRC:${SRCDIR}/%.cpp=${OBJDIR}/%.o} ${BINS:${SRCDIR}/%.cpp=${OBJDIR}/%.o}
INCLUDES = ${wildcard ${SRCDIR}/*/*.h}
INC = ${INCLUDES:${SRCDIR}/%.h=${LIBDIR}/include/%.h}
all: fmtest wavtest amalgam all: fmtest wavtest amalgam
${ALLOBJ}: $(OBJDIR)/%.o : $(SRCDIR)/%.cpp ${ALLOBJ}: $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
@ -37,18 +39,21 @@ wavtest: ${ALLOBJ}
@mkdir -p ${BINDIR} @mkdir -p ${BINDIR}
${CXX} ${INCDIR} -o ${BINDIR}/wavtest ${OBJDIR}/wavtest.o ${OBJ} ${LDFLAGS} ${CFLAGS} ${DEFINES} ${CXX} ${INCDIR} -o ${BINDIR}/wavtest ${OBJDIR}/wavtest.o ${OBJ} ${LDFLAGS} ${CFLAGS} ${DEFINES}
amalgam.so: ${OBJ} libamalgam.so: ${OBJ} ${INC}
${CXX} ${INCDIR} -o ${BINDIR}/${TARGET}.so ${OBJ} --shared -fPIC ${LDFLAGS} ${CFLAGS} ${DEFINES} ${CXX} ${INCDIR} -o ${LIBDIR}/lib${TARGET}.so ${OBJ} --shared -fPIC ${LDFLAGS} ${CFLAGS} ${DEFINES}
amalgam.dylib: ${OBJ} libamalgam.dylib: ${OBJ} ${INC}
${CXX} ${INCDIR} -o ${BINDIR}/${TARGET}.dylib ${OBJ} -dynamiclib ${LDFLAGS} ${CFLAGS} ${DEFINES} ${CXX} ${INCDIR} -o ${LIBDIR}/lib${TARGET}.dylib ${OBJ} -dynamiclib ${LDFLAGS} ${CFLAGS} ${DEFINES}
ifeq (${UNAME},Darwin) ifeq (${UNAME},Darwin)
amalgam: amalgam.dylib amalgam: libamalgam.dylib
else else
amalgam: amalgam.so amalgam: libamalgam.so
endif endif
${INC}: $(LIBDIR)/include/%.h : $(SRCDIR)/%.h
@mkdir -p $(dir $@)
cp $< $@
clean: clean:
@echo cleaning @echo cleaning
@rm -f ${OBJ} @rm -f ${OBJ}

View File

@ -12,7 +12,5 @@
*/ */
#include "Engine.h" #include "Engine.h"
template class FM::Engine<2>; namespace amalgam {
template class FM::Engine<4>; }
template class FM::Engine<6>;
template class FM::Engine<8>;

View File

@ -17,11 +17,13 @@
#include "Matrix.h" #include "Matrix.h"
#include <array> #include <array>
namespace amalgam {
namespace FM { namespace FM {
template <int T> template <int T>
class Engine { class Engine {
Matrix<double,T> gains; Matrix<double,T> gains;
std::array<float, T> pans; // panning on master channels.? std::array<std::pair<float,float>, T> _pans; // panning on master channels.
std::array<float, T> pans; // panning on master channels.
Matrix<bool,T> mutes; Matrix<bool,T> mutes;
std::array<Operator*,T> operators; std::array<Operator*,T> operators;
std::pair<double,double> out; std::pair<double,double> out;
@ -103,8 +105,13 @@ namespace FM {
return out; return out;
} }
}; };
template class Engine<1>;
template class Engine<4>;
template class Engine<6>;
template class Engine<8>;
} }
}
/* Local Variables: */ /* Local Variables: */
/* mode: c++ */ /* mode: c++ */

View File

@ -13,6 +13,7 @@
#include "Envelope.h" #include "Envelope.h"
namespace amalgam {
namespace FM { namespace FM {
float Envelope::process () { float Envelope::process () {
switch (envstate) { switch (envstate) {
@ -100,3 +101,4 @@ namespace FM {
return 0.0f; // if this is reached, something went wrong or an unhandled function was used. return 0.0f; // if this is reached, something went wrong or an unhandled function was used.
} }
} }
}

View File

@ -13,6 +13,7 @@
#pragma once #pragma once
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
namespace amalgam {
namespace FM { namespace FM {
class Envelope { class Envelope {
enum EnvState {_e_off,_e_attack, _e_attackrelease, _e_decay, _e_sustain,_e_release, _e_finished}; enum EnvState {_e_off,_e_attack, _e_attackrelease, _e_decay, _e_sustain,_e_release, _e_finished};
@ -73,7 +74,7 @@ namespace FM {
float operator()() { return process(); } float operator()() { return process(); }
}; };
} }
}
/* Local Variables: */ /* Local Variables: */
/* mode: c++ */ /* mode: c++ */
/* End: */ /* End: */

View File

@ -13,7 +13,7 @@
#pragma once #pragma once
#include <array> #include <array>
namespace amalgam {
namespace FM { namespace FM {
template <class T, int N> template <class T, int N>
class Matrix { class Matrix {
@ -27,6 +27,7 @@ namespace FM {
} }
}; };
} }
}
/* Local Variables: */ /* Local Variables: */
/* mode: c++ */ /* mode: c++ */

View File

@ -12,6 +12,7 @@
*/ */
#include "Operator.h" #include "Operator.h"
namespace amalgam {
namespace FM { namespace FM {
void Operator::process(){ void Operator::process(){
phase += smpTime * (((*freq * mul) + detune)); phase += smpTime * (((*freq * mul) + detune));
@ -59,3 +60,4 @@ namespace FM {
} }
} }
} }
}

View File

@ -13,6 +13,7 @@
#pragma once #pragma once
#include "Envelope.h" #include "Envelope.h"
namespace amalgam {
namespace FM { namespace FM {
class Operator { class Operator {
double mul = 1.0; double mul = 1.0;
@ -45,7 +46,7 @@ namespace FM {
~Operator(); ~Operator();
}; };
} }
}
/* Local Variables: */ /* Local Variables: */
/* mode: c++ */ /* mode: c++ */
/* End: */ /* End: */

View File

@ -12,7 +12,7 @@
*/ */
#include "WavWriter.h" #include "WavWriter.h"
#include <cstdarg> #include <cstdarg>
namespace amalgam {
WavWriter::WavWriter(char* filename, uint srate, uint chan, uint bps) { WavWriter::WavWriter(char* filename, uint srate, uint chan, uint bps) {
file = fopen(filename, "w"); file = fopen(filename, "w");
sr = srate; sr = srate;
@ -67,3 +67,4 @@ void WavWriter::writeBytes(char* bytes, uint count) {
} }
WavWriter::~WavWriter(){} WavWriter::~WavWriter(){}
}

View File

@ -15,8 +15,9 @@
// standard wave files have a 32bit size limit. // standard wave files have a 32bit size limit.
#define WAVMAX (0xffffff - 20) #define WAVMAX (0xffffff - 20)
typedef unsigned int uint; typedef unsigned int uint;
namespace amalgam {
class WavWriter { class WavWriter {
uint32_t length = 0; uint32_t length = 0;
@ -55,7 +56,7 @@ class WavWriter {
void writeHeader(); void writeHeader();
void write(...); void write(...);
}; };
}
/* Local Variables: */ /* Local Variables: */
/* mode: c++ */ /* mode: c++ */

View File

@ -16,6 +16,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
using namespace amalgam;
int16_t toint16(double i) { int16_t toint16(double i) {
double temp = i *= 32767; double temp = i *= 32767;
return floor(temp); return floor(temp);

View File

@ -17,6 +17,7 @@
#include <math.h> #include <math.h>
#include "FM/Engine.h" #include "FM/Engine.h"
#include "WavWriter/WavWriter.h" #include "WavWriter/WavWriter.h"
using namespace amalgam;
int16_t toint16(double i) { int16_t toint16(double i) {
double temp = i *= 32767; double temp = i *= 32767;