din-51.1.1/0000775000175000017500000000000014073336001007351 500000000000000din-51.1.1/NEWS0000664000175000017500000000055513351024044007774 00000000000000din is noise was the Pixelache Software of the year 2012. http://www.pixelache.ac/helsinki/2011/piksel11-pixelache-sotfware-of-the-year-2012/ and that was version 5.2.1, 6 years ago! Please visit http://dinisnoise.org/fundin to fund the development of DIN Is Noise. Thank you to all the funders for making the release of DIN Is Noise as free software possible. din-51.1.1/g-jack0000775000175000017500000000007013351024045010350 00000000000000./configure CXXFLAGS="-g -D __LINUX_ALSA__" CFLAGS="-g" din-51.1.1/acconfig.h0000664000175000017500000000047413351024044011217 00000000000000#undef ENABLE_NLS #undef HAVE_CATGETS #undef HAVE_GETTEXT #undef HAVE_LC_MESSAGES #undef HAVE_STPCPY #undef HAVE_LIBSM #undef PACKAGE_LOCALE_DIR #undef PACKAGE_DOC_DIR #undef PACKAGE_DATA_DIR #undef PACKAGE_PIXMAPS_DIR #undef PACKAGE_HELP_DIR #undef PACKAGE_MENU_DIR #undef PACKAGE_SOURCE_DIR #undef GETTEXT_PACKAGE din-51.1.1/mkinstalldirs0000755000175000017500000000672214073335615012116 00000000000000#! /bin/sh # mkinstalldirs --- make directory hierarchy scriptversion=2009-04-28.21; # UTC # Original author: Noah Friedman # Created: 1993-05-16 # Public domain. # # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' IFS=" "" $nl" errstatus=0 dirmode= usage="\ Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... Create each directory DIR (with mode MODE, if specified), including all leading file name components. Report bugs to ." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" exit $? ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --version) echo "$0 $scriptversion" exit $? ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and # mkdir -p a/c at the same time, both will detect that a is missing, # one will create a, then the other will try to create a and die with # a "File exists" error. This is a problem when calling mkinstalldirs # from a parallel make. We use --version in the probe to restrict # ourselves to GNU mkdir, which is thread-safe. case $dirmode in '') if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" else # On NextStep and OpenStep, the 'mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because '.' already # exists. test -d ./-p && rmdir ./-p test -d ./--version && rmdir ./--version fi ;; *) if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" else # Clean up after NextStep and OpenStep mkdir. for d in ./-m ./-p ./--version "./$dirmode"; do test -d $d && rmdir $d done fi ;; esac for file do case $file in /*) pathcomp=/ ;; *) pathcomp= ;; esac oIFS=$IFS IFS=/ set fnord $file shift IFS=$oIFS for d do test "x$d" = x && continue pathcomp=$pathcomp$d case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr= chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp=$pathcomp/ done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: din-51.1.1/README0000664000175000017500000000401414022060210010136 00000000000000DIN Is Noise Copyright (c) 2006-2021 Jagannathan Sampath Please visit https://dinisnoise.org for more information. DIN Is Noise is released under GPL 2.0 license. See the file COPYING for more information. DIN Is Noise is Free Software. To keep DIN Is Noise as Free Software, please fund the development at: https://dinisnoise.org/fundin/ In this regard, I would like to thank Mr Bernt M. Winness from Norway for his Christmas 2020 gift of USD 500 that helped me develop DIN Is Noise 50. To build DIN Is Noise for 64-bit GNU/Linux, First, you must install these libraries: a. OpenGL (-lGL) b. SDL (-lSDL) c. TCL (-ltcl8.6) d. Boost e. ALSA (-lasound) OR e. JACK (-ljack) To build for the first time type these commands in a shell, a. autoreconf -fvi b. ./configure CXXFLAGS="-O3 -D__LINUX_ALSA__" CFLAGS=-O3 If you want JACK support instead of ALSA then: b. ./configure CXXFLAGS="-O3 -D__UNIX_JACK__" CFLAGS=-O3 LIBS=-ljack c. make d. sudo make install e. !! ATTENTION !! if you are using ALSA, make sure no other program is playing audio. if you are using JACK, make sure JACK server is running before starting DIN. f. on a shell, type din and press enter. If you have built DIN Is Noise before: a. sudo make uninstall b. rm -rf ~/.din Now follow the steps for building DIN Is Noise for the first time. *********************************************************************** * Please do not use this source code to build and distribute binaries * * for Microsoft Windows or Apple Mac OS X as I sell licenses for * * using those binaries at https://dinisnoise.org/buy to try and * * support myself. Please consider funding my independent work on DIN * * Is Noise at https://dinisnoise.org/fundin * *********************************************************************** Hope you enjoy DIN Is Noise. If you can package DIN Is Noise for various GNU/Linux distributions or other Unices, please e-mail me. Jagannathan Sampath [jag@dinisnoise.org] Chennai, India. din-51.1.1/compile0000755000175000017500000001624514073335615010667 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2014 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: din-51.1.1/src/0000775000175000017500000000000014073335777010163 500000000000000din-51.1.1/src/kiss_fft.c0000664000175000017500000003056413351024045012044 00000000000000/* Copyright (c) 2003-2010, Mark Borgerding All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "_kiss_fft_guts.h" /* The guts header contains all the multiplication and addition macros that are defined for fixed or floating point complex numbers. It also delares the kf_ internal functions. */ static void kf_bfly2( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, int m ) { kiss_fft_cpx * Fout2; kiss_fft_cpx * tw1 = st->twiddles; kiss_fft_cpx t; Fout2 = Fout + m; do{ C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); C_MUL (t, *Fout2 , *tw1); tw1 += fstride; C_SUB( *Fout2 , *Fout , t ); C_ADDTO( *Fout , t ); ++Fout2; ++Fout; }while (--m); } static void kf_bfly4( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, const size_t m ) { kiss_fft_cpx *tw1,*tw2,*tw3; kiss_fft_cpx scratch[6]; size_t k=m; const size_t m2=2*m; const size_t m3=3*m; tw3 = tw2 = tw1 = st->twiddles; do { C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4); C_MUL(scratch[0],Fout[m] , *tw1 ); C_MUL(scratch[1],Fout[m2] , *tw2 ); C_MUL(scratch[2],Fout[m3] , *tw3 ); C_SUB( scratch[5] , *Fout, scratch[1] ); C_ADDTO(*Fout, scratch[1]); C_ADD( scratch[3] , scratch[0] , scratch[2] ); C_SUB( scratch[4] , scratch[0] , scratch[2] ); C_SUB( Fout[m2], *Fout, scratch[3] ); tw1 += fstride; tw2 += fstride*2; tw3 += fstride*3; C_ADDTO( *Fout , scratch[3] ); if(st->inverse) { Fout[m].r = scratch[5].r - scratch[4].i; Fout[m].i = scratch[5].i + scratch[4].r; Fout[m3].r = scratch[5].r + scratch[4].i; Fout[m3].i = scratch[5].i - scratch[4].r; }else{ Fout[m].r = scratch[5].r + scratch[4].i; Fout[m].i = scratch[5].i - scratch[4].r; Fout[m3].r = scratch[5].r - scratch[4].i; Fout[m3].i = scratch[5].i + scratch[4].r; } ++Fout; }while(--k); } static void kf_bfly3( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, size_t m ) { size_t k=m; const size_t m2 = 2*m; kiss_fft_cpx *tw1,*tw2; kiss_fft_cpx scratch[5]; kiss_fft_cpx epi3; epi3 = st->twiddles[fstride*m]; tw1=tw2=st->twiddles; do{ C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); C_MUL(scratch[1],Fout[m] , *tw1); C_MUL(scratch[2],Fout[m2] , *tw2); C_ADD(scratch[3],scratch[1],scratch[2]); C_SUB(scratch[0],scratch[1],scratch[2]); tw1 += fstride; tw2 += fstride*2; Fout[m].r = Fout->r - HALF_OF(scratch[3].r); Fout[m].i = Fout->i - HALF_OF(scratch[3].i); C_MULBYSCALAR( scratch[0] , epi3.i ); C_ADDTO(*Fout,scratch[3]); Fout[m2].r = Fout[m].r + scratch[0].i; Fout[m2].i = Fout[m].i - scratch[0].r; Fout[m].r -= scratch[0].i; Fout[m].i += scratch[0].r; ++Fout; }while(--k); } static void kf_bfly5( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, int m ) { kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; int u; kiss_fft_cpx scratch[13]; kiss_fft_cpx * twiddles = st->twiddles; kiss_fft_cpx *tw; kiss_fft_cpx ya,yb; ya = twiddles[fstride*m]; yb = twiddles[fstride*2*m]; Fout0=Fout; Fout1=Fout0+m; Fout2=Fout0+2*m; Fout3=Fout0+3*m; Fout4=Fout0+4*m; tw=st->twiddles; for ( u=0; ur += scratch[7].r + scratch[8].r; Fout0->i += scratch[7].i + scratch[8].i; scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); C_SUB(*Fout1,scratch[5],scratch[6]); C_ADD(*Fout4,scratch[5],scratch[6]); scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); C_ADD(*Fout2,scratch[11],scratch[12]); C_SUB(*Fout3,scratch[11],scratch[12]); ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; } } /* perform the butterfly for one stage of a mixed radix FFT */ static void kf_bfly_generic( kiss_fft_cpx * Fout, const size_t fstride, const kiss_fft_cfg st, int m, int p ) { int u,k,q1,q; kiss_fft_cpx * twiddles = st->twiddles; kiss_fft_cpx t; int Norig = st->nfft; kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p); for ( u=0; u=Norig) twidx-=Norig; C_MUL(t,scratch[q] , twiddles[twidx] ); C_ADDTO( Fout[ k ] ,t); } k += m; } } KISS_FFT_TMP_FREE(scratch); } static void kf_work( kiss_fft_cpx * Fout, const kiss_fft_cpx * f, const size_t fstride, int in_stride, int * factors, const kiss_fft_cfg st ) { kiss_fft_cpx * Fout_beg=Fout; const int p=*factors++; /* the radix */ const int m=*factors++; /* stage's fft length/p */ const kiss_fft_cpx * Fout_end = Fout + p*m; #ifdef _OPENMP // use openmp extensions at the // top-level (not recursive) if (fstride==1 && p<=5) { int k; // execute the p different work units in different threads # pragma omp parallel for for (k=0;k floor_sqrt) p = n; /* no more factors, skip to end */ } n /= p; *facbuf++ = p; *facbuf++ = n; } while (n > 1); } /* * * User-callable function to allocate all necessary storage space for the fft. * * The return value is a contiguous block of memory, allocated with malloc. As such, * It can be freed with free(), rather than a kiss_fft-specific function. * */ kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) { kiss_fft_cfg st=NULL; size_t memneeded = sizeof(struct kiss_fft_state) + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ if ( lenmem==NULL ) { st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); }else{ if (mem != NULL && *lenmem >= memneeded) st = (kiss_fft_cfg)mem; *lenmem = memneeded; } if (st) { int i; st->nfft=nfft; st->inverse = inverse_fft; for (i=0;iinverse) phase *= -1; kf_cexp(st->twiddles+i, phase ); } kf_factor(nfft,st->factors); } return st; } void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) { if (fin == fout) { //NOTE: this is not really an in-place FFT algorithm. //It just performs an out-of-place FFT into a temp buffer kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft); kf_work(tmpbuf,fin,1,in_stride, st->factors,st); memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); KISS_FFT_TMP_FREE(tmpbuf); }else{ kf_work( fout, fin, 1,in_stride, st->factors,st ); } } void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) { kiss_fft_stride(cfg,fin,fout,1); } void kiss_fft_cleanup(void) { // nothing needed any more } int kiss_fft_next_fast_size(int n) { while(1) { int m=n; while ( (m%2) == 0 ) m/=2; while ( (m%3) == 0 ) m/=3; while ( (m%5) == 0 ) m/=5; if (m<=1) break; /* n is completely factorable by twos, threes, and fives */ n++; } return n; } din-51.1.1/src/range.h0000664000175000017500000000275214022054646011341 00000000000000/* * range.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __range__ #define __range__ #include "box.h" #include "note.h" #include "color.h" #include "modulator.h" #include #include #include struct scale_info; struct range { // // microtonal range // from one note to another (both included). box extents; note notes[2]; // end notes std::string intervals[2]; // interval names of end notes (see *.tuning files) void change_note (int i, int j, scale_info& si); int octave; void change_octave (int i, int o, scale_info& si); float delta_step; // difference of step values ie pitch/frequency of the end notes (see note.h) void calc (scale_info& si); void calc_note_freq (int i, scale_info& si); void draw_labels (int label_what = LEFT, int show_frequency = 0); enum {NONE = -1, LEFT, RIGHT, CENTER, BOTH}; // for opengl int pts [8]; // modulation int fixed; // whats fixed? left, right or center modulator mod; // fm => width, am => height void init_mod (); range (); void change_height (int dh); void sample_rate_changed (); inline float hz_per_pix () { float delta_hz = fabs(notes[1].hz - notes[0].hz); return (delta_hz * 1.0f / extents.width); } void print_hz_per_pixel (); }; void print_range_info (range& ri); #endif din-51.1.1/src/delay.h0000664000175000017500000000167614022054642011343 00000000000000/* * delay.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __delay #define __delay #include "multi_curve.h" #include "solver.h" #include "listeners.h" struct delay { // 1 channel delay int nsamples; float* samples; float* fbk; float* vol; int id; float msecs; // delay time // feedback and volume are beziers solved into fbk and vol std::string fbk_fname, vol_fname; multi_curve fbk_crv, vol_crv; delay_listener fbk_lis, vol_lis; solver fbk_sol, vol_sol; delay (float t, const std::string& fn, const std::string& vn); ~delay (); void zero (); void prep_buffer (); void operator() (float* out, int nz, float fdr); void set (float t); void get (float& t); void setup (); }; extern delay left_delay, right_delay; #endif din-51.1.1/src/curve.h0000664000175000017500000000444414022054642011365 00000000000000/* * curve.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __CURVE__ #define __CURVE__ #include #include #include "crvpt.h" #include "point.h" struct curve { float x0, y0, x1, y1; // start/end points float tx0, ty0, tx1, ty1; // start/end tangents float ptx0, pty0; // start point to tangent vector float ptx1, pty1; // end point to tangent vector std::vector vpts; // bezier curve points for draw & solve std::vector dpts; // shapeform points (see multi_curve.h/cc) curve (); curve (float x0, float y0, float x1, float y1, float tx0, float ty0, float tx1, float ty1, float d = 0); /* * din generates points on the bezier curve using recursive subdivision: * * find midpoint of line joining end points * if distance between midpoint on this line and point on the bezier curve > limit * insert point and repeat else stop */ float limit2; // square of limit distance void set_limit (float l); // evaluation generates points of the curve // enum {EVAL_COMPLETE, EVAL_REQUIRED}; int eval_state; inline int eval_required () {return eval_state == EVAL_REQUIRED;} void eval (int find_length = 0); inline void vertex (int i, float xv, float yv) { if (i) { x1 = xv; y1 = yv; ptx1 = tx1 - x1; pty1 = ty1 - y1; } else { x0 = xv; y0 = yv; ptx0 = tx0 - x0; pty0 = ty0 - y0; } eval_state = EVAL_REQUIRED; } inline void get_vertex (int i, float& xv, float& yv) { if (i) { xv = x1; yv = y1; } else { xv = x0; yv = y0; } } inline void tangent (int i, float xt, float yt) { if (i) { tx1 = xt; ty1 = yt; ptx1 = tx1 - x1; pty1 = ty1 - y1; } else { tx0 = xt; ty0 = yt; ptx0 = tx0 - x0; pty0 = ty0 - y0; } eval_state = EVAL_REQUIRED; } inline void get_tangent (int i, float& xt, float& yt) { if (i) { xt = tx1; yt = ty1; } else { xt = tx0; yt = ty0; } } float length; float calc_length (); void normalise_length (float& now_length, float total_length); void calc_slope (crvpt& p, crvpt& q); }; #endif din-51.1.1/src/modulator.cc0000664000175000017500000000540214067423165012411 00000000000000/* * modulator.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "multi_curve.h" #include "modulator.h" #include "audio.h" #include "chrono.h" #include "drone.h" #include "console.h" extern float TWO_PI; extern const char spc; mod_params::mod_params (multi_curve* c, int i, point& p, const std::string& n) { setdir (i, &p.x, &p.y); bv.name = n; bv.crv = c; bv.setup (); depth = result = initial = 0; t = ui_clk (); } void mod_params::clear () { depth = 0; result = 0; initial = 0; bv.set_bpm (bv.bpm); } void mod_params::calc () { double t1 = ui_clk (); double dt = t1 - t; t = t1; bv.delta = dt * bv.bps; result = depth * bv.sol (bv.now, bv.delta); if (autorot.yes) autorot.calc (dt); } void mod_params::calcdir (drone& dd) { float* px [] = {&vertical.x, &horizontal.x, &dd.vx, &dd.ax}; float* py [] = {&vertical.y, &horizontal.y, &dd.vy, &dd.ay}; dirx = px[id]; diry = py[id]; } void autorotator::set_rpm (float r) { if (r > 0) { rpm = r; angle.persec = TWO_PI * r / 60.0f; } else { rpm = 0; angle.persec = 0.0f; } } void autorotator::chgdeg (float d) { setdeg (deg + d); } void autorotator::chgtps (float t) { settps (tps + t); setdeg (deg); } void autorotator::calc (float dt) { if (movement == SMOOTH) angle.theta = dt * angle.persec; else { if (tik (ui_clk())) angle.theta = tik.triggert * angle.persec; else angle.theta = 0.0f; } if (autoflip.yes) autoflip.calc (angle.theta, dir); angle.theta *= dir; } void autoflipt::calc (float theta, int& dir) { total += theta; if (total > angle.rad) { dir = -dir; total = 0.0f; } } void autoflipt::set (float d) { angle = d; } autoflipt::autoflipt () : angle (90) { yes = 0; total = 0.0f; } using namespace std; istream& operator>> (istream& file, autorotator& ar) { file >> ar.yes >> ar.dir >> ar.rpm >> ar.movement >> ar.deg >> ar.tps >> ar.autoflip; if (ar.movement == autorotator::SMOOTH) ar.set_rpm (ar.rpm); else { ar.setdeg (ar.deg); ar.settps (ar.tps); } return file; } ostream& operator<< (ostream& file, autorotator& ar) { file << ar.yes << spc << ar.dir << spc << ar.rpm << spc << ar.movement << spc << ar.deg << spc << ar.tps << spc << ar.autoflip; return file; } istream& operator>> (istream& file, autoflipt& af) { float d; file >> af.yes >> d >> af.total; af.angle = d; return file; } ostream& operator<< (ostream& file, autoflipt& af) { file << af.yes << spc << af.angle.deg << spc << af.total; return file; } din-51.1.1/src/textboard.h0000664000175000017500000000264514022053525012235 00000000000000/* * textboard.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * For more information, please visit http://dinisnoise.org/ */ #ifndef __textboard #define __textboard #include #include #include #include "ui.h" struct text { std::string txt; // actual text // hline - label on horizontal line, vline = label on vertical line enum {hline=0, vline=1, normal}; int type; enum {permanent, temporary}; int state; float r, g, b; // color float wx, wy; // window co-ords int vx, vy; // view co-ords text ( const std::string& t, float xx = 0, float yy = 0, float rr=0.25, float gg=0.25, float bb=0.25, int s = text::temporary, int y = text::normal, float vxx = 0, float vyy = 0) : txt(t), type (y) , state (s), r(rr), g(gg), b(bb), wx(xx), wy(yy), vx(vxx), vy(vyy) {} bool operator== (const text& t) {return txt == t.txt;} }; struct basic_editor; struct mondrian; struct textboard { std::list texts; void draw (int shapeform = 0); void draw_line (int x1, int y1, int x2, int y2); void add (const text& t) { texts.push_back (t);} void clear (); void refresh (basic_editor* b, float dwx = 0, float dwy = 0, float dvx = 0, float dvy = 0); void refresh (mondrian* m); void load (std::ifstream& file); void save (std::ofstream& file); }; #endif din-51.1.1/src/alarm.h0000664000175000017500000000074114066010047011330 00000000000000/* * alarm.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __ALARM__ #define __ALARM__ struct alarm_t { double triggert; double startt; double nowt; double elapsed; int active; alarm_t (double tt = 1.0); int operator() (double t); double operator() (); void start (); void stop (); }; #endif din-51.1.1/src/plugin.cc0000664000175000017500000000567714035636615011720 00000000000000/* * plugin.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "plugin.h" #include "curve_editor.h" #include "vector2d.h" #include "ui_list.h" #include "field.h" #include "viewwin.h" #include "console.h" #include "log.h" #include #include using namespace std; plugin::plugin () { name = "from_plugin"; ss.str (name); num_ctrls = 0; shapeform = 1; pts = 0; pts_n = 0; mix = 1; undo = 1; ed = 0; npts = 0; } void plugin::setup () { num_ctrls = 2; ctrls.resize (num_ctrls); ctrls[0] = &cb_auto_apply; ctrls[1] = &b_apply; b_apply.set_text ("Apply"); cb_auto_apply.set_text ("Auto apply"); b_apply.set_listener (this); cb_auto_apply.set_listener (this); b_apply.click_repeat = 1; ss.precision (10); } void plugin::update () { for (int i = 0; i < num_ctrls; ++i) ctrls[i]->update (); } int plugin::handle_input () { int r = 0; if (!_folded) for (int i = 0; i < num_ctrls; ++i) r |= ctrls[i]->handle_input (); return r; } void plugin::draw () { if (!_folded) for (int i = 0; i < num_ctrls; ++i) ctrls[i]->draw (); } void plugin::clicked (button& b) { uis.crved->apply_plugin (this); } void plugin::changed (field& f) { do_render (); } void plugin::changed (checkbutton& cb) { if (&cb == &cb_auto_apply) { if (cb.state) { uis.crved->apply_plugin (this); mix = undo = 0; } else mix = undo = 1; } } void plugin::try_auto_apply () { //if (cb_auto_apply.state) uis.crved->apply_plugin (this); if (cb_auto_apply.state) ed->apply_plugin (this); } void plugin::try_auto_apply (curve_editor* ed) { if (cb_auto_apply.state) ed->apply_plugin (this); } void plugin::unfold () { for (int i = 0, j = num_ctrls; i < j; ++i) ctrls[i]->show (); _folded = 0; } void plugin::fold () { for (int i = 0, j = num_ctrls; i < j; ++i) ctrls[i]->hide (); _folded = 1; } void plugin::draw (curve_editor* ed) { glColor3f (clr.r, clr.g, clr.b); glVertexPointer (2, GL_FLOAT, 0, pts); glDrawArrays (GL_LINE_STRIP, 0, npts); } plugin::~plugin () { if (pts) delete[] pts; } string plugin::make_fname () { extern string user_data_dir; return (user_data_dir + "p_" + name); } void plugin::gen_pts () { if (ed) { npts = points.size (); if (pts_n < npts) { if (pts) delete[] pts; pts_n = npts; pts = new float [2 * pts_n]; } float wx, wy; for (int i = 0, k = 0; i < npts; ++i) { point& p = points[i]; ed->obj2win (p.x, p.y, wx, wy); pts[k++] = wx; pts[k++] = wy; } } } void plugin::set_ed (curve_editor* e) { ed = e; gen_pts (); } void plugin::do_render () { render (); try_auto_apply (); } void plugin::do_render (curve_editor* ed) { render (); try_auto_apply (ed); } din-51.1.1/src/gravity.h0000664000175000017500000000317514061004425011723 00000000000000/* * gravity.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __GRAVITY #define __GRAVITY #include "widget.h" #include "arrow_button.h" #include "checkbutton.h" #include "spinner.h" #include "point.h" #include "mouse_slider.h" struct drone; struct gravity_t : widget, click_listener, mouse_slider_listener { arrow_button fold; button zero, reset; arrow_button left, right, up, down; checkbutton mouse, dron, keepsize; button changesize; MAKE_STATE_LISTENER (mousel, ml) int handlesize; point base; point tip; point base2tip, base2tip_ms; point p_base2tip; point bottomleft, topright; point textpos; int hitt; enum {NEXT_TO_NOTHING = -1, NOTHING, BASE, TIP}; int hit (const point& p, int mx, int my); int lmb_clicked; float strength; float gx, gy; drone* tracked_drone; int forcetrack; void track (int vx, int vy); double mag0, mag; int keep_size; int maos; int dronn; gravity_t (); void load (std::ifstream& file); void save (std::ofstream& file); int handle_input (); void set (point& p, int mx, int my, int calc_mag = 1); void calc (int calc_mag = 1); void calcui (); void preset (int id); void doreset (int keep_size = 0); int stop_editing (); int gl_base [8]; float gl_arrow[12]; void draw (); void clicked (button& b); void moused (int dir, double scl); int unfolded (); }; #endif din-51.1.1/src/recorder.cc0000664000175000017500000001263614022054461012205 00000000000000/* * recorder.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "main.h" #include "recorder.h" #include "wav.h" #include "audio.h" #include "checkbutton.h" #include "chrono.h" #include "label.h" #include "console.h" #include "ui_list.h" #include "menu.h" #ifdef __WINDOWS_DS__ #include #include #include #include #endif #include #include #include using namespace std; extern ofstream dlog; extern char BUFFER []; recorder::recorder () : fname ("din.wav") { buffer_size = 0; saved = 1; samples_buffer = 0; stop_rec = stop_mins = stop_secs = 0; } void recorder::add (float* sample_buffer, int sample_buffer_size, int num_samples, checkbutton& cb_record1, checkbutton& cb_record2) { if (saving_started) return; float* recbuf = new float [num_samples]; if (recbuf == 0) { cons << console::red << "Recorder ran out of memory!" << eol; return; } memcpy (recbuf, sample_buffer, sample_buffer_size); record_buffers.push_back (recbuf); buffer_size += sample_buffer_size; rec_time_add += clk.delta_secs; sprintf (BUFFER, "Recorded %02d:%02d", rec_time_add.mins, rec_time_add.secs); cb_record1.set_text (BUFFER); cb_record2.set_text (BUFFER); if (stop_rec) { if (rec_time_add.mins >= stop_mins && rec_time_add.secs >= stop_secs) stop (); } saved = 0; } void recorder::start_saving () { if (saving_started || (buffer_size == 0)) return; #ifdef __WINDOWS_DS__ TCHAR desktop[MAX_PATH]={0}; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL, 0, desktop))); std::basic_ostringstream file_path; file_path << desktop << _TEXT("\\") << fname.c_str(); file.open(file_path.str().c_str(), ios::binary); cons << file_path.str().c_str() << eol; #else string home = getenv ("HOME"); string desktop ("/Desktop/"); folder = home + desktop; string full_fname (folder + fname); file.open (full_fname.c_str(), ios::binary); #endif write_wav_header (file, SAMPLE_RATE, aout.num_channels, buffer_size); iter = record_buffers.begin (); jter = record_buffers.end (); samples_buffer = new float [aout.samples_per_buffer]; saving_started = 1; } int recorder::save_some (checkbutton& cb) { if (iter != jter) { float* recbuf = *iter; float* L = recbuf, *R = recbuf + aout.samples_per_channel; // separate L and R channels for (int i = 0, j = aout.samples_per_channel, k = 0; i < j; ++i) { // interleave L and R channels samples_buffer[k++] = L[i]; samples_buffer[k++] = R[i]; } file.write ((const char*) samples_buffer, aout.samples_buffer_size); // write to disk! ++iter; rec_time_save += clk.delta_secs; sprintf (BUFFER, "Saved %02d:%02d of %02d:%02d", rec_time_save.mins, rec_time_save.secs, rec_time_add.mins, rec_time_add.secs); cb.set_text (BUFFER); return 1; } else { delete [] samples_buffer; file.close (); samples_buffer = 0; saved = 1; saving_started = 0; rec_time_save.reset (); return 0; } } void recorder::clear () { if (buffer_size && !saving_started) { for (list::iterator citer = record_buffers.begin (), cjter = record_buffers.end (); citer != cjter; ++citer) delete[] *citer; record_buffers.clear (); buffer_size = 0; rec_time_add.reset (); saved = 1; } if (samples_buffer) delete[] samples_buffer; } recorder::~recorder () { clear (); dlog << "-- destroyed recorder --" << endl; } void recorder::set_fname (const string& _fname) { fname = _fname; } void recorder::set_stop_at (int m, int s) { stop_rec = 1; stop_mins = m; stop_secs = s; } void recorder::start () { uis.cb_record.turn_on (); MENU.cb_record.turn_on (); } void recorder::stop () { uis.cb_record.turn_off (); MENU.cb_record.turn_off (); cons ("stopped-recording"); } void recorder::normalise () { float lmin, lmax; float rmin, rmax; lmin = rmin = lmax = rmax = 0; for (list::iterator start = record_buffers.begin (), end = record_buffers.end (); start != end; ++start) { float* recbuf = *start; float* L = recbuf, *R = recbuf + aout.samples_per_channel; for (int i = 0, j = aout.samples_per_channel; i < j; ++i) { float li = L[i], ri = R[i]; if (li > lmax) lmax = li; else if (li < lmin) lmin = li; if (ri > rmax) rmax = ri; else if (ri < rmin) rmin = ri; } } float ldco = -(lmax + lmin)/2, rdco = -(rmin+rmax)/2; cons << "lmin/max: " << lmin <<'/'< characters; // vector desc of chars std::map < char, std::map > kern; // char-char kerning int mod; font (const std::string& fn); ~font (); void load (const std::string& fn); void load (std::ifstream& file); void save (); const std::string& filename () const { return fname;} int char_width (char c); int char_height (char c); void calc_line_height (); void draw_char (char c, int x, int y, int z = 0); const std::map& get_chars (); void set_chars (const std::map& chars); #ifdef __SVG_OUT__ std::ofstream svg; void write_char (char c, int x, int y, int z = 0); #endif #ifdef __PLOTTER_OUT__ std::ofstream hpgl; void plot_char (char c, int x, int y, int z = 0); #endif }; extern font fnt; extern int line_height; inline void draw_char (char c, int x, int y, int z = 0) { fnt.draw_char (c, x, y, z); } int draw_string (const std::string& s, int x, int y, int z = 0); #ifdef __SVG_OUT__ int write_string (const std::string& s, int x, int y, int z = 0); #endif #ifdef __PLOTTER_OUT__ int plot_string (const std::string& s, int x, int y, int z = 0); #endif int get_char_width (const std::string& s); int get_char_height (const std::string& s); #endif din-51.1.1/src/authors_note.cc0000664000175000017500000000340314022054453013103 00000000000000/* * authors_note.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "authors_note.h" #include "console.h" #include "font.h" #include "viewwin.h" #include "main.h" using namespace std; authors_note::authors_note () { name = "Author's Note"; buy_now.set_listener (this); buy_later.set_listener (this); buy_now.set_color (0.5f, 1.0f, 0.5f); buy_later.set_color (1.0f, 0.5f, 0.5f); } void authors_note::enter () { rollup = cons.rollup (); cons.rollup (0); cons ("show-eval-notice"); } void authors_note::leave () { cons.clear (); cons.rollup (rollup); } int authors_note::handle_input () { int r = buy_now.handle_input (); r |= buy_later.handle_input (); return r; } void authors_note::draw () { glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (0, view.xmax, 0, view.ymax, -1, 1); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); buy_now.draw (); buy_later.draw (); } void authors_note::setup () { extern int line_height; buy_now.set_text ("Click here to Buy a License."); buy_now.set_pos (20, 5 * line_height); buy_later.set_text ("Click here to Evaluate."); buy_later.set_pos (20, 3 * line_height); } void authors_note::clicked (button& b) { if (&b == &buy_now) { #if defined (__UNIX_JACK__) || defined (__LINUX_ALSA__) #define BUY_COMMAND "buy-license Linux" #elif defined __MACOSX_CORE__ #define BUY_COMMAND "buy-license Darwin" #elif defined __WINDOWS_DS__ #define BUY_COMMAND "buy-license Windows" #endif cons (BUY_COMMAND); } else { load_instrument (); } } din-51.1.1/src/curve_editor.h0000664000175000017500000001716414022054642012736 00000000000000/* * curve_editor.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __curve_editor #define __curve_editor #include #include #include #include #include #include "curve.h" #include "multi_curve.h" #include "basic_editor.h" #include "curve_listener.h" #include "curve_samples.h" #include "ui.h" #include "mocap.h" #include "beat2value.h" #include "box_selector.h" #include "curve_picker.h" #include "checkbutton.h" #include "state_button.h" #include "capturer.h" #include "point_modulator.h" #include "hit.h" #include "help.h" struct multi_curve; struct curve_editor; struct curve_library; struct plugin; extern const char spc; struct mouse_macro { // for applying mouse capture to hit vertex/tangent of hit curve mocap mo; // mouse capture data hit_t hit; // hit curve & vertex/tangent state_button* sb; // button on capturer widget int paused; mouse_macro (const mocap& m, hit_t& h, state_button* b) : mo(m), hit(h), sb(b) { paused = 0;} }; struct undo_t { int i; multi_curve curve; window win; undo_t (int ii, const multi_curve& mc, window& w) : i(ii), curve(mc), win(w) {} }; typedef undo_t redo_t; struct curve_info { multi_curve* curve; int picked; int disabled; curve_listener* lisner; curve_info (multi_curve* c, curve_listener* l, int picked = 0); curve_info (); }; struct curve_editor : basic_editor { std::vector curveinfo; // edited curves int curcrv; int num_curves; void clear (); void add (multi_curve* crv, curve_listener* lsnr); curve_info& get_curve_info (int i); multi_curve* get_curve (int i); // curve editor features // int carry_tangents; // when vertex moves, their tangents move too. int mirror_tangents; // when 1 tangent of a vertex moves, the other moves too. int lmb_clicked; // picking // std::vector hitlist; hit_t pik; multi_curve* get_picked_curve (); std::string get_picked_curve_name (); hit_t pick_cur_curve (); void set_picked_curve_name (const std::string& n); void curve_picked (); void hilite_item (int id); void hittest (multi_curve* crv, int crv_id, const points_array& points, unsigned int what); void hittest (); int filter_hitlist (); void clear_hit (hit_t& h); void calc_hit_params (hit_t& h); void set_pick_from_hitlist (int i); void picked_using_picker (int i); // vertex/tangent operations // enum { NOTHING = 0, MOVE_PICKED, MOVE_ALL, PICK_CURVE, INSERT_VERTEX, REMOVE_VERTEX, FOLD_VERTEX, UNFOLD_VERTEX, FOLD_ALL, UNFOLD_ALL, MIRROR_VERTEX, MIRROR_ALL, COPY, PASTE, ADD_VERTEX, START_CAPTURE, ASSIGN_CAPTURE, REMOVE_CAPTURE, MODULATE_POINT }; int todo; int next_todo; int stop_todo (); void do_nothing (); void do_pick_curve (); int lmb_move; enum {PREP = 1, FINISH_ON_CLICK = 2}; void prep_move (); int move (); int move (int); int move (hit_t& hit, float x, float y, int eval_now = 1); void fold_tangents_using_menu (); void unfold_tangents_using_menu (); void fold_all_tangents (hit_t& hit); void unfold_all_tangents (hit_t& hit); void fold_tangents_of_vertex (hit_t& hit); void unfold_tangents_of_vertex (hit_t& hit); void insert (); void insert_using_menu (); void remove (); void remove_using_menu (); enum {MIRROR_X = 0, MIRROR_Y, MIRROR_BBX, MIRROR_BBY}; int axis; void mirror (int whole_curve = 0); void mirror_using_menu (); void set_limit (float f); void copy_curve (); void copy_using_menu (); void replace (); void paste_using_menu (); void swap (); // scratch curve // int show_scratch_curve; points_array win_scratch_points, curv_scratch_points; multi_curve scratch_curve; void clear_scratch_curve (); void draw_scratch_curve (); void draw_replacement_curve_using_menu (); void add_vertex (); // load and save editor settings std::string settings_filename; // undo, redo // std::list undos; std::list redos; void dodo (std::list& do1, std::list& do2, std::string mesg); void do_undo (); void do_redo (); // copy & paste static multi_curve copy; void paste (hit_t& h); // curve library // curve_library* library; void add_curve (); void replace_curve (); void insert_curve (); void delete_curve (); void load_curve (int dir); void do_load_curve (int dir); // mouse capture // std::vector macros; capturer_t capturer; void start_mouse_capture_from_menu (); void assign_mouse_capture (); void assign_mouse_capture_from_menu (); void remove_mouse_capture (state_button* sb); void toggle_mouse_capture (std::vector& caps); // point modulation point_modulator pomo; void modulate_point (); void modulate_point (int); // settings // curve_editor (const std::string& settingsf, const std::string& helpf = "curve_editor.hlp"); ~curve_editor (); void load (const std::string& fname); void save (); // ui int handle_input (); // curve selection ops void pick (int k); void toggle (int k); void enable (int k); void enable_all (); int one_curve_enabled (); std::string selection (); // drawing // int draw_curve_only; void draw_curve (multi_curve* crv); void draw_tangents (multi_curve* crv); void draw_vertices (multi_curve* crv); void draw_handle (const point& p); void draw_tangent (const point& p, const point& t); void draw_curves (); void draw_vertices (); void draw_tangents (); void draw_all (); void draw (); int draw_plugin_output; int mark_segments; void mark_curve_segments (); int guides; void draw_guides (); #ifdef __SVG__ // svg void write_curve (multi_curve* crv, std::ofstream& svg, float w, float h, float t, float left, float top, box& bb); void write_svg (float h, float t, const std::string& fn, float left, float top); void write_samples (std::ofstream& svg); #endif #ifdef __HPGL__ // hpgl void write_curve (multi_curve* crv, std::ofstream& hpgl, float scale, float penmag); void write_hpgl (float scale = 5000, float penmag = 100); #endif void attach_library (curve_library* lib); void enter (); void bg (); void set_curve_style (); void toggle_curve_style (); void apply_mocap (); void apply_mocap (mouse_macro& m, int dir = 1); int sine_enabled, fft_enabled; int is_waveform_editor; int samples_enabled; float hz; int nperiods; int offset; curve_samples cs; void set_hz (float zh); void set_periods (int p); void toggle_waveform_samples_display (); void render_curve_samples (); std::vector bv; int label_vertices; void toggle_vertex_labels (); int overlay; std::string next_cursor_mesg; void setup_tools_menu (); float startt; hit_t rpm; float rotx, roty; float angle; float last_rpm; void set_rpm (float RPM); void rotate (); void scale (float sx, float sy); void apply_plugin (plugin* p); int hlabel_only; int mkr[8]; void calc_visual_params (); multi_curve mix; help helptext; static color vtxlbl; int esc (); void drawerlay (); }; extern curve_picker_t curve_picker; void show_curve_picker (); #define CRVED uis.crved #endif din-51.1.1/src/arrow_button.h0000664000175000017500000000150214022054640012754 00000000000000/* * arrow_button.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __arrow_button #define __arrow_button #include "button.h" struct arrow_button : button { enum {left = 1, right, up, down}; int dir; int v[6]; arrow_button (int _sz = 10, int _dir = right) { set_size (_sz); set_dir (_dir); } void draw (); void set_dir (int _dir); void set_pos (int x, int y) { widget::set_pos (x, y); set_size (size); set_dir (dir); } void set (int _sz, int _dir, float r = 1.0f, float g = 1.0f, float b = 1.0f) { set_size (_sz); set_dir (_dir); set_color (r, g, b); } void toggle (); void update () {} }; #endif din-51.1.1/src/ui.h0000664000175000017500000000136514022053526010655 00000000000000/* * ui.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * For more information, please visit http://dinisnoise.org/ */ #ifndef __UI #define __UI #include struct ui { // or screen std::string name; int ed; // editor? int inst; // instrument? int prev_mousex, prev_mousey; // mouse in device space co-ords static ui* over; virtual void enter (); virtual void leave (); virtual int handle_input() {return 1;} virtual void calc_win_mouse () {} virtual void draw() {} virtual void drawerlay () { if (over) over->draw (); } virtual void bg () {} virtual int esc () {return 0;} ui () { prev_mousex = prev_mousey = -1; ed = 0; inst = 0;} virtual ~ui () {} }; #endif din-51.1.1/src/mouse_slider.h0000664000175000017500000000430414060255777012744 00000000000000/* * mouse_slider.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __mouse_slider #define __mouse_slider #include "widget.h" #include "arrow_button.h" #include struct mouse_slider_listener { std::string name; enum {X, Y, NONE}; int orient; double delta0, delta; mouse_slider_listener (); virtual void moused (int dir, double scl = 1.0) {} virtual void after_slide () {} }; struct mouse_slider : widget { int sz, sz_2, szn, szn_1; arrow_button axl, axr; arrow_button ayb, ayt; void update_x_arrows (); void update_y_arrows (); static const int margin = 10; int lowx, highx, midx; int lowy, highy, midy; int prevx, prevy; int initx, inity, inityy; std::list mslx, msly; int nmslx, nmsly; void print (std::list&, std::list&); void print (std::list&); int dx, dy; int justx (); int justy (); int active; int warp; int lmb_clicked; mouse_slider (); ~mouse_slider (); int handle_input (); int pts [8]; void draw (); //void printdx (); //void printdy (); void add (mouse_slider_listener* sl); void remove (mouse_slider_listener* sl); double base; int shift; struct scalet { enum {FIXED, CHANGING}; int style; double value; void operator*= (const double& v) { value *= v; } void operator/= (const double& v) { value /= v; } void calcvalue (double& b, int s); } scale; int activate (int shft = 0, int scalestyle = scalet::CHANGING); int deactivate (); }; void cant_mouse_slide (); void activate_mouse_slider (int shift = 0, int scalestyle = mouse_slider::scalet::CHANGING); extern mouse_slider mouse_slider0; #define MAKE_MOUSE_SLIDER_LISTENER(name,var) struct name : mouse_slider_listener { void after_slide (); void moused (int dir, double scl); }; name var; #define AFTER_SLIDE(scope,name) void scope::name::after_slide () #define MOUSED(scope,name) void scope::name::moused (int dir, double scl) #endif din-51.1.1/src/play.h0000664000175000017500000000611114022054646011203 00000000000000/* * play.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef PLAY #define PLAY #include "note.h" #include "curve_mixer.h" // // renders a tone // struct solver; struct play : set_mixer { // pitch // solver* sol; // solver linked to waveform float x; // current x on the waveform; x usually goes from 0 to 1. 0 = waveform start, 1 = waveform end ie 1 cycle. float dx; // change of x every sample; determines how fast the waveform is sampled and hence frequency of the tone (equivalent to variable step in note.h) float* pdx; // array of dx [interpolated from last to present for smooth frequency change] // volume // float vol; // current volume float* pvol; // array of volumes [interpolated from last to present for smooth volume change] // for calculation of pdx and pvol // float da; // delta alpha int n; // buffer size int n_1; // n-1 // for mixing waveforms curve_mixer mixer; void set_mix (multi_curve& crv); play (solver* s); play (); play (const play&); ~play (); void alloc (); void realloc (); void init (); inline void set_wave (solver* s) { sol = s;} inline void set_step (float xd) {dx = xd;} inline void set_volume (float v) {vol = v;} inline void set (float xd, float l, float r) {dx = xd; vol = l;} void interpolate_buffer (float* buf, float s, float e); void fill_pitch (float xd); void fill_volume (float v); void set_interpolated_pitch (float xd); void set_interpolated_pitch (float xd, int check); void set_interpolated_volume (float v); void set_interpolated_volume (float v, int check); void set_interpolated_pitch_volume (float xd, float v) { set_interpolated_pitch (xd); set_interpolated_volume (v); } void set_interpolated_pitch_volume (float xd, float v, int check) { set_interpolated_pitch (xd, check); set_interpolated_volume (v, check); } inline void operator() (float* out, int n, float* wav, float vol) { // no modulation audio output for (int i = 0; i < n; ++i) out[i] += (vol * wav[i]); } inline void operator() (float* out, int n, float* wav, float* vola) { // no modulation audio output with volume array for (int i = 0; i < n; ++i) out[i] += (vola[i] * wav[i]); } void operator() (float* out, int n, float* wav, float* am, float vol) { // AM modulation in audio output for (int i = 0; i < n; ++i) out[i] += ((vol + am[i]) * wav[i]); } void gen_wav_and_mix (float* wav, int n); void gen_wav_fm (solver& s, float& xx, float* wav, float* fm, int n); void gen_wav_am (float* out, float* wav, float* am, int n); void gen_wav_fm_am_mix (float* out, int n); void gen_wav_mix (float* out, float vol, int n); void gen_wav_mix (float* out, float* vol, int n); void master (float* left, float* right, float* wav, int n, float* vol); void master (float* left, float* right, float* wav, int n, float vol); }; #endif din-51.1.1/src/sine_mixer.cc0000664000175000017500000002100514054776777012562 00000000000000/* * sine_mixer.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "dingl.h" #include "input.h" #include "viewwin.h" #include "sine_mixer.h" #include "ui_list.h" #include "viewwin.h" #include "vector2d.h" #include "circler.h" #include "log.h" #include "console.h" #include "container.h" #include using namespace std; extern const float PI; extern const float TWO_PI; extern curve_library sin_lib; extern int line_height; extern const char SPC; sine_mixer::sine_mixer () : cp_sin ("sine_mixer_sin.crv"), sin_ed ("sine_mixer_sin.ed"), harms ("harmonics"), phase ("phases") { plugin::name = "Sine_Mixer"; shapeform = 0; type = 0; sin_ed.add (&cp_sin.crv, this); sin_ed.attach_library (&sin_lib); harms.paintl = this; harms.chgl = this; harms.shftl = this; harms.szr.movlis = &szm; phase.paintl = this; phase.chgl = this; phase.shftl = this; phase.szr.movlis = &szm; szm.data = this; static const float fac = 0.6; phase.set_color (1.0f - fac * harms.clr.r, 1.0f - fac * harms.clr.g, 1.0f - fac * harms.clr.b); paintphase = 0; } void sine_mixer::load_params () { ifstream f (make_fname().c_str(), ios::in); string ignore; f >> ignore >> num_points >> ignore >> make_shapeform >> ignore >> type >> ignore >> auto_apply; NUM_SINE_SAMPLES = num_points + 1; } void sine_mixer::save_params () { ofstream f (make_fname().c_str(), ios::out); string ignore; f << "num_points " << int (sp_points.f_value) << " make_shapeform " << cb_make_shapeform.state << " type " << type \ << " auto_apply " << cb_auto_apply.state << endl; } sine_mixer::~sine_mixer () { save_params (); widget_save ("d_sine_mixer", ctrls); dlog << "--- destroyed sine mixer ---" << endl; } void sine_mixer::num_harmonics (int h) { nharmonics = h; if (nharmonics < 1) nharmonics = 1; prep_harmonics (); } void sine_mixer::prep_harmonics () { harmonics.resize (nharmonics); float df = TWO_PI / (NUM_SINE_SAMPLES - 1); funktion& f_sin = *pf_sin; for (int i = 0, j = 1; i < nharmonics; ++i, ++j) { vector< point >& harmonic = harmonics[i]; harmonic.resize (NUM_SINE_SAMPLES); float dx = j * df; float x = phase.values[i] * TWO_PI; for (int p = 0; p < NUM_SINE_SAMPLES; ++p) { point& hp = harmonic[p]; hp.x = cos(x); hp.y = f_sin (x, TWO_PI); x += dx; if (x > TWO_PI) x -= TWO_PI; } } norm.resize (NUM_SINE_SAMPLES); mix (); } void sine_mixer::mix () { for (int p = 0; p < NUM_SINE_SAMPLES; ++p) { point& pi = norm[p]; pi.x = pi.y = 0;} ss.str(""); ss << plugin::name; for (int i = 0; i < nharmonics; ++i) { float lev = harms.values[i]; if (lev > 0) { vector< point >& harmonic = harmonics[i]; for (int p = 0; p < NUM_SINE_SAMPLES; ++p) { point& np = norm[p]; point& hp = harmonic[p]; np.x += (lev * hp.x); np.y += (lev * hp.y); } ss << '_' << (i+1); } } normalise (); } void sine_mixer::normalise () { int n = NUM_SINE_SAMPLES; if (n) { point& np0 = norm[0]; float maxy = fabs (np0.y), maxx = fabs (np0.x); for (int i = 0; i < n; ++i) { point& pi = norm[i]; float vx = fabs (pi.x), vy = fabs (pi.y); if (vx > maxx) maxx = vx; if (vy > maxy) maxy = vy; } if (maxx != 0) for (int p = 0; p < n; ++p) norm[p].x /= maxx; if (maxy != 0) for (int p = 0; p < n; ++p) norm[p].y /= maxy; } } void sine_mixer::render () { undo = !cb_auto_apply.state; shapeform = cb_make_shapeform.state; int ns = norm.size (); points.resize (ns); if (shapeform) { for (int i = 0; i < ns; ++i) { point& ni = norm[i]; point& pi = points[i]; pi.x = ni.x; pi.y = ni.y; } } else { float x = 0; float dx = 1.0f / (NUM_SINE_SAMPLES - 1); for (int i = 0; i < ns; ++i) { point& ni = norm[i]; point& pi = points[i]; pi.x = x; pi.y = ni.y; x += dx; } } gen_pts (); } void sine_mixer::setup () { plugin::setup (); widget* _ctrls [] = { &sp_points, &cb_make_shapeform, &ol_sin, &b_edit, &cbpaint, &olpaint, }; num_ctrls = 8; ctrls.resize (num_ctrls); for (int i = 0, j = 2; j < num_ctrls; ++i, ++j) ctrls[j] = _ctrls[i]; load_params (); sp_points.set ("Points", 1, 1, MILLION, this, 0); sp_points.set_value (num_points); cb_make_shapeform.set_text ("Make shapeform"); cb_make_shapeform.set_state (make_shapeform); cb_make_shapeform.set_listener (this); cbpaint.set_text ("Paint"); levs[0] = &harms; levs[1] = &phase; LISTEN (cbpaint, this) pail.data = this; LISTEN (olpaint, &pail) if (auto_apply) { cb_auto_apply.set_state (1, 0); plugin::mix = undo = 0; } ol_sin.set_listener (this); widget_load ("d_sine_mixer", ctrls); ctrls.push_back (&harms); olpaint.set_text (" Harmonics"); num_ctrls = 9; //for (int i = 0; i < num_ctrls; ++i) ctrls[i]->set_moveable(1); b_edit.set_text ("Edit"); set_type (); num_harmonics (harms.n); render (); } void sine_mixer::set_type () { if (type) { pf_sin = &cp_sin; ol_sin.option.set_text (" Custom sin"); b_edit.set_color (clr.r, clr.g, clr.b); b_edit.set_listener (this); } else { pf_sin = &st_sin; ol_sin.option.set_text (" Standard sin"); b_edit.set_color (0.25f, 0.25f, 0.25f); b_edit.set_listener (0); } int spacer = 10; b_edit.set_pos (ol_sin.option.extents.right + spacer, ol_sin.option.extents.bottom); } void sine_mixer::changed (field& f) { if (&f == &sp_points.f_value) { set_samples (f); do_render (); } } void sine_mixer::changed (levels& l) { if (&l == &phase) prep_harmonics (); mix (); do_render (); } void sine_mixer::changed (checkbutton& cb) { if (&cb == &cb_make_shapeform) { render (); apply_not_auto_apply (); } else if (&cb == &cbpaint) { levs[paintphase]->paint = cbpaint.state; } else plugin::changed (cb); } void sine_mixer::set_samples (int s) { NUM_SINE_SAMPLES = s + 1; if (NUM_SINE_SAMPLES < MIN_SINE_SAMPLES) NUM_SINE_SAMPLES = MIN_SINE_SAMPLES; prep_harmonics (); } void sine_mixer::apply_not_auto_apply () { if (cb_auto_apply.state) { plugin::mix = undo = 1; uis.crved->apply_plugin (this); plugin::mix = undo = 0; } else uis.crved->apply_plugin (this); } void sine_mixer::picked (label& lbl, int dir) { type = !type; set_type (); prep_harmonics (); render (); } void sine_mixer::shift_apply () { mix (); render (); apply_not_auto_apply (); } void sine_mixer::clicked (button& b) { if (&b == &b_edit) uis.set_current (&sin_ed); else plugin::clicked (b); } void sine_mixer::edited (curve_editor* e, int i) { cp_sin.sol.update (); curve_listener::edited (e, i); prep_harmonics (); render (); } void sine_mixer::moused (int dx, double scl) { if (dx > 0) harms.rshift (); else harms.lshift (); shift_apply (); } void sine_mixer::paint (levels& l) { cbpaint.set_state (levs[paintphase]->paint, 0); } void sine_mixer::shifted (levels& l) { if (&l == &phase) prep_harmonics (); shift_apply (); } void sine_mixer::toggpaint (label& l) { static const char* pp [] = {" Harmonics", " Phase"}; paintphase = !paintphase; ctrls.pop_back (); if (paintphase) { uis.plugin__browser.l_title.swapchild (&harms, &phase); ctrls.push_back (&phase); phase.setpos2 (harms); } else { uis.plugin__browser.l_title.swapchild (&phase, &harms); ctrls.push_back (&harms); harms.setpos2 (phase); } l.set_text (pp[paintphase]); levels* lp = levs[paintphase]; olpaint.option.set_color (lp->clr.r, lp->clr.g, lp->clr.b); cbpaint.set_state (lp->paint,0); } int sine_mixer::handle_input () { int r = plugin::handle_input (); if (!_folded) { if (keypressed (SDLK_g)) { pressed.g = 1; toggpaint (olpaint.option); r |= 1; } } return r; } PICKED_OPTION (sine_mixer, paintlis) { sine_mixer& sm = (* (sine_mixer*) data); sm.toggpaint (l); } MOVED (sine_mixer, szrmov) { sine_mixer& sm = (* (sine_mixer*) data); levels* pla = sm.levs[sm.paintphase]; pla->moved (); levels* plb = sm.levs[!sm.paintphase]; plb->extents = pla->extents; plb->szr.setpos2 (pla->szr); plb->moved (); } din-51.1.1/src/bit_display.h0000664000175000017500000000232314022054640012534 00000000000000/* * bit_display.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __BIT_DISPLAY #define __BIT_DISPLAY #include "widget.h" #include struct ucolor_t; struct bit_display : widget { int d_width; // display width of each bit int xstart, xend; // start, end of display std::vector bits; // the bits int num_bits; int last_bit; int cur_id; // mouse @ int prev_id; change_listener* lsnr; bit_display (int w = 256, int h = 64); void set_pos (int x, int y); void set_size (int w, int h); void set (void* bytes, int num_bytes); int handle_input (); void draw (); void calc_visual_params (); int find_bit_id (); void get_color (ucolor_t* uc); template void get_data (T* ptr_) { unsigned char* ptr = (unsigned char*) ptr_; int num_bytes = sizeof (T); for (int i = 0, j = num_bits - 1; i < num_bytes; ++i) { unsigned char uci = 0; for (int k = 0; k < 8; ++k) { unsigned char bj = bits[j--]; uci = uci | (bj << k); } ptr[i] = uci; } } }; #endif din-51.1.1/src/note.h0000664000175000017500000000164014022054645011204 00000000000000/* * note.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __NOTE #define __NOTE #include #include struct scale_info; struct note { // // musical note / tone // std::string name; std::string hz_name; void set_name (const std::string& n); void set_name (const std::string& interval, int i); float hz; // frequency of note in hertz float step; // amount to step in x along the waveform every sample to get the audio level at that sample. int scale_pos; void change_scale_pos (int j, scale_info& si); int octave; note (); void set_freq (float f); void set_freq (float key, float interval); std::ofstream& save (std::ofstream& f); std::ifstream& load (std::ifstream& f); }; #endif din-51.1.1/src/midi_in.h0000664000175000017500000000152114022054645011645 00000000000000/* * midi_in.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __midi_in #define __midi_in #include "RtMidi.h" #include #include struct midi_in { RtMidiIn rt; int num_ports; int input_port; int available; unsigned char channel; unsigned char cc; unsigned char val; std::vector names; midi_in (); void probe (); void open (); void open (int _input_port); void handle_input (); std::string get_name (int i) { if (i > -1 && i < num_ports) return names[i]; else return "?"; } }; void run_midi_cmd (const std::string& cmd, std::vector& args); extern midi_in midiin; #endif din-51.1.1/src/sine_mixer.h0000664000175000017500000000443114022053476012403 00000000000000/* * sine_mixer.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * For more information, please visit http://dinisnoise.org/ */ #ifndef __sine_mixer #define __sine_mixer #include "box.h" #include "multi_curve.h" #include "spinner.h" #include "checkbutton.h" #include "state_button.h" #include "levels.h" #include "plugin.h" #include "point.h" #include "custom_periodic.h" #include "sine.h" #include "curve_editor.h" #include "listeners.h" #include "filled_button.h" #include "mouse_slider.h" #include "plus_button.h" #include "minus_button.h" #include "cross_button.h" #include struct harmonics_list_button : state_button { std::vector harmonics; }; struct sine_mixer : plugin, change_listener, shift_listener, paint_listener, curve_listener, option_listener { static int NUM_SINE_SAMPLES; static const int MIN_SINE_SAMPLES; int num_points; int make_shapeform; funktion* pf_sin; custom_periodic cp_sin; sine st_sin; int type; curve_editor sin_ed; int nharmonics; std::vector< std::vector< point > > harmonics; // output std::vector< point > norm; void normalise (); // ui // spinner sp_points; checkbutton cb_make_shapeform; // standard/custom sin options_list ol_sin; button b_edit; levels harms; // harmonics levels phase; // phase levels* levs [2]; // harmonics, phase checkbutton cbpaint; options_list olpaint; MAKE_OPTION_LISTENER(paintlis, pail) void toggpaint (label& l); sine_mixer (); ~sine_mixer (); void load_params (); void save_params (); void setup (); void set_type (); void set_samples (int s); void prep_harmonics (); void num_harmonics (int n); void mix (); void render (); int auto_apply; void apply_not_auto_apply (); void shift_apply (); void changed (field& f); void changed (checkbutton& cb); void changed (levels& l); void paint (levels& l); void shifted (levels& l); void picked (label& lbl, int dir); void edited (curve_editor* e, int i); void clicked (button& b); void moused (int dir, double scl); int handle_input (); int paintphase; MAKE_MOVE_LISTENER (szrmov, szm) }; extern sine_mixer sinemixer; #endif din-51.1.1/src/multi_curve.cc0000664000175000017500000003402514063307626012743 00000000000000/* * multi_curve.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "multi_curve.h" #include "vector2d.h" #include "container.h" #include "random.h" #include "log.h" #include extern string user_data_dir; static const char eol = '\n'; multi_curve::multi_curve (const string& filename) { load (filename); } multi_curve::multi_curve () { clear (); } void multi_curve::clear (int all) { if (all) { name = "nameless"; set_color (1, 1, 1); } vertices.clear (); num_vertices = 0; last_vertex = -1; left_tangents.clear (); right_tangents.clear (); curv.clear (); limit = 0.001f; shapeform = 0; centroid_style = CALC; scx = 0.5f; scy = 0.0f; cx = scx; cy = scy; } // // must call following 3 together with add_vertex called first // to correctly add curve // void multi_curve::add_vertex (float x, float y) { last_vertex = num_vertices++; vertices.push_back (point (x, y)); if (num_vertices > 1) curv.push_back (curve()); } void multi_curve::add_left_tangent (float x, float y) { left_tangents.push_back (point (x, y)); } void multi_curve::add_right_tangent (float x, float y) { right_tangents.push_back (point (x, y)); } void multi_curve::get_vertex (int i, float& x, float& y) { point& v = vertices[i]; x = v.x; y = v.y; } int multi_curve::set_vertex (int i, float x, float y, int carry_tangents) { point& v = vertices[i]; if ((v.x != x) || (v.y != y)) { float dlx, dly, drx, dry; if (carry_tangents) { point& lt = left_tangents[i]; point& rt = right_tangents[i]; dlx = lt.x - v.x; dly = lt.y - v.y; drx = rt.x - v.x; dry = rt.y - v.y; lt.x = x + dlx; lt.y = y + dly; rt.x = x + drx; rt.y = y + dry; } v.x = x; v.y = y; if ((unsigned int) i < curv.size ()) curv[i].eval_state = curve::EVAL_REQUIRED; int i_1 = i - 1; if (i_1 > -1) curv[i_1].eval_state = curve::EVAL_REQUIRED; return 1; } else return 0; } int multi_curve::set_left_tangent (int i, float x, float y) { point& lt = left_tangents [i]; if ((lt.x != x) || (lt.y != y)) { lt.x = x; lt.y = y; int j = i - 1; if (j > -1) curv[j].eval_state = curve::EVAL_REQUIRED; return 1; } return 0; } int multi_curve::set_right_tangent (int i, float x, float y) { point& rt = right_tangents[i]; if ((rt.x != x) || (rt.y != y)) { rt.x = x; rt.y = y; if (i < (int) curv.size()) curv[i].eval_state = curve::EVAL_REQUIRED; return 1; } return 0; } void multi_curve::get_left_tangent (int i, float& x, float& y) { point& lt = left_tangents [i]; x = lt.x; y = lt.y; } void multi_curve::get_right_tangent (int i, float& x, float& y) { point& rt = right_tangents[i]; x = rt.x; y = rt.y; } int multi_curve::insert (float x, float y, float tx, float ty) { points_array::iterator vter = ++vertices.begin (), lter = ++left_tangents.begin (), rter = ++right_tangents.begin (); vector::iterator cter = curv.begin (); for (int i = 0, j = last_vertex; i < j; ++i, ++vter, ++lter, ++rter, ++cter) { point& vi = vertices[i]; point& vi1 = vertices[i + 1]; if ((x >= vi.x) && (x <= vi1.x)) { /*float ltx, lty; unit_vector (ltx, lty, x, y, vi.x, vi.y); float rtx, rty; unit_vector (rtx, rty, x, y, vi1.x, vi1.y); point v (x, y), lt (x + tx * ltx, y + ty * lty), rt (x + tx * rtx, y + ty * rty);*/ point v (x, y); vertices.insert (vter, v); last_vertex = num_vertices++; left_tangents.insert (lter, v); right_tangents.insert (rter, v); /*left_tangents.insert (lter, lt); right_tangents.insert (rter, rt);*/ (*cter).eval_state = curve::EVAL_REQUIRED; curv.insert (cter, curve()); return 1; } } return 0; } int multi_curve::remove (int i) { // remove ith vertex and its tangents if (num_vertices < 3) return 0; erase_id (vertices, i); erase_id (left_tangents, i); erase_id (right_tangents, i); if (i == (int) curv.size ()) { int j = i - 1; erase_id (curv, j); } else { erase_id (curv, i); if (--i > -1) curv[i].eval_state = curve::EVAL_REQUIRED; else curv[0].eval_state = curve::EVAL_REQUIRED; } --num_vertices; last_vertex = num_vertices - 1; return 1; } void multi_curve::set_limit (float d) { limit = d; require_eval (); } void multi_curve::require_eval () { for (int i = 0, j = curv.size(); i < j; ++i) curv[i].eval_state = curve::EVAL_REQUIRED; } void multi_curve::set_color () { static const float base = 0.1f; static rnd rd (base, 1.0f - base); r = rd (); g = rd (); b = rd (); calc_tangent_color (); } void multi_curve::set_color (float rr, float gg, float bb) { r = rr; g = gg; b = bb; calc_tangent_color (); } void multi_curve::calc_tangent_color () { static const float factor = 0.5; rt = factor * r; gt = factor * g; bt = factor * b; } void multi_curve::evaluate () { int nevals = 0; int ncrvs = curv.size (); for (int i = 0; i < ncrvs; ++i) { curve& crv = curv[i]; if (crv.eval_required ()) { int j = i + 1; point& v0 = vertices[i]; point& v1 = vertices[j]; point& rt0 = right_tangents[i]; point& lt1 = left_tangents[j]; crv.vertex (0, v0.x, v0.y); crv.vertex (1, v1.x, v1.y); crv.tangent (0, rt0.x, rt0.y); crv.tangent (1, lt1.x, lt1.y); crv.set_limit (limit); crv.eval (shapeform); ++nevals; } } if (nevals) { if (shapeform) { float total_length = 0.0f; float now_length = 0.0f; for (int i = 0; i < ncrvs; ++i) total_length += curv[i].length; for (int i = 0; i < ncrvs; ++i) curv[i].normalise_length (now_length, total_length); check_shapeform (); } } } void multi_curve::check_shapeform () { for (int i = 0, j = 1, k = curv.size () - 1; i < k; ++i, ++j) { curve& crvi = curv[i]; curve& crvj = curv[j]; vector& dptsi = crvi.dpts; vector& dptsj = crvj.dpts; int last = dptsi.size () - 1; crvpt& dl = dptsi[last]; crvpt& d0 = dptsj[0]; d0.x = dl.x; d0.y = dl.y; } } void multi_curve::calc_centroid () { if (centroid_style == SET) { cx = scx; cy = scy; } else { box b; calc_bbox (b); cx = (b.left + b.right) / 2.; cy = (b.bottom + b.top) / 2.; } } void multi_curve::calc_bbox (box& b) { int num_curves = curv.size (); if (num_curves) { int num_points = curv[0].vpts.size (); if (num_points) { const vector& vpts = curv[0].vpts; b.left = b.right = vpts[0].x; b.bottom = b.top = vpts[0].y; for (int i = 0; i < num_curves; ++i) { const vector & vpts = curv[i].vpts; num_points = vpts.size (); for (int j = 0; j < num_points; ++j) { const crvpt& p = vpts[j]; if (p.x < b.left) b.left = p.x; else if (p.x > b.right) b.right = p.x; if (p.y < b.bottom) b.bottom = p.y; else if (p.y > b.top) b.top = p.y; } } } } b.calc (); } void multi_curve::load (const string& filename) { ifstream file ((user_data_dir + filename).c_str (), ios::in); if (!file) { dlog << "!!! failed to load curve from: " << filename << " !!!" << endl; return; } load (file); dlog << "+++ loaded curve from: " << filename << " +++" << endl; } void multi_curve::load (ifstream& file) { clear (); string ignore; file >> ignore >> name; int nvertices; file >> ignore >> nvertices; for (int i = 0; i < nvertices; ++i) { float x, y; file >> ignore >> x >> y; add_vertex (x, y); file >> ignore >> x >> y; add_left_tangent (x, y); file >> ignore >> x >> y; add_right_tangent (x, y); } file >> ignore >> limit; float ir, ig, ib; file >> ignore >> ir >> ig >> ib; set_color (ir, ig, ib); file >> ignore >> shapeform; point& lt0 = left_tangents[0]; point& v0 = vertices[0]; int last = nvertices - 1; point& rtl = right_tangents[last]; point& vl = vertices[last]; lt0.x = v0.x; lt0.y = v0.y; rtl.x = vl.x; rtl.y = vl.y; evaluate (); } void multi_curve::save (const string& filename) { ofstream file ((user_data_dir + filename).c_str (), ios::out); if (!file) { dlog << "!!! failed writing curve to: " << filename << endl; return; } save (file); dlog << "+++ saved curve into: " << filename << " +++" << endl; } void multi_curve::save (ofstream& file) { string ignore; if (name == "") name = "nameless"; file << "name " << name << eol; file << "num_vertices " << num_vertices << eol; for (int i = 0; i < num_vertices; ++i) { point& v = vertices[i]; point& lt = left_tangents[i]; point& rt = right_tangents[i]; file << "vertex_" << i << spc << v.x << spc << v.y << eol; file << "left_tangent_" << i << spc << lt.x << spc << lt.y << eol; file << "right_tangent_" << i << spc << rt.x << spc << rt.y << eol; } file << "limit " << limit << eol; file << "color " << r << spc << g << spc << b << eol; file << "shapeform " << shapeform << eol; } void create_polyline (multi_curve& crv, const points_array& pts) { int npts = pts.size (); if (npts < 2) return; crv.clear (0); for (int i = 0; i < npts; ++i) { float xi = pts[i].x, yi = pts[i].y; crv.add_vertex (xi, yi); crv.add_left_tangent (xi, yi); crv.add_right_tangent (xi, yi); } crv.evaluate (); } void convert2_polyline (multi_curve& crv) { for (int i = 0, j = crv.num_vertices; i < j; ++i) { point& v = crv.vertices[i]; crv.set_left_tangent (i, v.x, v.y); crv.set_right_tangent (i, v.x, v.y); } crv.evaluate (); } void convert2_catmull_rom (multi_curve& crv, float tangent_size) { int npts = crv.num_vertices; if (npts < 2) return; int last = npts - 1; point& p0 = crv.vertices[0]; point& p1 = crv.vertices[1]; point& pl = crv.vertices[last]; point& pl1 = crv.vertices[last-1]; // set tangents for 1st vertex float dx, dy; direction (dx, dy, p0.x, p0.y, p1.x, p1.y); float tx = tangent_size * dx, ty = tangent_size * dy; crv.set_left_tangent (0, p0.x - tx, p0.y - ty); crv.set_right_tangent (0, p0.x + tx, p0.y + ty); // set tangents for last vertex direction (dx, dy, pl.x, pl.y, pl1.x, pl1.y); tx = tangent_size * dx; ty = tangent_size * dy; crv.set_left_tangent (last, pl.x + tx, pl.y + ty); crv.set_right_tangent (last, pl.x - tx, pl.y - ty); // set left, right tangent for inbetween vertices for (int i = 1; i < last; ++i) { int l = i - 1, r = i + 1; point& pi = crv.vertices[i]; point& pl = crv.vertices[l]; point& pr = crv.vertices[r]; direction (dx, dy, pl.x, pl.y, pr.x, pr.y); crv.set_left_tangent (i, pi.x - tangent_size * dx, pi.y - tangent_size * dy); crv.set_right_tangent (i, pi.x + tangent_size * dx, pi.y + tangent_size * dy); } crv.evaluate (); } multi_curve* check_list (multi_curve** lst, int n, const string& name) { for (int m = 0; m < n; ++m) if (lst[m]->name == name) return lst[m]; return 0; } vector& multi_curve::get_profile_points (int i) { if (shapeform) return curv[i].dpts; else return curv[i].vpts; } void multi_curve::set_shapeform (int what) { shapeform = what; require_eval (); evaluate (); } void multi_curve::rotate (float angle) { // rotate curve about centroid for (int i = 0; i < num_vertices; ++i) { point& vi = vertices[i]; point& lt = left_tangents[i]; point& rt = right_tangents[i]; rotate (vi, angle); rotate (lt, angle); rotate (rt, angle); } require_eval (); evaluate (); } void multi_curve::rotate (point& p, float angle) { // rotate point about centroid by angle float px = p.x - cx, py = p.y - cy; p.x = px * cos (angle) - py * sin (angle) + cx; p.y = px * sin (angle) + py * cos (angle) + cy; } void multi_curve::scale (float sx, float sy) { for (int i = 0; i < num_vertices; ++i) { point& vi = vertices[i]; point& lt = left_tangents[i]; point& rt = right_tangents[i]; scale (vi, sx, sy); scale (lt, sx, sy); scale (rt, sx, sy); } require_eval (); evaluate (); } void multi_curve::scale (point& p, float sx, float sy) { float px = sx * (p.x - cx), py = sy * (p.y - cy); p.x = cx + px; p.y = cy + py; } void multi_curve::get_xy (double d, float& x, float& y) { for (int i = 0, j = curv.size (); i < j; ++i) { curve& c = curv[i]; vector& vpts = c.vpts; vector& dpts = c.dpts; for (int m = 0, n = dpts.size () - 1; m < n; ++m) { crvpt& dm = dpts[m]; crvpt& dn = dpts[m+1]; crvpt& vm = vpts[m]; crvpt& vn = vpts[m+1]; if (d >= dm.x && d <= dn.x) { float amt = (d - dm.x) / (dn.x - dm.x); x = vm.x + amt * (vn.x - vm.x); y = vm.y + amt * (vn.y - vm.y); return; } } } } int multi_curve::get_total_points () { int total = 0; for (int i = 0, j = curv.size(); i < j; ++i) { vector& vpts = curv[i].vpts; total = total + vpts.size () - 1; } total += 1; return total; } void multi_curve::get_profile_points (vector& profile) { profile.clear (); for (int i = 0, j = curv.size(), k = j - 1; i < j; ++i) { vector& vpts = curv[i].vpts; int q = vpts.size() - 1; if (i == k) ++q; for (int p = 0; p < q; ++p) profile.push_back (vpts[p]); } } extern void make_good_name (string& name); void multi_curve::set_name (const string& _name) { name = _name; make_good_name (name); } din-51.1.1/src/osc.h0000664000175000017500000000226714022054645011031 00000000000000/* * osc.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __osc #define __osc #include #include "command.h" #include struct oserver : command { lo_server server; int lo_fd; fd_set rfds; struct timeval tv; bool enabled; bool msg; oserver (const std::string& ln, const std::string& sn) : command (ln, sn) {} bool operator() (tokenizer& tz); void handle_requests (); void toggle (); ~oserver (); }; int command_handler (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data); struct oconnect : command { lo_address& client; oconnect (lo_address& c, const std::string& ln, const std::string& sn) : command (ln, sn), client(c) {} bool operator() (tokenizer& tz); ~oconnect () {} }; struct osend : command { lo_address& client; osend (lo_address& c, const std::string& ln, const std::string& sn) : command (ln, sn), client(c) {} bool operator() (tokenizer& tz); ~osend () {} }; void osc (); #endif din-51.1.1/src/hit.h0000664000175000017500000000306014022054643011017 00000000000000/* * hit.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __hit #define __hit #include "point.h" #include "multi_curve.h" struct multi_curve; struct hit_t { multi_curve* crv; // curve hit int crv_id; // id among list of curves enum {NONE = 0, VERTEX, LEFT_TANGENT, RIGHT_TANGENT}; // things that can be hit int what; // what was hit int id; // id of hit thing static int name_only; // tangent vectors from corresponding vertex // point left_tangent, right_tangent; float left_tangent_magnitude, right_tangent_magnitude; hit_t (multi_curve* c = 0, int cid = -1, int w = NONE, int i = -1, int no = 0); hit_t (const hit_t& h); void clear (); int operator()() const; // hit? int operator()(int) const; // hit curve item exists? int operator== (const hit_t& h) {return ((crv == h.crv) && (what == h.what) && (id == h.id));} int matched_id (const hit_t& h) {return ( (crv == h.crv) && (id == h.id) ); } void ensure_id (); hit_t& operator= (const hit_t& h); void copy (const hit_t& src); const point& get (); }; template T& operator<< (T& t, const hit_t& h) { if (hit_t::name_only) t << h.crv->name; else { static const std::string what [] = {"nothing ", "vertex ", "L-tangent ", "R-tangent "}; static const char* of = " of "; t << what[h.what] << h.id << of << h.crv->name; } return t; } #endif din-51.1.1/src/funktion.h0000664000175000017500000000053614022054643012075 00000000000000/* * funktion.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __FUNKTION #define __FUNKTION struct funktion { virtual float operator() (float ra = 0, float rea = 0) = 0; }; #endif din-51.1.1/src/play.cc0000664000175000017500000001017114022054460011334 00000000000000/* * play.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "audio.h" #include "play.h" #include "multi_curve.h" #include void play::init () { sol = 0; x = 0.0f; dx = 0.0f; vol = 0.0f; pdx = pvol = 0; alloc (); pdx [0] = 0.0f; pdx [n_1] = 1.0f; pvol [0] = 0.0f; pvol [n_1] = 1.0f; } void play::alloc () { n = aout.samples_per_channel; n_1 = n - 1; da = 1.0f / n_1; if (pdx) delete [] pdx; if (pvol) delete [] pvol; pdx = new float [n]; pvol = new float [n]; int sz = n * sizeof (float); memset (pdx, 0, sz); memset (pvol, 0, sz); } void play::realloc () { alloc (); fill_pitch (dx); fill_volume (vol); } play::play (solver *w) { init (); set_wave (w); } play::play () { init (); } play::play (const play& p) { sol = p.sol; x = p.x; dx = p.dx; vol = p.vol; n = p.n; n_1 = p.n_1; da = p.da; pdx = new float [n]; pvol = new float [n]; for (int i = 0; i < n; ++i) { pdx [i] = p.pdx [i]; pvol [i] = p.pvol [i]; } } play::~play () { if (pdx) delete[] pdx; if (pvol) delete[] pvol; } void play::fill_pitch (float xd) { for (int i = 0; i < n; ++i) pdx[i] = xd; dx = xd; } void play::fill_volume (float v) { for (int i = 0; i < n; ++i) pvol[i] = v; vol = v; } void play::interpolate_buffer (float* buf, float s, float e) { float a = 0; float es = e - s; for (int i = 0; i < n; ++i) { buf[i] = s + a * es; a += da; } } void play::set_interpolated_volume (float v) { interpolate_buffer (pvol, vol, v); vol = v; } void play::set_interpolated_pitch (float xd) { interpolate_buffer (pdx, dx, xd); dx = xd; } void play::set_interpolated_pitch (float xd, int check) { if ((pdx[0] == pdx[n_1]) && (pdx[0] == xd)) return; // pitch is same else if (xd == dx) for (int i = 0; i < n; ++i) pdx[i] = dx; // same as last pitch so just fill ie no interpolation needed else set_interpolated_pitch (xd); } void play::set_interpolated_volume (float v, int check) { if ((pvol[0]==pvol[n_1]) && (pvol[0]==v)) return; // volume is same else if (v == vol) for (int i = 0; i < n; ++i) pvol[i] = v; // same as last volume so just fill ie no interpolation needed else set_interpolated_volume (v); } void play::gen_wav_and_mix (float* wav, int n) { (*sol) (x, pdx, n, wav); if (mixer.active) { mixer.gen_mix (aout.mix, n); mixer.do_mix (wav, aout.mix, aout.mixa, n); } } void play::master (float* L, float* R, float* wav, int n, float* vola) { // master with volume array gen_wav_and_mix (wav, n); // mix waveforms operator() (L, n, wav, vola); // multiply volumes memcpy (R, L, aout.samples_channel_size); // copy to R } void play::master (float* L, float* R, float* wav, int n, float vol) { // master with volume gen_wav_and_mix (wav, n); // mix waveforms operator() (L, n, wav, vol); // apply volume memcpy (R, L, aout.samples_channel_size); // copy to R } void play::gen_wav_fm (solver& _sol, float& _x, float* wav, float* fm, int n) { // generate waveform samples with FM _sol (_x, pdx, n, fm, wav); } void play::gen_wav_am (float* out, float* wav, float* am, int n) { // apply AM to waveform samples for (int i = 0; i < n; ++i) out[i] = ((pvol[i] + am[i]) * wav[i]); } void play::gen_wav_fm_am_mix (float* out, int n) { // generate waveform samples, apply AM and FM and mix (if present) gen_wav_fm (*sol, x, aout.result, aout.fms, n); gen_wav_am (out, aout.result, aout.ams, n); if (mixer.active) { mixer.gen_fm (aout.result, n, aout.fms); gen_wav_am (aout.mix, aout.result, aout.ams, n); mixer.do_mix (out, aout.mix, aout.mixa, n); } } void play::gen_wav_mix (float* out, float* vola, int n) { gen_wav_and_mix (aout.result, n); operator() (out, n, aout.result, vola); } void play::gen_wav_mix (float* out, float vol, int n) { gen_wav_and_mix (aout.result, n); operator() (out, n, aout.result, vol); } void play::set_mix (multi_curve& crv) { mixer.setup (crv, x, dx); } din-51.1.1/src/binaural_drones.h0000664000175000017500000000450314022054640013402 00000000000000/* * binaural_drones.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __BINAURAL_DRONES__ #define __BINAURAL_DRONES__ #include #include "binaural_drone.h" #include "ui.h" #include "instrument.h" #include "curve_editor.h" #include "help.h" struct fade_info { std::string name; int active; int after; solver sol; float xt, dxt; float xu, xui; float duration; fade_info (); void start (const std::string& _name = "op"); int eval (float* out); void set_duration (float t); void complete (); void abort (); }; struct i_binaural_drones; struct waveform_listener : curve_listener { i_binaural_drones* sb; void edited (curve_editor* ed, int i); }; struct i_binaural_drones : instrument { std::vector binaural_drones; int num_binaural_drones; multi_curve wav; // waveform shared by all binaural drones curve_editor waved; // waveform editor waveform_listener wavlis; // waveform edit listener // binaural drone fading multi_curve fdrcrv; // fading curve fade_info pitch_fader, vol_fader; float master_volume; // split among all binaural drones float modulation_amount; float starting_pitch; // starting pitch from where binaural drones are made float separation; // in hz between l and r of a binaural drone int pairs; // number of binaural drones float spacing; // inter drone spacing enum {START_PITCH=0, FROM_SCALE}; int keynote; int close_octave; // close octave when making binaural drones on notes of scale? int change_key_note (int dir); int resize_separation; // justification int just; help hlp; i_binaural_drones (); ~i_binaural_drones (); int add (float _lhz, float _rhz, float _vol, int just, float sep, float lx = 0, float rx = 0); void remove (int w); void sync (int n, const std::string& lst); void list (); void load (); void save (); void update_players (multi_curve& mx); int handle_input (); int change_justification (int dir); int render_audio (float* L, float* R); void enter (); int abort; int busy (); int aborted (); std::string get_sel_vol (); }; extern i_binaural_drones binaural_drones0; #endif din-51.1.1/src/levels.cc0000664000175000017500000003160614022054457011675 00000000000000/* * levels.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "main.h" #include "levels.h" #include "viewwin.h" #include "input.h" #include "console.h" #include "utils.h" #include "font.h" #include "log.h" using namespace std; extern string user_data_dir; extern int mousex, mousey, wheel, mouseyy, prev_mousey; extern char BUFFER []; extern int line_height; levels::levels (const string& s) { name = s; editing = lmb_clicked = paint = nsel = 0; selection = 0; chgl = 0; shftl = 0; paintl = 0; load (); if (editable) { const char* bt [] = {"Wrap", "Slide", "<<", ">>", "All", "None", "Invert", "+", "-", "x"}; button* b[] = {&cbwrap, &bslide, &blshift, &brshift, &ball, &bnone, &binvert, &plus, &minus, &cross}; click_listener* cl [] = {&cbwrap, &sll, &lsl, &rsl, &alll, &nonl, &invl, &pll, &mil, &crol}; for (int i = 0; i < 10; ++i) { button* pbi = b[i]; click_listener* pcl = cl[i]; pbi->set_text (bt[i]); pbi->set_listener (pcl); pcl->data = this; this->add_child (pbi); } this->add_child (&szr); MOVE (szr); szr.movlis = this; blshift.click_repeat = brshift.click_repeat = 1; bml.data = this; } } levels::~levels () { save (); removeallbookmarks (); if (selection) delete[] selection; } void levels::load () { string ignore; int left, bottom; ifstream file ((user_data_dir + name).c_str(), ios::in); file >> ignore >> n; last = n - 1; file >> ignore >> left >> bottom; file >> ignore >> elem; file >> ignore >> height; file >> ignore >> editable; file >> ignore >> saveable; int w; file >> ignore >> w; cbwrap.set_state (w,0); a = 0.7; a0 = a / 4; extents (left, bottom, left + n * elem, bottom + height); set_pos (left, bottom); values.resize (n); heights.resize (n); selection = new bool [n]; sel_sz = sizeof (bool) * n; memset (selection, 0, sel_sz); if (saveable) { int savings; file >> ignore >> savings; for (int i = 0; i < savings; ++i) { float h; file >> h >> selection[i]; heights[i] = h; values[i] = h * extents.height_1; } file >> nsel; } int nb; file >> ignore >> nb; if (nb) { bmk.resize (nb); for (int i = 0, y = minus.extents.bottom - state_button::SIZE2; i < nb; ++i) { bookmark* b = new bookmark (); b->set_pos (minus.extents.left, y); y -= state_button::SIZE2; b->set_listener (&bml); this->add_child (b); bmk[i] = b; int nid; file >> nid; vector& ids = b->ids; ids.resize (nid); for (int m = 0; m < nid; ++m) file >> ids[m]; } } editing = 0; } void levels::save () { ofstream file ((user_data_dir+name).c_str(), ios::out); if (file) { file << "num_levels " << n << endl; file << "lower_corner " << extents.left << spc << extents.bottom << endl; file << "element_width " << elem << endl; file << "height " << height << endl; file << "editable " << editable << endl; file << "saveable " << saveable << endl; file << "wrap " << cbwrap.state << endl; if (saveable) { file << "savings " << n << spc; for (int i = 0; i < n; ++i) file << heights[i] << spc << selection[i] << spc; file << nsel << endl; } else { file << "savings 0" << endl; } int j = bmk.size (); file << "bookmarks " << j << spc; if (j) { for (int i = 0; i < j; ++i) { bookmark* bi = bmk[i]; vector& ids = bi->ids; int n = ids.size (); file << n << spc; for (int m = 0; m < n; ++m) file << ids[m] << spc; } } } else dlog << "!!! couldnt save levels !!!" << endl; } int levels::stop_editing () { if (editing == FINISH) { editing = 0; return 1; } return 0; } int levels::handle_input () { prev_mousey = mousey; widget::handle_input (); int hne = hover && !editing; if (hne) calc_lev (); if (keypressed (SDLK_f)) { paint = !paint; if (paintl) paintl->paint (*this); } if (editable) { for (int i = 0, j = children.size(); i < j; ++i) { if (children[i]->handle_input ()) return 1; } if (lmb) { if (lmb_clicked == 0) { if (stop_editing () == 0) { if (hne) { if (SHIFT) { bool& k = selection [lev]; k = !k; if (k) ++nsel; else --nsel; } else { editing = STARTED; widget::focus = this; } } } } lmb_clicked = 1; } else { lmb_clicked = 0; if (editing) { if (wheel) { mousey -= wheel; warp_mouse (mousex, mousey); } if (paint) calc_lev (); calc_hgt_val (); int dh = set (lev, val, hgt); int uml = 0; if (selection[lev] && !SHIFT ) uml = update_mul_lev (dh); if (chgl && (dh || uml)) chgl->changed (*this); editing = FINISH; } else { if (widget::focus == this) widget::focus = 0; } } } return 1; } int levels::update_mul_lev (int dh) { float dv = dh * extents.height_1; int ret = 0; for (int i = 0; i < n; ++i) { if ((i != lev) && selection[i]) { int& hi = heights[i]; float& vi = values[i]; int hji = hi + dh; float vji = vi + dv; if (hji < 0) hji = 0; else if (hji > extents.height) hji = extents.height; if (vji < 0.0f) vji = 0.0f; else if (vji > 1.0f) vji = 1.0f; hi = hji; vi = vji; ret = 1; } } return ret; } void levels::calc_lev () { lev = (mousex - extents.left) / elem; if (lev > last || lev < 0) lev = -1; } void levels::calc_hgt_val () { hgt = mouseyy - extents.bottom; clamp (0, hgt, extents.height); val = hgt * extents.height_1; } void levels::clear_hgt_val () { for (int i = 0; i < n; ++i) values[i] = heights[i] = 0; } void levels::draw () { glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); int i = 0, x = extents.left, ds = elem - 2; if (extents.left < 0) { i = -extents.left / elem; x = 0; } for (;i < n; ++i) { int l = x + 1, r = x + ds; glColor4f (clr.r, clr.g, clr.b, a0); glRecti (l, extents.bottom, r, extents.top); float dc = selection[i] * 0.4; glColor4f (clr.r + dc * clr.r, clr.g + dc * clr.g, clr.b + dc * clr.b, a); glRecti (l, extents.bottom, r, extents.bottom + heights[i]); x += elem; extern viewport view; if (x > view.xmax) break; } glDisable (GL_BLEND); sprintf (BUFFER, "%d/%.3f", lev+1, lev > -1? values[lev]:-1); draw_string (BUFFER, extents.left, extents.bottom - line_height, 0); if (editable) for (int i = 0, j = children.size(); i < j; ++i) children[i]->draw (); } int levels::change (int i, float dv) { if (i > -1 && i < n) { float& vi = values[i]; vi += dv; int result = clamp (0, vi, 1); heights[i] = (int) (vi * extents.height + 0.5); return result; } return 0; } void levels::set_only (int i, float v) { if (i > -1 && i < n) { clamp (0, v, 1); values[i] = v; heights[i] = (int)(v * extents.height + 0.5); } } int levels::set (int i, float v, int h) { // from ui if (i > -1 && i < n) { int& hi = heights[i]; int dh = h - hi; hi = h; float& vi = values[i]; if (vi != v) { // bcos from ui vi = v; } return dh; } return 0; } void levels::update () { if (chgl) chgl->changed (*this); } void levels::chkpos () { extern viewport view; if (!view.inside (extents.left, extents.bottom)) extents.lower_corner (0, 0); } void levels::reheight () { for (int i = 0; i < n; ++i) { float v = values[i]; int h = v * height + 0.5; heights[i] = h; } } int levels::lshift () { float v0 = values[0]; int h0 = heights[0]; int wrap = cbwrap.state; if (wrap == 0) { if (h0) return 0; } for (int i = 0, j = 1; i < last; ++i, ++j) { values[i] = values[j]; heights[i] = heights[j]; } float& vl = values[last]; int& hl = heights[last]; if (wrap) { vl = v0; hl = h0; } else { vl = 0; hl = 0; } if (shftl) shftl->shifted (*this); return 1; } int levels::rshift () { float vl = values[last]; int hl = heights[last]; int wrap = cbwrap.state; if (wrap == 0) { if (hl) return 0; } for (int j = last, i = last - 1; j > 0; --j, --i) { values[j]=values[i]; heights[j]=heights[i]; } float& v0 = values[0]; int& h0 = heights[0]; if (wrap) { v0 = vl; h0 = hl; } else { v0 = 0; h0 = 0; } if (shftl) shftl->shifted (*this); return 1; } void levels::selall () { nsel = 0; for (int i = 0; i < n; ++i) { if (heights[i]) { selection[i] = 1; ++nsel; } } clearbookmarks (); } void levels::selnon () { for (int i = 0; i < n; ++i) selection[i] = 0; nsel = 0; clearbookmarks (); } void levels::invsel () { for (int i = 0; i < n; ++i) { bool& si = selection[i]; if (si) { si = 0; --nsel; } else if (heights[i]) { si = 1; ++nsel; } } clearbookmarks (); } CLICKED_BUTTON (levels, alllis) { levels* l = (levels*) data; l->selall(); } CLICKED_BUTTON (levels, nonlis) { levels* l = (levels*) data; l->selnon(); } CLICKED_BUTTON (levels, invlis) { levels* l = (levels*) data; l->invsel(); } CLICKED_BUTTON (levels, lshiftlis) { levels* l = (levels*) data; l->lshift (); } CLICKED_BUTTON (levels, rshiftlis) { levels* l = (levels*) data; l->rshift (); } CLICKED_BUTTON (levels, pluslis) { levels* l = (levels*) data; l->addbookmark (); } void levels::slide::clicked (button& b) { if (!mouse_slider0.active) { mouse_slider0.add (this); activate_mouse_slider (); } } void levels::slide::moused (int dir, double scl) { levels* l = (levels*) data; if (dir > 0) l->rshift (); else l->lshift (); } void levels::set_pos (int x, int y) { widget::set_pos (x, y); extern int line_height; int bx = extents.right + 3, by = extents.top - line_height; blshift.set_pos (bx, by); brshift.set_pos (bx + 28, by); by -= line_height; { button* b[] = {&cbwrap, &bslide, &ball, &bnone, &binvert}; for (int i = 0; i < 5; ++i) { button& bi = *b[i]; bi.set_pos (bx, by); by -= line_height; } } { button* b[] = {&plus, &minus, &cross}; for (int i = 0; i < 3; ++i) { b[i]->set_pos (bx, by); bx += 20; } } szr.set_pos (extents.right + elem, extents.bottom); } void levels::addbookmark () { if (nsel) { bookmark* bm = new bookmark (); int bs = bmk.size (); if (bs) { int lb = bs - 1; bookmark* plb = bmk [lb]; bm->set_pos (minus.extents.left, plb->extents.bottom - state_button::SIZE2); } else { bm->set_pos (minus.extents.left, minus.extents.bottom - state_button::SIZE2); } for (int i = 0; i < n; ++i) if (selection[i]) bm->ids.push_back (i); clearbookmarks (); bm->set_state (1, 0); bm->set_listener (&bml); bmk.push_back (bm); this->add_child (bm); cons << GREEN << "Bookmarked " << nsel << spc << name << eol; } else { cons << RED << "No " << name << " selected to bookmark. SHIFT+click " << name << " to select." << eol; } } void levels::removebookmark () { for (vector::iterator i = bmk.begin (), j = bmk.end (); i != j; ) { bookmark* b = *i; if (b->state) { i = bmk.erase (i); j = bmk.end (); this->remove_child (b); delete b; } else { ++i; } } } void levels::removeallbookmarks () { for (int i = 0, j = bmk.size (); i < j; ++i) { bookmark* pbi = bmk[i]; this->remove_child (pbi); delete pbi; } bmk.clear (); } void levels::clearbookmarks () { for (int i = 0, j = bmk.size (); i < j; ++i) bmk[i]->set_state (0,0); } CLICKED_CHECKBUTTON (levels, bmlis) { bookmark& b = dynamic_cast(cb); int s = b.state; levels& l = *( (levels*) data); if (SHIFT) ; else { l.selnon (); if (s == 0) s = 1; b.set_state (s, 0); } int sl [] = {-1, 1}; for (int i = 0, j = l.bmk.size (); i < j; ++i) { if (&b == l.bmk[i]) { vector& ids = b.ids; int n = ids.size (); for (int m = 0; m < n; ++m) l.selection[ids[m]] = s; l.nsel += (n * sl[s]); } } } CLICKED_BUTTON (levels, minuslis) { ((levels*) data)->removebookmark (); } CLICKED_BUTTON (levels, crosslis) { ((levels*) data)->removeallbookmarks (); } /*MOVED (levels,szrlis) { levels* pl = (levels *) data; l->sized (); }*/ void levels::moved () { if (extents.top > szr.extents.bottom) { height = extents.height = extents.top - szr.extents.bottom; set_pos (posx, szr.posy); reheight (); } } din-51.1.1/src/noiser.h0000664000175000017500000000233714022054645011542 00000000000000/* * noiser.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __noiser #define __noiser #include "solver.h" #include "random.h" #include "beat2value.h" #include "listeners.h" #include struct noiser { static multi_curve interp; static curve_editor ed; static noise_interp_lis lis; struct value_dat { float cur; float next; float delta; value_dat () { cur = next = delta = 0.0f;} } value; float spread; rnd random_value; struct samples_dat { int cur; int due; int duei; float next; float err; float derr; samples_dat () { cur = due = duei = 0; next = err = derr = 0.0f; } } samples; struct alpha_dat { float val; float warp; float delta; alpha_dat () {val = warp = delta = 0.0f;} } alpha; void calc_delta_alpha (); solver warp; float last_vol; noiser (); void operator() (float* L, float* R, int n, float vol); void operator() (float* L, float* R, int n, float* vola); void set_samples (float s); void set_spread (float s); void set_value (float v); }; std::ofstream& operator<< (std::ofstream& o, noiser& n); #endif din-51.1.1/src/mocap.cc0000664000175000017500000000207314022054457011476 00000000000000/* * mocap.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "mocap.h" #include "basic_editor.h" #include using namespace std; mocap::mocap () { clear (); } void mocap::clear () { x.clear (); y.clear (); x.reserve (1); y.reserve (1); cur = 0; state = empty; } int mocap::get (float& gx, float& gy, int dir) { if (cur >= x.size ()) cur = 0; else if (cur < 0) cur = x.size () - 1; gx = x[cur]; gy = y[cur]; cur += dir; return 1; } int mocap::add (float wx, float wy) { x.push_back (wx); y.push_back (wy); state = capturing; return 1; } void mocap::finish (basic_editor* b) { for (int i = 0, j = x.size (); i < j; ++i) { float wx = x[i], wy = y[i]; b->win2obj (wx, wy, x[i], y[i]); // win to obj space } cur = 0; state = finished; } int mocap::operator() () { return (state == finished); } din-51.1.1/src/alarm.cc0000664000175000017500000000132714022054442011466 00000000000000/* * alarm.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "alarm.h" #include "chrono.h" alarm_t::alarm_t (double tt) { triggert = tt; startt = nowt = 0; elapsed = 0; active = 0; } int alarm_t::operator() (double t) { nowt = t; elapsed = nowt - startt; if (elapsed < triggert) return 0; else { startt = nowt; return 1; } } double alarm_t::operator() () { return (elapsed * 1.0 / triggert); } void alarm_t::start () { startt = ui_clk (); elapsed = 0.0; active = 1; } void alarm_t::stop () { active = 0; } din-51.1.1/src/note.cc0000664000175000017500000000321714022054460011337 00000000000000/* * note.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "note.h" #include "main.h" #include "scale_info.h" #include "utils.h" #include #include extern char BUFFER []; extern const char spc; extern int NOTATION; note::note () { hz = 0; step = 0; scale_pos = 0; octave = 0; } void note::set_freq (float f) { hz = f; hz2step (hz, step); sprintf (BUFFER, "%0.3f", hz); hz_name = BUFFER; } void note::set_freq (float key, float interval) { set_freq (key * interval * pow (2.0, octave)); } void note::set_name (const std::string& n) { name = n; } void note::set_name (const std::string& interval, int offset) { if (NOTATION == WESTERN) { extern std::map NOTE_POS; extern const char* WESTERN_FLAT []; int np = NOTE_POS[interval]; name = WESTERN_FLAT[(offset + np) % 12]; } else { set_name (interval); } } void note::change_scale_pos (int j, scale_info& si) { int i = sign(j); int k = abs(j); while (k--) { scale_pos += i; if (scale_pos < 0) { scale_pos = si.second_last_note; --octave; } else if (scale_pos > si.last_note) { scale_pos = 1; ++octave; } } } std::ofstream& note::save (std::ofstream& f) { f << name << spc << hz_name << spc << hz << spc << step << spc << scale_pos << spc << octave << spc; return f; } std::ifstream& note::load (std::ifstream& f) { f >> name >> hz_name >> hz >> step >> scale_pos >> octave; return f; } din-51.1.1/src/cosine.h0000664000175000017500000000062214022054641011512 00000000000000/* * cosine.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #ifndef __COSINE #define __COSINE #include #include "funktion.h" struct cosine : funktion { float operator() (float a, float ea) { return cos (a); } }; #endif din-51.1.1/src/textboard.cc0000664000175000017500000000634014022054462012370 00000000000000/* * textboard.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include "textboard.h" #include "dingl.h" #include "font.h" #include "basic_editor.h" #include "mondrian.h" #include using namespace std; extern viewport view; extern int line_height; void textboard::draw (int shapeform) { glMatrixMode (GL_PROJECTION); glPushMatrix (); glLoadIdentity (); glOrtho (0, view.xmax, 0, view.ymax, -1, 1); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); for (list::iterator i = texts.begin (), j = texts.end (); i != j; ++i) { text& t = *i; if (t.type == text::normal) { glColor3f (t.r, t.g, t.b); draw_string (t.txt, t.vx, t.vy); } else if (t.type == text::vline && !shapeform) { // draw vertical line with label draw_line (t.vx, 0, t.vx, view.ymax); glColor3f (t.r, t.g, t.b); draw_string (t.txt, t.vx, t.vy); } else { // draw horizontal line with label draw_line (0, t.vy, view.xmax, t.vy); glColor3f (t.r, t.g, t.b); draw_string (t.txt, t.vx, t.vy); } } glPopMatrix (); glMatrixMode (GL_PROJECTION); glPopMatrix (); glMatrixMode (GL_MODELVIEW); } void textboard::draw_line (int x1, int y1, int x2, int y2) { static int pts [4] = {0}; glColor3f (0.3f, 0.3f, 0.3f); pts[0]=x1;pts[1]=y1; pts[2]=x2;pts[3]=y2; glVertexPointer (2, GL_INT, 0, pts); glDrawArrays (GL_LINES, 0, 2); } void textboard::clear () { for (list::iterator i = texts.begin (), j = texts.end (); i != j;) { text& ti = *i; if (ti.state == text::temporary) { i = texts.erase (i); j = texts.end (); } else ++i; } } void textboard::refresh (basic_editor* b, float dwx, float dwy, float dvx, float dvy) { static const int spc = 3; extern viewport view; float wx, wy; for (list::iterator i = texts.begin (), j = texts.end (); i != j; ++i) { text& ti = *i; b->obj2win (ti.wx, ti.wy, wx, wy); wx += dwx; wy += dwy; win2view (wx, wy, ti.vx, ti.vy, b->win, view); ti.vx += dvx; ti.vy += dvy; if (ti.type == text::hline) ti.vx = spc; else if (ti.type == text::vline) ti.vy = line_height; } } void textboard::refresh (mondrian* b) { for (list::iterator i = texts.begin (), j = texts.end (); i != j; ++i) { text& ti = *i; float wx, wy; b->obj2win (ti.wx, ti.wy, wx, wy); win2view (wx, wy, ti.vx, ti.vy, b->win, view); } } void textboard::load (ifstream& file) { string ignore, txt; float r, g, b, wx, wy; int type, ntexts; file >> ignore >> ntexts; for (int i = 0; i < ntexts; ++i) { file >> txt >> wx >> wy >> r >> g >> b >> type; add (text (txt, wx, wy, r, g, b, text::permanent, type)); } } void textboard::save (ofstream& file) { static const char spc = ' '; int ntexts = texts.size (); file << "num_labels " << ntexts << endl; for (list::iterator i = texts.begin (), j = texts.end (); i != j; ++i) { text& ti = *i; if (ti.type != text::normal) { file << ti.txt << spc << ti.wx << spc << ti.wy << spc << ti.r << spc << ti.g << spc << ti.b << spc << ti.type << endl; } } } din-51.1.1/src/basic_editor.cc0000664000175000017500000002526514061270400013025 00000000000000/* * basic_editor.cc * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * DIN Is Noise is released under GNU Public License 2.0 * For more information, please visit https://dinisnoise.org/ */ #include #include #include "main.h" #include "input.h" #include "font.h" #include "console.h" #include "basic_editor.h" #include "solver.h" #include "widget.h" #include "ui_list.h" using namespace std; extern std::string user_data_dir; extern viewport view; extern char BUFFER []; extern int wheel; extern int can_wheel (); basic_editor::basic_editor () { snap_what = SNAP_NONE; edit_sustain = 0; kbkb_attack_editor = 0; lmb_clicked = 0; pan = zoom = 1; ed = 1; draw_guide = 0; ++ref; } basic_editor::~basic_editor () { if (--ref == 0) { if (gl_pts) { dlog << "cleared basic_editor::gl_pts @ " << gl_pts << endl; delete[] gl_pts; } } } void basic_editor::load (const std::string& fname) { ifstream file ((user_data_dir + fname).c_str (), ios::in); if (!file) return; load (file); } void basic_editor::load (ifstream& file) { std::string ignore; file >> ignore >> name; float l, b, r, t; file >> ignore >> l >> b >> r >> t; win.set (l, b, r, t); file >> ignore >> win_chunk.x >> win_chunk.y; file >> ignore >> obj_chunk.x >> obj_chunk.y; win_per_obj (win_chunk.x / obj_chunk.x, win_chunk.y / obj_chunk.y); obj_per_win (obj_chunk.x / win_chunk.x , obj_chunk.y / win_chunk.y); file >> ignore >> snap_what; set_snap (snap_what); file >> ignore >> win_resolution; float dummy1 = 0, dummy2 = 0; win2obj (win_resolution, dummy1, obj_resolution, dummy2); } void basic_editor::save (ofstream& file) { //file << "id " << id << endl; file << "editor " << name << endl; file << "window " << win.left << ' ' << win.bottom << ' ' << win.right << ' ' << win.top << endl; file << "win_chunk " << win_chunk.x << ' ' << win_chunk.y << endl; file << "obj_chunk " << obj_chunk.x << ' ' << obj_chunk.y << endl; file << "snap " << snap_what << endl; file << "win_resolution " << win_resolution << endl; } void basic_editor::calc_win_mouse () { win.update_mouse (); } int basic_editor::handle_input () { if (kbkb_attack_editor) { if (lmb) { if (lmb_clicked == 0) { if (edit_sustain) edit_sustain = 0; else {if (inbox (susbox, win.mousex, win.mousey)) edit_sustain = 1;} lmb_clicked = 1; } } else { if (edit_sustain) { float sx, sy; snap (sx, sy); float cx, cy; win2obj (sx, sy, cx, cy); _gotog.set (cx); } lmb_clicked = 0; } } // mouse capture if (mocap0.state == mocap::capturing) mocap0.add (win.mousex, win.mousey); // movement if (can_wheel()) do_zoom (-wheel * zoom); double pan_rept = window::PAN_REPEAT, zoom_rept = window::ZOOM_REPEAT; if (keypressedd (SDLK_a, pan_rept, pan_rept)) do_panx (-pan); else if (keypressedd (SDLK_d, pan_rept, pan_rept)) do_panx (+pan); else if (keypressedd (SDLK_w, pan_rept, pan_rept)) do_pany (+pan); else if (keypressedd (SDLK_s, pan_rept, pan_rept)) do_pany (-pan); else if (keypressed (SDLK_g)) draw_guide = !draw_guide; // snap else if (keypressed (SDLK_x)) set_snap (SNAP_X); else if (keypressed (SDLK_y)) set_snap (SNAP_Y); else if (keypressed (SDLK_b)) set_snap (SNAP_BOTH); else if (keypressed (SDLK_n)) set_snap (SNAP_NONE); else if (keypressedd (SDLK_F5)) { if (SHIFT) set_win_chunk (win_chunk.x, --win_chunk.y); else set_win_chunk (--win_chunk.x, win_chunk.y); } else if (keypressedd (SDLK_F6)) { if (SHIFT) set_win_chunk (win_chunk.x, ++win_chunk.y); else set_win_chunk (++win_chunk.x, win_chunk.y); } else if (keypressed (SDLK_F7)) { toggle_mouse_capture (); } if (!mouse_slider0.active) { if (keypressedd (SDLK_q, zoom_rept, zoom_rept)) do_zoom (+zoom); else if (keypressedd (SDLK_e, zoom_rept, zoom_rept)) do_zoom (-zoom); } return 1; } void basic_editor::set_win_chunk (int x, int y) { if (x < 1) x = 1; if (y < 1) y = 1; win_chunk.x = x; win_chunk.y = y; float wx = win_chunk.x / obj_chunk.x, wy = win_chunk.y / obj_chunk.y; win_per_obj (wx, wy); obj_per_win (1.0f/wx, 1.0f/wy); } int basic_editor::is_snapx () { return ((snap_what == SNAP_X) || (snap_what == SNAP_BOTH)); } int basic_editor::is_snapy () { return ((snap_what == SNAP_Y) || (snap_what == SNAP_BOTH)); } void basic_editor::snap (float& x, float& y) { x = win.mousex; y = win.mousey; if (SHIFT) { // x stays, wont snap if (shft_clk.noted == 0) shft_clk.note (x, y); x = shft_clk.pt.x; do_snapy (y); ctrl_clk.noted = 0; } else if (CTRL) { // y stays, wont snap if (ctrl_clk.noted == 0) ctrl_clk.note (x, y); y = ctrl_clk.pt.y; do_snapx (x); shft_clk.noted = 0; } else { // both may snap do_snapx (x); do_snapy (y); ctrl_clk.noted = 0; shft_clk.noted = 0; } } void basic_editor::do_snapx (float& x) { if (is_snapx()) { float s = win.mousex / win_chunk.x; if (s < 0) s -= 0.5; else s += 0.5; x = (int) s * win_chunk.x; } } void basic_editor::do_snapy (float& y) { if (is_snapy()) { float s = win.mousey / win_chunk.y; if (s < 0) s -= 0.5; else s += 0.5; y = (int) s * win_chunk.y; } } void basic_editor::project () { glMatrixMode (GL_PROJECTION); glPushMatrix (); glLoadIdentity (); glOrtho (win.left, win.right, win.bottom, win.top, -1, 1); glMatrixMode (GL_MODELVIEW); glPushMatrix (); glLoadIdentity (); } void basic_editor::unproject () { glMatrixMode (GL_MODELVIEW); glPopMatrix (); glMatrixMode (GL_PROJECTION); glPopMatrix (); } void basic_editor::draw () { // must always be wrapped by project, unproject draw_snaps (); } void basic_editor::draw_cursor () { if (hide_cursor) return; glMatrixMode (GL_PROJECTION); glPushMatrix (); glLoadIdentity (); glOrtho (0, view.xmax, 0, view.ymax, 0, 1); float wx, wy; snap (wx, wy); win2obj (wx, wy, cursor_x, cursor_y); int vx, vy; win2view (wx, wy, vx, vy, win, view); /*int spacing, dummy; float whx = win.left+win.handle_radius, why = win.bottom; win2view (whx, why, spacing, dummy, win, view); */ const int spacing = 12; int vxs = vx + spacing; if (draw_guide) { glColor3f (0.20f, 0.20f, 0.20f); gl_pts[0]=0; gl_pts[1]=vy; gl_pts[2]=vx - spacing; gl_pts[3]=vy; gl_pts[4]=vxs; gl_pts[5]=vy; gl_pts[6]=view.xmax; gl_pts[7]=vy; gl_pts[8]=vx; gl_pts[9]=0; gl_pts[10]=vx; gl_pts[11]=vy - spacing; gl_pts[12]=vx; gl_pts[13]=vy + spacing; gl_pts[14]=vx; gl_pts[15]=view.ymax; glVertexPointer (2, GL_FLOAT, 0, gl_pts); glDrawArrays (GL_LINES, 0, 8); } glColor3f (1, 1, 1); sprintf (BUFFER, " %.3f, %.3f", cursor_x, cursor_y); draw_string (BUFFER, vxs, vy); extern int line_height; if (edit_sustain) { vy -= line_height; extern gotog _gotog; sprintf (BUFFER, " sustain @ %.3f", _gotog.g); draw_string (BUFFER, vx, vy); } if (cursor_mesg != "") { glColor3f (1, 1, 0.5); vy -= line_height; draw_string (cursor_mesg, vx, vy); } glPopMatrix (); } void basic_editor::update_snaps () { int l, b, r, t; if (is_snapx()) { l = (int)(win.left / win_chunk.x); startx = l * win_chunk.x; r = (int)(win.right / win_chunk.x); endx = r * win_chunk.x; xlines.clear (); nxpts = 0; while (startx <= endx) { xlines.push_back (startx); xlines.push_back (win.bottom); xlines.push_back (startx); xlines.push_back (win.top); startx += win_chunk.x; nxpts += 2; } } if (is_snapy ()) { b = (int)(win.bottom / win_chunk.y); starty = b * win_chunk.y; t = (int)(win.top / win_chunk.y); endy = t * win_chunk.y; ylines.clear (); nypts = 0; while (starty <= endy) { ylines.push_back (win.left); ylines.push_back (starty); ylines.push_back (win.right); ylines.push_back (starty); starty += win_chunk.y; nypts += 2; } } } void basic_editor::draw_snaps () { // // draw snap lines // static const float sr = 0.1f, sg = sr, sb = sg; // snap color glColor3f (sr, sg, sb); if (is_snapx()) { // lines along y glVertexPointer (2, GL_INT, 0, xlines.data ()); glDrawArrays (GL_LINES, 0, nxpts); } if (is_snapy()) { // lines along x glVertexPointer (2, GL_INT, 0, ylines.data ()); glDrawArrays (GL_LINES, 0, nypts); } } void basic_editor::calc_visual_params () { if (kbkb_attack_editor) susbox (susx - win.handle_radius, win.top - win.sus_handle_radius, susx + win.handle_radius, win.top); tb.refresh (this); update_snaps (); } void basic_editor::update_sustain (float f) { float ox = f, oy = 0; obj2win (ox, oy, susx, susy); calc_visual_params (); } void basic_editor::do_panx (int dir) { win.panx (dir); calc_visual_params (); } void basic_editor::do_pany (int dir) { win.pany (dir); calc_visual_params (); } void basic_editor::do_zoom (int dir) { win.zoom (dir); calc_visual_params (); } void basic_editor::set_snap (int what) { snap_what = what; update_snaps (); ::set_snap (what); } void basic_editor::start_mouse_capture () { mocap0.clear (); mocap0.state = mocap::capturing; cons << GREEN << "Capturing mouse" << eol; } void basic_editor::stop_mouse_capture () { if (mocap0.state == mocap::capturing) { mocap0.finish (this); cons << GREEN << "Captured mouse!" << eol; } } void basic_editor::toggle_mouse_capture () { if (mocap0.state != mocap::capturing) start_mouse_capture (); else stop_mouse_capture (); } void basic_editor::obj2win (const float& ox, const float& oy, float& wx, float& wy) { wx = win_per_obj.x * ox; wy = win_per_obj.y * oy; } void basic_editor::obj2win (const point& v, float& wx, float& wy) { obj2win (v.x, v.y, wx, wy); } void basic_editor::win2obj (const float& wx, const float& wy, float& ox, float& oy) { ox = obj_per_win.x * wx; oy = obj_per_win.y * wy; } void basic_editor::obj2view (const float& ox, const float& oy, int& vx, int& vy) { float wx, wy; obj2win (ox, oy, wx, wy); win2view (wx, wy, vx, vy, win, view); } void basic_editor::view2obj (const int& vx, const int& vy, float& ox, float& oy) { float wx, wy; view2win (vx, vy, wx, wy, view, win); win2obj (wx, wy, ox, oy); } void basic_editor::obj2mouse (const float& ox, const float& oy) { int vx, vy; obj2view (ox, oy, vx, vy); warp_mouse (vx, view.ymax - vy); } click_point_t::click_point_t () : noted (0) {} void click_point_t::note (float x, float y) { pt.x = x; pt.y = y; noted = 1; } din-51.1.1/src/tcl_interp.h0000664000175000017500000000137314022053525012401 00000000000000/* * tcl_interp.h * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath * For more information, please visit http://dinisnoise.org/ */ #ifndef __tcl #define __tcl #include #include #include struct tcl_interp { // tcl interpreter Tcl_Interp *interp; tcl_interp (); ~tcl_interp (); void setup (Tcl_Interp* pi); std::string result; int result_status; tcl_interp& operator() (const std::string& command); // execute command void add_din_specific (); }; typedef int (*tclcmd)(ClientData cd, Tcl_Interp* ti, int objc, Tcl_Obj* CONST objv[]); int tcl_run (ClientData cd, Tcl_Interp* ti, int objc, Tcl_Obj* CONST objv[]); extern tcl_interp interpreter; #endif din-51.1.1/src/factory/0000775000175000017500000000000014073336000011606 500000000000000din-51.1.1/src/factory/start-end.help.tcl0000664000175000017500000000266713351024045015076 00000000000000set start-end(name) N/A set start-end(short) N/A set start-end(purpose) {For each assigned MIDI #CC, go from a start value to an end value and run a command for each inbetween value. can be used to set key, set bpm, set AM and FM depth, set drone master volumes & more.} set start-end(invoke) {load-patch start-end ;# loads this patch} set start-end(help) {} set start-end(examples) {assign ;# no arguments -> just print current assignments ;# assign MIDI #CC ie slider/knob 1 to go from current key to an octave above assign 1 [key value] [expr $8 * [key value]] key ;# assign MIDI #CC 2 to go from current key to 2 octaves above assign 2 [key value] [expr $8 * $8 * [key value]] key ;# assign MIDI #CC 3 to go from current key to perfect-fourth an octave above assign 3 [key value] [expr $8 * $4 * [key value]] key ;# assign MIDI #CC 4 to go from BPM of gater to 4 times BPM of gater assign 4 [get-bpm gr] [expr 4 * [get-bpm gr]] {set-bpm gr} 8 and 4 are built in interval variables in din with values determined by the current tuning ($8 & $4 substitute their values ie 2 & 1.33333 respectively. see TCL documentation). ;# must use {} to separate & include words properly. ;# see TCL documentation ;# assign MIDI #CC 5 to set fm_depth variable from 0 to 100. assign 5 0 100 set-var fm_depth ;# wrong :( assign 5 0 100 {set-var fm_depth} ;# right :) ;# retain start/end as above ie 0 & 100 but change command to set-bpm gr assign 5 . . {set-bpm gr}} din-51.1.1/src/factory/rose_milker_cos.ed0000664000175000017500000000072113675551226015237 00000000000000editor rose_milker-cos window -2260.1 -2390.72 4419.51 2618.99 win_chunk 100 100 obj_chunk 0.05 0.05 snap 3 win_resolution 1 carry_tangents 1 mirror_tangents 0 sine_enabled 1 label_vertex 0 num_labels 5 silence 0 0 0 1 1 0 +max 0 1 1 0 0 0 -max 0 -1 1 0 0 0 start 0 0.5 1 1 0.5 1 end 1 0.5 1 1 0.5 1 fft_enabled 1 samples_enabled 0 hz 44 nperiods 3 is_waveform_editor 1 draw_curve_only 0 sustain_editing 0 overlay 1 curcrv 0 mirror_axis 0 din-51.1.1/src/factory/get-kern.help.tcl0000664000175000017500000000104713351024045014700 00000000000000set get-kern(name) get-kern set get-kern(short) gk set get-kern(purpose) {get kerning amount between two characters of the font} set get-kern(invoke) {get-kern OR gk character1 character2} set get-kern(help) {} set get-kern(examples) {get-kern a b ;# prints kerning amount when b follows a. get-kern b a ;# prints kerning amount when a follows b. get-kern . a ;# prints kerning amount for each character when it precedes a. get-kern a . ;# prints kerning amount for each character when it follows a. gk i j ;# prints kerning amount when j follows i.} din-51.1.1/src/factory/range-modulation.ed0000664000175000017500000000071313453060246015315 00000000000000editor range-modulation window -1241 -898.518 3531.13 2680.58 win_chunk 100 100 obj_chunk 0.05 0.05 snap 3 win_resolution 1 carry_tangents 1 mirror_tangents 0 sine_enabled 1 label_vertex 0 num_labels 5 zero 0 0 1 0 0 0 max 0 1 0 1 0 0 -max 0 -1 0 1 0 0 zero 0 0 1 1 0.5 1 beat-1 1 0 1 1 0.5 1 fft_enabled 0 samples_enabled 0 hz 440 nperiods 2 is_waveform_editor 0 draw_curve_only 0 sustain_editing 0 overlay 0 curcrv 0 mirror_axis 0 din-51.1.1/src/factory/Sine_Mixer0000664000175000017500000000004713351024045013515 00000000000000num_points 100 make_shapeform 0 type 0 din-51.1.1/src/factory/range-width-height.ed0000664000175000017500000000070213463245055015531 00000000000000editor global-range-width-height window -1065.48 -427.563 3098.95 2695.76 win_chunk 100 100 obj_chunk 0.05 0.05 snap 0 win_resolution 1 carry_tangents 1 mirror_tangents 0 sine_enabled 1 label_vertex 0 num_labels 4 min 0 0 1 0 0 0 default 0 1 0 1 1 0 first 0 0 1 1 1 1 last 1 0 1 1 1 1 fft_enabled 0 samples_enabled 0 hz 440 nperiods 2 is_waveform_editor 0 draw_curve_only 0 sustain_editing 0 overlay 0 curcrv 0 mirror_axis 0 din-51.1.1/src/factory/d_superformula0000664000175000017500000000016213643202625014506 00000000000000_Auto_apply 500 384 _Apply 613 384 _m 555 513 _n1 553 489 _n2 547 465 _n3 547 440 _Points 507 416 _Browse 681 382 din-51.1.1/src/factory/morph_target.crv0000664000175000017500000001407613351024045014746 00000000000000name circle_12_peano num_vertices 61 vertex_0 0.499998 1 left_tangent_0 0.499998 1 right_tangent_0 0.499998 1 vertex_1 0.324998 0.953108 left_tangent_1 0.324998 0.953108 right_tangent_1 0.324998 0.953108 vertex_2 0.493808 0.323108 left_tangent_2 0.493808 0.323108 right_tangent_2 0.493808 0.323108 vertex_3 0.343808 0.282916 left_tangent_3 0.343808 0.282916 right_tangent_3 0.343808 0.282916 vertex_4 0.174998 0.912916 left_tangent_4 0.174998 0.912916 right_tangent_4 0.174998 0.912916 vertex_5 -1.92167e-006 0.866024 left_tangent_5 -1.90735e-006 0.866024 right_tangent_5 -1.92167e-006 0.866024 vertex_6 -0.128111 0.737915 left_tangent_6 -0.128111 0.737915 right_tangent_6 -0.128111 0.737915 vertex_7 0.333083 0.276724 left_tangent_7 0.333083 0.276724 right_tangent_7 0.333083 0.276724 vertex_8 0.223276 0.166916 left_tangent_8 0.223276 0.166916 right_tangent_8 0.223276 0.166916 vertex_9 -0.237918 0.628107 left_tangent_9 -0.237918 0.628107 right_tangent_9 -0.237918 0.628107 vertex_10 -0.366027 0.499998 left_tangent_10 -0.366027 0.499998 right_tangent_10 -0.366027 0.499998 vertex_11 -0.412917 0.324997 left_tangent_11 -0.412917 0.324997 right_tangent_11 -0.412917 0.324997 vertex_12 0.217084 0.156191 left_tangent_12 0.217084 0.156191 right_tangent_12 0.217084 0.156191 vertex_13 0.176892 0.00619077 left_tangent_13 0.176892 0.00619077 right_tangent_13 0.176892 0.00619077 vertex_14 -0.453109 0.174997 left_tangent_14 -0.453109 0.174997 right_tangent_14 -0.453109 0.174997 vertex_15 -0.5 -3.32843e-006 left_tangent_15 -0.5 -3.30806e-006 right_tangent_15 -0.5 -3.32843e-006 vertex_16 -0.453108 -0.175003 left_tangent_16 -0.453108 -0.175003 right_tangent_16 -0.453108 -0.175003 vertex_17 0.176892 -0.00619288 left_tangent_17 0.176892 -0.00619288 right_tangent_17 0.176892 -0.00619288 vertex_18 0.217085 -0.156193 left_tangent_18 0.217085 -0.156193 right_tangent_18 0.217085 -0.156193 vertex_19 -0.412915 -0.325003 left_tangent_19 -0.412915 -0.325003 right_tangent_19 -0.412915 -0.325003 vertex_20 -0.366023 -0.500003 left_tangent_20 -0.366023 -0.500003 right_tangent_20 -0.366023 -0.500003 vertex_21 -0.237914 -0.628112 left_tangent_21 -0.237914 -0.628112 right_tangent_21 -0.237914 -0.628112 vertex_22 0.223277 -0.166917 left_tangent_22 0.223277 -0.166917 right_tangent_22 0.223277 -0.166917 vertex_23 0.333085 -0.276725 left_tangent_23 0.333085 -0.276725 right_tangent_23 0.333085 -0.276725 vertex_24 -0.128106 -0.737919 left_tangent_24 -0.128106 -0.737919 right_tangent_24 -0.128106 -0.737919 vertex_25 3.84334e-006 -0.866028 left_tangent_25 3.8445e-006 -0.866028 right_tangent_25 3.84334e-006 -0.866028 vertex_26 0.175004 -0.912918 left_tangent_26 0.175004 -0.912918 right_tangent_26 0.175004 -0.912918 vertex_27 0.343809 -0.282916 left_tangent_27 0.343809 -0.282916 right_tangent_27 0.343809 -0.282916 vertex_28 0.49381 -0.323108 left_tangent_28 0.49381 -0.323108 right_tangent_28 0.49381 -0.323108 vertex_29 0.325005 -0.95311 left_tangent_29 0.325005 -0.95311 right_tangent_29 0.325005 -0.95311 vertex_30 0.500005 -1 left_tangent_30 0.500005 -1 right_tangent_30 0.500005 -1 vertex_31 0.675005 -0.953108 left_tangent_31 0.675005 -0.953108 right_tangent_31 0.675005 -0.953108 vertex_32 0.506193 -0.323108 left_tangent_32 0.506193 -0.323108 right_tangent_32 0.506193 -0.323108 vertex_33 0.656193 -0.282915 left_tangent_33 0.656193 -0.282915 right_tangent_33 0.656193 -0.282915 vertex_34 0.825005 -0.912915 left_tangent_34 0.825005 -0.912915 right_tangent_34 0.825005 -0.912915 vertex_35 1 -0.866023 left_tangent_35 1 -0.866023 right_tangent_35 1 -0.866023 vertex_36 1.12811 -0.737913 left_tangent_36 1.12811 -0.737913 right_tangent_36 1.12811 -0.737913 vertex_37 0.666918 -0.276723 left_tangent_37 0.666918 -0.276723 right_tangent_37 0.666918 -0.276723 vertex_38 0.776725 -0.166915 left_tangent_38 0.776725 -0.166915 right_tangent_38 0.776725 -0.166915 vertex_39 1.23792 -0.628105 left_tangent_39 1.23792 -0.628105 right_tangent_39 1.23792 -0.628105 vertex_40 1.36603 -0.499995 left_tangent_40 1.36603 -0.499995 right_tangent_40 1.36603 -0.499995 vertex_41 1.41292 -0.324994 left_tangent_41 1.41292 -0.324994 right_tangent_41 1.41292 -0.324994 vertex_42 0.782917 -0.15619 left_tangent_42 0.782917 -0.15619 right_tangent_42 0.782917 -0.15619 vertex_43 0.823108 -0.00618967 left_tangent_43 0.823108 -0.00618967 right_tangent_43 0.823108 -0.00618967 vertex_44 1.45311 -0.174994 left_tangent_44 1.45311 -0.174994 right_tangent_44 1.45311 -0.174994 vertex_45 1.5 6.65685e-006 left_tangent_45 1.5 6.64592e-006 right_tangent_45 1.5 6.65685e-006 vertex_46 1.45311 0.175007 left_tangent_46 1.45311 0.175007 right_tangent_46 1.45311 0.175007 vertex_47 0.823108 0.00619393 left_tangent_47 0.823108 0.00619393 right_tangent_47 0.823108 0.00619393 vertex_48 0.782915 0.156194 left_tangent_48 0.782915 0.156194 right_tangent_48 0.782915 0.156194 vertex_49 1.41291 0.325006 left_tangent_49 1.41291 0.325006 right_tangent_49 1.41291 0.325006 vertex_50 1.36602 0.500006 left_tangent_50 1.36602 0.500006 right_tangent_50 1.36602 0.500006 vertex_51 1.23791 0.628114 left_tangent_51 1.23791 0.628114 right_tangent_51 1.23791 0.628114 vertex_52 0.776723 0.166918 left_tangent_52 0.776723 0.166918 right_tangent_52 0.776723 0.166918 vertex_53 0.666914 0.276725 left_tangent_53 0.666914 0.276725 right_tangent_53 0.666914 0.276725 vertex_54 1.1281 0.737921 left_tangent_54 1.1281 0.737921 right_tangent_54 1.1281 0.737921 vertex_55 0.999993 0.866029 left_tangent_55 0.999993 0.866029 right_tangent_55 0.999993 0.866029 vertex_56 0.824993 0.912919 left_tangent_56 0.824993 0.912919 right_tangent_56 0.824993 0.912919 vertex_57 0.65619 0.282917 left_tangent_57 0.65619 0.282917 right_tangent_57 0.65619 0.282917 vertex_58 0.506189 0.323108 left_tangent_58 0.506189 0.323108 right_tangent_58 0.506189 0.323108 vertex_59 0.674992 0.95311 left_tangent_59 0.674992 0.95311 right_tangent_59 0.674992 0.95311 vertex_60 0.499992 1 left_tangent_60 0.499992 1 right_tangent_60 0.499992 1 curve_roughness 0.001 color 0.692311 0.75047 1 shapeform 1 din-51.1.1/src/factory/p_Spiraler0000664000175000017500000000004313351024045013547 00000000000000radius 1 turns 3 num_points 128 din-51.1.1/src/factory/scalelist0000664000175000017500000000135713351024045013443 00000000000000num_scales 27 bhairav 8 1 2b 3 4 5 6b 7 8 yaman 8 1 2 3 5b 5 6 7 8 todi 8 1 2b 3b 4 5 6b 7b 8 jog 7 1 3b 3 4 5 7b 8 multani 8 1 2b 3b 5b 5 6b 7 8 darbari 8 1 2 3b 4 5 6b 7b 8 minor 8 1 2 3b 4 5 6b 7b 8 malkauns 6 1 3b 4 6b 7b 8 bhoopali 6 1 2 3 5 6 8 shivaranjani 6 1 2 3b 5 6 8 marwa 7 1 2b 3 5b 6 7 8 blues 7 1 3b 4 5b 5 7b 8 all 13 1 2b 2 3b 3 4 5b 5 6b 6 7b 7 8 dorian 8 1 2 3b 4 5 6 7b 8 ionian 8 1 2 3 4 5 6 7 8 lydian 8 1 2 3 5b 5 6 7 8 mixolydian 8 1 2 3 4 5 6 7b 8 aeolian 8 1 2 3b 4 5 6b 7b 8 phrygian 8 1 2b 3b 4 5 6b 7b 8 locrian 8 1 2b 3b 4 5b 6b 7b 8 minor5 6 1 3b 4 5 7b 8 major5 6 1 3 4 5 7 8 5 3 1 5 8 45 4 1 4 5 8 457 5 1 4 5 7b 8 m6 8 1 2 3b 4 5 7b 7 8 major 8 1 2 3 4 5 6 7 8 din-51.1.1/src/factory/p_Number0000664000175000017500000000022313351024045013216 00000000000000type 5 color 255 255 39 double 2.71828 float 3.14159 int 1729 short 666 char A 0_equals 0.3 1_equals 1 scale 1 make_shapeform 1 wrap 1 din-51.1.1/src/factory/pythagoras.tuning0000664000175000017500000000023013351024045015131 00000000000000num_intervals 13 1 1.00000 2b 1.05349 2 1.12500 3b 1.18518 3 1.26562 4 1.33333 5b 1.40466 5 1.50000 6b 1.58024 6 1.68750 7b 1.77777 7 1.89843 8 2.00000 din-51.1.1/src/factory/sounding-board.osc0000664000175000017500000000007213351024045015147 00000000000000left 32 base 300 height 64 num_samples 368 visible 1 din-51.1.1/src/factory/d_min_max0000664000175000017500000000012213351024045013400 00000000000000_Min/Max 333 534 _Min 334 512 _Max 332 491 0x5ac0d8 381 512 0x5ac190 381 491 din-51.1.1/src/factory/midimap.patch.tcl0000664000175000017500000000244613754041412014763 00000000000000if 0 { /* * This file is part of din. * * din is copyright (c) 2006 - 2018 Jagannathan Sampath * For more information, please visit http://dinisnoise.org * * */ displays midi controller slider/knob/buttons/keys & misc others status } proc make-tracer {name} { proc $name [list status id val ch [list msg $name]] { echo "$msg: [format {mesg = %x id = %d value = %d channel = %x} $status $id $val $ch]" } } proc midimap {} { make-tracer midi-note-on make-tracer midi-note-off make-tracer midi-cc global echo_midi set echo_midi 1 } proc midi-program-change {status value} { echo "midi-program-change; status = $status, value = $value" } proc midi-pitch-bend {status ivalue fvalue} { echo "midi-pitch-bend, status = $status, ivalue = $ivalue, fvalue = $fvalue" } proc list-bpms {} { return {gr fm am os} } proc midi-clock {} { global midibpm set-bpm [list-bpms] $midibpm global echo_midi echo "MIDI bpm: $midibpm" } proc midi-start {} { foreach i [list-bpms] { set-beat $i [get-beat $i first] } global echo_midi echo "MIDI start" } proc unload_midimap {} { set procs {midi-note-on midi-note-off midi-cc midi-clock midi-start midi-program-change midi-pitch-bend} foreach i $procs { proc $i {args} {} } global echo_midi set echo_midi 0 } midimap din-51.1.1/src/factory/dot.crv0000664000175000017500000000035313351024045013032 00000000000000name dot num_vertices 3 vertex 0 0 left_tangent 0 0 right_tangent 0 0 vertex 0.05 1 left_tangent 0 1 right_tangent 0.1 1 vertex 0.1 0 left_tangent 0.1 0 right_tangent 0.1 0 curve_resolution 0.0005 color 1 0 0 shapeform 0 din-51.1.1/src/factory/spiraler_sin.ed0000664000175000017500000000071713675551141014553 00000000000000editor spiraler-sin window -2186.43 -2909.15 4996.13 2477.76 win_chunk 100 100 obj_chunk 0.05 0.05 snap 3 win_resolution 1 carry_tangents 1 mirror_tangents 0 sine_enabled 1 label_vertex 0 num_labels 5 silence 0 0 0 1 1 0 +max 0 1 1 0 0 0 -max 0 -1 1 0 0 0 start 0 0.5 1 1 0.5 1 end 1 0.5 1 1 0.5 1 fft_enabled 1 samples_enabled 0 hz 44 nperiods 3 is_waveform_editor 1 draw_curve_only 0 sustain_editing 0 overlay 1 curcrv 0 mirror_axis 0 din-51.1.1/src/factory/set-style.help.tcl0000664000175000017500000000124713351024045015117 00000000000000set set-style(name) set-style set set-style(short) ss set set-style(purpose) {set style of beat progression} set set-style(invoke) {set-style OR ss