Commit b348bcb1 authored by Daniel Clarke's avatar Daniel Clarke

begun work on fft library, updated makefile and readme.

parent bf3854d9
# change '../../em++' to path to em++ in emscriten folder
CC=../../em++
EMSCR=../../em++
# ----------------------------------------
# Maximilian base stuff
# POST_JS is all the external js stuff that handles web audio etc
POST_JS=src/js/maxi_webAudio.js
#the .cpp file that is used
SOURCE=src/cpp/maxi_emscr_new.cpp
SOURCE_MAXI=src/cpp/maxi_emscr_new.cpp #src/cpp/libs/fft.cpp
# destination .js file
OUTPUT=maxiLib/maxiLib.js
OUTPUT_MAXI=maxiLib/maxiLib.js
# ----------------------------------------
# extra libs stuff
# EXP_FUNCS=-s EXPORTED_FUNCTIONS="['_sumArray']"
#the .cpp file that is used
SOURCE_FFT=src/cpp/libs/fft.cpp
# destination for fft
OUTPUT_FFT=maxiLib/libs/maxiLib_fft.js
# ----------------------------------------
# General flags
# https://kripken.github.io/emscripten-site/docs/tools_reference/emcc.html
CFLAGS=-O2 $(EXP_FUNCS) -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 --memory-init-file 0 --profiling
CFLAGS=-O2 -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 --memory-init-file 0 --profiling
# ----------------------------------------
# Final paths
maxi:
$(EMSCR) $(CFLAGS) --post-js $(POST_JS) --bind -o $(OUTPUT_MAXI) $(SOURCE_MAXI)
fft:
$(EMSCR) $(CFLAGS) --bind -o $(OUTPUT_FFT) $(SOURCE_FFT)
all:
$(CC) $(CFLAGS) --post-js $(POST_JS) --bind -o $(OUTPUT) $(SOURCE)
\ No newline at end of file
all: maxi fft
\ No newline at end of file
An implementation of maximilian in javascript using emscripten to compile code from C++ to javascript.
To use: move the maxiLib.js and maxiLib.map files from the web folder to an appropriate location and include using the <script> tag.
To use: move the maxiLib.js file from the maxiLib folder to an appropriate location and include using the <script> tag.
Makefile!! - Can now use ‘make’ command to compile. You will probably need to change the location of em++ in the Makefile though.
- to just make base maximilian (without libs [fft etc]) use ‘make maxi’
File structure:
......@@ -11,6 +12,9 @@ src: Contains all files (.cpp/.js) for use with emscripten.
- cpp/* : all maximilian files and emscripten bindings
- js/maxi_webAudio.js : some stuff for interacting with AudioContext and loading files (plus some other bits) which is appended to the end of emscripten’s output automatically.
web: files for the js implementation of maximilian. maxiLib.js is the output from emscripten.
maxiLib: files for the js implementation of maximilian.
- maxiLib.js is the output from emscripten.
- libs will contain all extra maximilian libraries when completed.
old stuff : the initial files from the beginning. Not of much use anymore.
old stuff : the initial files from the beginning. Not of much use anymore.
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/*
* maximilian
* platform independent synthesis library using portaudio or rtaudio
*
* Created by Mick Grierson on 29/12/2009.
* Copyright 2009 Mick Grierson & Strangeloop Limited. All rights reserved.
* Thanks to the Goldsmiths Creative Computing Team.
* Special thanks to Arturo Castro for the PortAudio implementation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef _FFT
#define _FFT
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifdef __APPLE_CC__
#include <Accelerate/Accelerate.h>
#endif
class fft {
public:
fft(int fftSize);
~fft();
int n; //fftSize
int half; //halfFFTSize
float *in_real, *out_real, *in_img, *out_img;
#ifdef __APPLE_CC__
int log2n; //log2(n);
FFTSetup setupReal;
COMPLEX_SPLIT A;
float *polar;
void powerSpectrum_vdsp(int start, float *data, float *window, float *magnitude,float *phase);
void inversePowerSpectrum_vdsp(int start, float *finalOut, float *window, float *magnitude,float *phase);
void convToDB_vdsp(float *in, float *out);
#endif
/* Calculate the power spectrum */
void powerSpectrum(int start, float *data, float *window, float *magnitude, float *phase);
/* ... the inverse */
void inversePowerSpectrum(int start, float *finalOut, float *window, float *magnitude,float *phase);
void convToDB(float *in, float *out);
static void genWindow(int whichFunction, int NumSamples, float *window);
};
#endif
......@@ -331,5 +331,6 @@ EMSCRIPTEN_BINDINGS(my_module) {
.property("tick", &maxiClock::getTick, &maxiClock::setTick)
;
};
#endif
......@@ -45,7 +45,6 @@
#include <vector>
#ifdef _WIN32 //|| _WIN64
#include <algorithm>
#endif
using namespace std;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment