// =========================================================================== // W space: Multi star - fractal sound creation tool // (CC) 2009 Jens Koeplinger // http://www.jenskoeplinger.com/ // // Reference: J. A. Shuster and J. Koeplinger, // "Elliptic complex numbers with dual multiplication." // http://www.jenskoeplinger.com/P/PaperShusterKoepl_WSpace.pdf // // License: Creative Commons Attribution "Share Alike 3.0 Unported" // http://creativecommons.org/licenses/by-sa/3.0 // // You are free: // - to Share - to copy, distribute and transmit the work // - to Remix - to adapt the work // // Under the following conditions: // - Attribution. You must attribute the work in the manner specified by the // author or licensor (but not in any way that suggests that they endorse // you or your use of the work). // - Share Alike. If you alter, transform, or build upon this work, you may // distribute the resulting work only under the same, similar or a compatible // license. // // For any reuse or distribution, you must make clear to others the license // terms of this work. The best way to do this is with a link to: // http://creativecommons.org/licenses/by-sa/3.0 // // Any of the above conditions can be waived if you get permission from the // copyright holder. // // Nothing in this license impairs or restricts the author's moral rights. // =========================================================================== #define WspaceToolVersion "W space - Multi star fractal sound, version 0.0.5 (1 January 2009)\n" #define licenseMain "(CC) 2009 Jens Koeplinger - http://www.jenskoeplinger.com/P\n" #define licenseDetail "License: Creative Commons Attribution - Share Alike 3.0 Unported\n" #define licenseReference "http://creativecommons.org/licenses/by-sa/3.0\n\n" #define outFileName "multistar.wav" #define maxWaveBins 20000 #define PI 3.141592653589793116 #define thresholdDepth 25 #include #include #include // --------------------------------------------------------------------------- // global declarations - functions // --------------------------------------------------------------------------- // lib-multistar-recursion.h double squareRecursive(double, double, int, int); double calculateRadius(double, double, double); // lib-multistar-util.h void writeTwoByteInteger(FILE *, int); void writeFourByteInteger(FILE *, int); void writeOutputWaveFileHeader(void); void closeOutputWaveFile(void); // lib-multistar-sweep.h int calculateTotalDataLength(void); void calculateSweep(void); void calculateTestSweep(void); void calculateFractalSweep(void); // --------------------------------------------------------------------------- // global declarations - variables // --------------------------------------------------------------------------- // output wave file variables FILE *fp; // output wave file pointer int totalDataLength; // e.g. 20 seconds 16 bit stereo at 44.1kHz = 3528000 int outputMode; // 0=multi star (default); 1,2,3 = test (sine, saw, square) // multi-star fractal (sweep) global parameters double baseFrequency; // base frequency, in Herz ( s^(-1) ) double convergencePercentage; // convergence percentage of the outline to be played double totalLength; // total length of the WAV file, in seconds double convergenceSweepTo; // 2nd (target) convergence percentage (for sweep) int isSweep; // 0 if no sweep; otherwise this is a sweep double sweepStepWidth; // if not zero, this is the step width in convergence percentages) int isContinuous; // 0 if stepped sweep, otherwise continuous double amplitudeMultiplier; // 1. (full amplitude) or lower double amplitudeSweepTo; // 2nd (target) amplitude multiplier // if test output is selected, test variables: double testFLeft; // frequency of the left channel double testFRight; double testLength; // length of the sample in seconds double testAmplitude; // amplitude of the sample (0..32766) // --------------------------------------------------------------------------- // main() // --------------------------------------------------------------------------- int main(int argc, char **argv) { int i; // throwaway printf(WspaceToolVersion); printf(licenseMain); printf(licenseDetail); printf(licenseReference); printf("For HELP, run without command-line parameters.\n"); printf("\nFor documentation on the multi-star fractal, see:\n"); printf(" APPENDIX A, in\n"); printf(" J. A. Shuster and J. Koeplinger,\n"); printf(" \"Elliptic complex numbers with dual multiplication.\n"); printf(" http://www.jenskoeplinger.com/P/PaperShusterKoepl_WSpace.pdf\n\n"); // read command line parameters: #include "run-wspacemultistarsound.c" // arguments are parsed // => open the file totalDataLength = calculateTotalDataLength(); printf("Total data length: %d\n", totalDataLength); writeOutputWaveFileHeader(); // do it! calculateSweep(); // done. closeOutputWaveFile(); printf("Good-bye\n"); } // --------------------------------------------------------------------------- #include "lib-multistar-recursion.h" #include "lib-multistar-util.h" #include "lib-multistar-sweep.h" // ---------------------------------------------------------------------------