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
*.wav
.#a
bin/
lib/
build/
*.dSYM
a.out

View File

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

View File

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

View File

@ -17,11 +17,13 @@
#include "Matrix.h"
#include <array>
namespace amalgam {
namespace FM {
template <int T>
class Engine {
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;
std::array<Operator*,T> operators;
std::pair<double,double> out;
@ -103,8 +105,13 @@ namespace FM {
return out;
}
};
template class Engine<1>;
template class Engine<4>;
template class Engine<6>;
template class Engine<8>;
}
}
/* Local Variables: */
/* mode: c++ */

View File

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

View File

@ -13,6 +13,7 @@
#pragma once
#include <stdlib.h>
#include <math.h>
namespace amalgam {
namespace FM {
class Envelope {
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(); }
};
}
}
/* Local Variables: */
/* mode: c++ */
/* End: */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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