diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..88fb1bd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,32 @@ +# -*-cmake-*- +# Author: Kent Williams kwilliams@leepfrog.com +# top-level CMakeLists.txt This implements the SuperBuild CMake pattern. +# +# When you run came using this directory as the source directory, it +# invokes this file, which then includes SuperBuild.cmake, which +# configures building all the prerequisites using the ExternalProject +# module, then the main application. +# +# During main application configuration CMake includes PageWiz.cmake, +# which configures the Leepfrog CGI build to use all the already-built +# prerequisites. + +cmake_minimum_required(VERSION 2.8) + +option(USE_SYSTEM_PREREQS "Only use system-installed prerequisite libraries" ON) + +# PaulStretch_SUPERBUILD determines whether to build the prerequisites +# (ON) or build the application (OFF) +option(PaulStretch_SUPERBUILD "Build PaulStretch and the project it depends on via SuperBuild.cmake" ON) +mark_as_advanced(PaulStretch_SUPERBUILD) + + +if(${PaulStretch_SUPERBUILD}) + project(SuperBuild_PaulStretch) + include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") + return() +else() + project(PaulStretch) + include("${CMAKE_CURRENT_SOURCE_DIR}/PaulStretch.cmake") + return() +endif() diff --git a/CMakeLists.txt.mxml b/CMakeLists.txt.mxml new file mode 100644 index 0000000..340354a --- /dev/null +++ b/CMakeLists.txt.mxml @@ -0,0 +1,26 @@ +PROJECT(mxml) +# this is my CMake build recipe for paulstretch, an audio application +# for extreme time stretching. +# Source is here: https://sourceforge.net/project/showfiles.php?group_id=164941 + +cmake_minimum_required(VERSION 2.8) + +include(CheckIncludeFiles) + +add_library(mxml STATIC + mxml-attr.c + mxml-entity.c + mxml-file.c + mxml-get.c + mxml-index.c + mxml-node.c + mxml-private.c + mxml-search.c + mxml-set.c + mxml-string.c + ) + +install(TARGETS mxml + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +install(FILES mxml.h DESTINATION include) \ No newline at end of file diff --git a/Control.cpp b/Control.cpp index 502b657..0e6b763 100644 --- a/Control.cpp +++ b/Control.cpp @@ -62,6 +62,7 @@ bool Control::set_input_filename(string filename,FILE_TYPE intype){ if (intype==FILE_VORBIS) ai=new VorbisInputS; if (intype==FILE_MP3) ai=new MP3InputS; if (intype==FILE_WAV) ai=new AInputS; + if (intype==FILE_FLAC) ai=new AInputS; if (!ai) return false; wavinfo.filename=filename; wavinfo.intype=intype; diff --git a/GUI.fl b/GUI.fl index febb297..d21a479 100644 --- a/GUI.fl +++ b/GUI.fl @@ -1,46 +1,46 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0110 -header_name {.h} +version 1.0110 +header_name {.h} code_name {.cxx} decl {//Copyright (c) Nasca Octavian Paul. Released under GNU General Public License version 2} {public -} +} -decl {\#include } {} +decl {\#include } {} decl {\#include } {public -} +} decl {\#include } {public -} +} decl {\#include } {public -} +} decl {\#include } {public -} +} decl {\#include } {public -} +} decl {\#include } {public -} +} -decl {\#include} {} +decl {\#include} {} -decl {\#include } {} +decl {\#include } {} -decl {\#include } {} +decl {\#include } {} -decl {\#include } {} +decl {\#include } {} decl {\#include "Control.h"} {public -} +} decl {\#include "FreeEditUI.h"} {public -} +} decl {\#include "version.h"} {public -} +} Function {hex4n(char c)} {return_type int } { @@ -49,7 +49,7 @@ if ((c>='0')&&(c<='9')) return (c-'0'); if ((c>='A')&&(c<='F')) return (c-'A')+10; return 0;} {} -} +} Function {unescape(std::string s)} {return_type {std::string} } { @@ -73,7 +73,7 @@ while (skcopy_label(control.get_input_filename_and_info().c_str()); @@ -140,7 +141,7 @@ render_percent_slider->activate(); cancel_render_button->activate(); //char defaultfile[FL_PATH_MAX]; //fl_filename_absolute(defaultfile,control.get_recommanded_output_filename().c_str()); -Fl_File_Chooser *fc=new Fl_File_Chooser(NULL,"Wave files (*.wav)\\tOgg Vorbis (*.ogg)",Fl_File_Chooser::CREATE,"Render to audio file..."); +Fl_File_Chooser *fc=new Fl_File_Chooser(NULL,"Wave files (*.wav)\\tOgg Vorbis (*.ogg)\\tFLAC (*.flac)",Fl_File_Chooser::CREATE,"Render to audio file..."); fc->preview(0); fc->filter_value(0); @@ -151,7 +152,7 @@ while (fc->visible()){ }; const char *newfile = fc->value(); - if (newfile != NULL) { + if (newfile != NULL) { if (file_exists(newfile)){ if (!fl_choice("The file exists. \\nOverwrite it?","No","Yes",NULL)) return; }; @@ -200,10 +201,10 @@ rendering=false;} {} } { MenuItem {} { label {Open audio file...} - callback {char *newfile = fl_file_chooser("Open Audio(ogg,wav,mp3) File?", NULL, NULL); + callback {char *newfile = fl_file_chooser("Open Audio(ogg,wav,mp3,flac) File?", NULL, NULL); if (newfile != NULL) { open_input_file(newfile); - + }; selection_pos1->value(0.0); selection_pos2->value(100.0); @@ -225,7 +226,7 @@ render();} if (newfile != NULL) { set_mode(STOP); control.stopplay(); - + if (!control.load_parameters(newfile)){ fl_alert("Error: Could not load parameter file:\\n%s",newfile); }; @@ -805,14 +806,14 @@ control.stopplay();} play_button->labelcolor(FL_BLACK); //mode_choice->activate(); break; - + case PLAY: play_button->labelcolor(FL_RED); //mode_choice->deactivate(); fftsize_slider->labelcolor(FL_BLACK); freeze_button->activate(); break; - + case FREEZE: if (control.is_freeze()) freeze_button->labelcolor(FL_GREEN); else freeze_button->labelcolor(FL_BLACK); @@ -836,7 +837,7 @@ resolution_box->copy_label(control.get_fftresolution_info().c_str()); bool may_render=false; if (infilename_output->label()!=NULL){ - if (strlen(infilename_output->label())!=0) + if (strlen(infilename_output->label())!=0) may_render=true; }; if (!rendering){//do not change the status of render button while rendering @@ -938,7 +939,7 @@ Fl::add_timeout(1.0/3.0,tick,v);//3 fps} {} decl {bool playing_for_button;} {} decl {bool rendering;} {} decl {bool eof_for_button;} {} -} +} Function {file_exists(const char *filename)} {return_type bool } { @@ -947,7 +948,7 @@ int i = stat ( filename, &buf ); // File exists if ( i == 0 ) return true; else return false;} {} -} +} Function {main(int argc, char *argv[])} {open return_type int } { @@ -970,4 +971,4 @@ Fl::run(); delete gui; return 0;} {} -} +} diff --git a/PaulStretch.cmake b/PaulStretch.cmake new file mode 100644 index 0000000..73deb84 --- /dev/null +++ b/PaulStretch.cmake @@ -0,0 +1,153 @@ +PROJECT(PaulStretch) +# this is my CMake build recipe for paulstretch, an audio application +# for extreme time stretching. +# Source is here: https://sourceforge.net/project/showfiles.php?group_id=164941 + +cmake_minimum_required(VERSION 2.8) + +if(LINUX) +set_directory_properties(PROPERTIES COMPILE_DEFINITIONS -DHAVE_JACK) +endif(LINUX) + +if(NOT USE_SYSTEM_PREREQS) +# +# paulstretch depends on numerous libraries that need to be built first. +# My strategy is to install them all in a single 'sandbox' directory, and +# reference them via EXTERNAL_LIB_PREFIX + +SET(EXTERNAL_LIB_PREFIX "" CACHE PATH + "Directory root to find lib and include of dependencies" + ) + +# +# fltk is installed in the sandbox but trying to use FindFLTK/UseFLTK +# seems to cause problems. Adding just this variable makes Fluid work +set(FLTK_FLUID_EXECUTABLE ${EXTERNAL_LIB_PREFIX}/bin/fluid) +include_directories(${EXTERNAL_LIB_PREFIX}/include) +link_directories(${EXTERNAL_LIB_PREFIX}/lib) +else(NOT USE_SYSTEM_PREREQS) + find_package(FLTK REQUIRED) +endif(NOT USE_SYSTEM_PREREQS) + +# +# GUI files built in fluid. +fltk_wrap_ui(paulstretch FreeEditUI.fl GUI.fl) +# +# some source nested in Input +set(Input_source + Input/AInputS.cpp + Input/AInputS.h + Input/InputS.h + Input/MP3InputS.cpp + Input/MP3InputS.h + Input/VorbisInputS.cpp + Input/VorbisInputS.h + ) +set(Output_source + Output/AOutputS.cpp + Output/VorbisOutputS.cpp + ) +# +# source for paulstretch +set (Source_files + BinauralBeats.cpp + Control.cpp + FreeEdit.cpp + JAaudiooutput.cpp + Mutex.cpp + PAaudiooutput.cpp + Player.cpp + ProcessedStretch.cpp + Stretch.cpp + Thread.cpp + XMLwrapper.cpp + globals.cpp + ${Input_source} + ${Output_source} + ${paulstretch_FLTK_UI_SRCS} + ) + +include_directories(${PaulStretch_SOURCE_DIR}) + +# +# on Apple, need to link to Carbon/Cocoa etc. Don't know the 'CMake Way' +# to get these frameworks linked in so punt. This is what fltk does for fluid. +IF(APPLE) + SET( FLTK_PLATFORM_DEPENDENT_LIBS + "-framework Carbon -framework Cocoa -framework ApplicationServices -lz") +ELSE(APPLE) + SET( FLTK_PLATFORM_DEPENDENT_LIBS + -lX11) +ENDIF(APPLE) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(EXTRA_LIBS rt asound pthread -ldl -lXrender -lXext -lXinerama -lXcursor -lXfixes -lXft -lXpm -lX11 -lz -lfontconfig) +endif() + +# +# the application. +add_executable(paulstretch MACOSX_BUNDLE + ${Source_files} + ) + +# +# all the dependencies +target_link_libraries(paulstretch audiofile + fftw3f vorbisenc vorbisfile vorbis ogg portaudio pthread + mad fltk fltk_forms fltk_gl fltk_images mxml + ${FLTK_PLATFORM_DEPENDENT_LIBS} + ${EXTRA_LIBS} + ) + +get_target_property(TARGET_EXEC_DIR paulstretch RUNTIME_OUTPUT_DIRECTORY) +set(TARGET_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin") + +set(DEFAULT_MODULE_SEARCH_PATH + "${TARGET_EXEC_DIR}/Modules") + +#-------------------------------------------------------------------------------- +# Now the installation stuff below +#-------------------------------------------------------------------------------- +SET(plugin_dest_dir bin) +SET(qtconf_dest_dir bin) +SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/paulstretch") +IF(APPLE) + SET(plugin_dest_dir paulstretch.app/Contents/MacOS) + SET(qtconf_dest_dir paulstretch.app/Contents/Resources) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/paulstretch.app") +ENDIF(APPLE) +IF(WIN32) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/paulstretch.exe") +ENDIF(WIN32) + +#-------------------------------------------------------------------------------- +# Install the paulstretch application, on Apple, the bundle is at the root of the +# install tree, and on other platforms it'll go into the bin directory. +INSTALL(TARGETS paulstretch + BUNDLE DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION bin COMPONENT Runtime + ) + +#-------------------------------------------------------------------------------- +# Use BundleUtilities to get all other dependencies for the application to work. +# It takes a bundle or executable along with possible plugins and inspects it +# for dependencies. If they are not system dependencies, they are copied. + +# directories to look for dependencies +SET(DIRS ${EXTERNAL_LIB_PREFIX}/lib ) +# Now the work of copying dependencies into the bundle/package +# The quotes are escaped and variables to use at install time have their $ escaped +# An alternative is the do a configure_file() on a script and use install(SCRIPT ...). +# Note that the image plugins depend on QtSvg and QtXml, and it got those copied +# over. +INSTALL(CODE " + include(BundleUtilities) + fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\") + " COMPONENT Runtime) + + +# To Create a package, one can run "cpack -G DragNDrop CPackConfig.cmake" on Mac OS X +# where CPackConfig.cmake is created by including CPack +# And then there's ways to customize this as well +set(CPACK_BINARY_DRAGNDROP ON) +include(CPack) diff --git a/RemoveFlags.cmake b/RemoveFlags.cmake new file mode 100644 index 0000000..2e50dfa --- /dev/null +++ b/RemoveFlags.cmake @@ -0,0 +1,5 @@ +file(READ ${fixfile} code) +string(REPLACE "-march=i486" "" code "${code}") +string(REPLACE "-fforce-mem" "" code "${code}") +string(REPLACE "-Werror" "" code "${code}") +file(WRITE ${fixfile} "${code}") diff --git a/SuperBuild.cmake b/SuperBuild.cmake new file mode 100644 index 0000000..7fa3dd1 --- /dev/null +++ b/SuperBuild.cmake @@ -0,0 +1,162 @@ +# requires CMake 2.8 +cmake_minimum_required(VERSION 2.8) +project(PaulStretch) +# +# Written by Kent Williams chaircrusher@gmail.com +# +# No rights reserved. No warranty for anything. + +include(ExternalProject) +# This new build recipe was prompted by the recent addition to CMake +# of the ExternalProject module. This addition makes for extremely concise +# recipes for downloading and installing libraries as needed. + +if(APPLE) +# need to do a 32-bit build because of FLTK needing Carbon +set(platform_flags -DCMAKE_OSX_ARCHITECTURES:STRING=i386 +-DCMAKE_C_FLAGS:STRING=-m32;-O2 +-DCMAKE_CXX_FLAGS:STRING=-m32;-O2) +endif() +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +set(platform_flags -DBUILD_SHARED_LIBS:BOOL=OFF) +set(extra_config_flags --disable-shared) +endif() + +if(NOT USE_SYSTEM_PREREQS) + ExternalProject_add(audiofile + GIT_REPOSITORY "https://github.com/mpruett/audiofile.git" + GIT_TAG "audiofile-0.2.7" + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./autogen.sh && ./configure + ${extra_config_flags} + --prefix=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + ) + + ExternalProject_add(fftw + URL "http://www.fftw.org/fftw-3.3.5.tar.gz" + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure + --prefix=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + --enable-threads + --enable-float + ) + + ExternalProject_add(fltk + URL "http://fltk.org/pub/fltk/1.3.4/fltk-1.3.4-1-source.tar.gz" + URL_MD5 d7fcd27ab928648e1a1366dd2e273970 + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure + --prefix=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + ) + + ExternalProject_add(libmad + URL "http://downloads.sourceforge.net/mad/libmad-0.15.1b.tar.gz" + URL_MD5 1be543bc30c56fb6bea1d7bf6a64e66c + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure + ${extra_config_flags} + --prefix=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + ) + + # simple script to handle find/replace in makefile + set(Script ${CMAKE_CURRENT_LIST_DIR}/RemoveFlags.cmake) + set(libmad_makefile + ${CMAKE_CURRENT_BINARY_DIR}/libmad-prefix/src/libmad/Makefile) + + ExternalProject_Add_Step(libmad fix_config_idiocy + COMMENT "Get rid of CFLAGS that are stupid" + DEPENDEES configure + DEPENDERS build + ALWAYS 1 + COMMAND ${CMAKE_COMMAND} -Dfixfile=${libmad_makefile} -P ${Script} + ) + + ExternalProject_add(libogg + URL "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz" + URL_MD5 0 + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure + ${extra_config_flags} + --prefix=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + ) + + ExternalProject_add(libvorbis + URL "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz" + URL_MD5 0 + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure + --prefix=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + ${extra_config_flags} + DEPENDS libogg + ) + + ExternalProject_add(portaudio + URL "http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz" + URL_MD5 4df8224e047529ca9ad42f0521bf81a8 + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure + ${extra_config_flags} + --prefix=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + ) + + set(portaudio_makefile + ${CMAKE_CURRENT_BINARY_DIR}/portaudio-prefix/src/portaudio/Makefile) + + ExternalProject_Add_Step(portaudio fix_config_idiocy + COMMENT "Get rid of CFLAGS that are stupid" + DEPENDEES configure + DEPENDERS build + ALWAYS 1 + COMMAND ${CMAKE_COMMAND} -Dfixfile=${portaudio_makefile} -P ${Script} + ) + + set(mxml_cmakelist ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.mxml) + set(mxml_target + ${CMAKE_CURRENT_BINARY_DIR}/mxml-prefix/src/mxml/CMakeLists.txt) + + set(mxml_config_src ${CMAKE_CURRENT_LIST_DIR}/config.h.mxml) + set(mxml_config_target + ${CMAKE_CURRENT_BINARY_DIR}/mxml-prefix/src/mxml/config.h) + + ExternalProject_add(mxml + URL "http://www.msweet.org/files/project3/mxml-2.10.tar.gz" + PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${mxml_cmakelist} ${mxml_target} + UPDATE_COMMAND "" + BUILD_IN_SOURCE 1 + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/Prereqs + ) + + ExternalProject_Add_Step(mxml make_config_h + COMMENT "Copy in config.h" + DEPENDEES configure + DEPENDERS build + ALWAYS 1 + COMMAND ${CMAKE_COMMAND} -E copy ${mxml_config_src} ${mxml_config_target} + ) + set(PREREQ_PREFIX -DEXTERNAL_LIB_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/Prereqs) + set(PAULSTRETCH_DEPENDENCIES DEPENDS audiofile fftw fltk libmad libogg libvorbis portaudio mxml) +endif(NOT USE_SYSTEM_PREREQS) + +ExternalProject_add(paulstretch +UPDATE_COMMAND "" +DOWNLOAD_COMMAND "" +INSTALL_COMMAND "" +SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} +BINARY_DIR PaulStretch-build +CMAKE_ARGS +-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} +-DUSE_SYSTEM_PREREQS:BOOL=${USE_SYSTEM_PREREQS} +${PREREQ_PREFIX} +-DCMAKE_BUILD_TYPE:STRING=Release +-DPaulStretch_SUPERBUILD:BOOLEAN=OFF +${platform_flags} +${PAULSTRETCH_DEPENDENCIES} +) diff --git a/config.h.mxml b/config.h.mxml new file mode 100644 index 0000000..1f59ba3 --- /dev/null +++ b/config.h.mxml @@ -0,0 +1,96 @@ +/* config.h. Generated from config.h.in by configure. */ +/* + * "$Id: config.h.in 408 2010-09-19 05:26:46Z mike $" + * + * Configuration file for Mini-XML, a small XML-like file parsing library. + * + * Copyright 2003-2010 by Michael R Sweet. + * + * These coded instructions, statements, and computer programs are the + * property of Michael R Sweet and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "COPYING" + * which should have been included with this file. If this file is + * missing or damaged, see the license at: + * + * http://www.minixml.org/ + */ + +/* + * Include necessary headers... + */ + +#include +#include +#include +#include +#include + + +/* + * Version number... + */ + +#define MXML_VERSION "Mini-XML v2.7" + + +/* + * Inline function support... + */ + +#define inline + + +/* + * Long long support... + */ + +#define HAVE_LONG_LONG 1 + + +/* + * Do we have the snprintf() and vsnprintf() functions? + */ + +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 + + +/* + * Do we have the strXXX() functions? + */ + +#define HAVE_STRDUP 1 + + +/* + * Do we have threading support? + */ + +#define HAVE_PTHREAD_H 1 + + +/* + * Define prototypes for string functions as needed... + */ + +# ifndef HAVE_STRDUP +extern char *_mxml_strdup(const char *); +# define strdup _mxml_strdup +# endif /* !HAVE_STRDUP */ + +extern char *_mxml_strdupf(const char *, ...); +extern char *_mxml_vstrdupf(const char *, va_list); + +# ifndef HAVE_SNPRINTF +extern int _mxml_snprintf(char *, size_t, const char *, ...); +# define snprintf _mxml_snprintf +# endif /* !HAVE_SNPRINTF */ + +# ifndef HAVE_VSNPRINTF +extern int _mxml_vsnprintf(char *, size_t, const char *, va_list); +# define vsnprintf _mxml_vsnprintf +# endif /* !HAVE_VSNPRINTF */ + +/* + * End of "$Id: config.h.in 408 2010-09-19 05:26:46Z mike $". + */ diff --git a/globals.h b/globals.h index c03042e..3f3e219 100644 --- a/globals.h +++ b/globals.h @@ -29,7 +29,7 @@ void sleep(int ms); #define ZERO(data,size) {char *data_=(char *) data;for (int i=0;i