├── README.md ├── ats-pd ├── cl.ats ├── crt.ats ├── help-atsreadhelp.pd ├── README └── help-atsread.pd ├── ats ├── doc │ ├── analysis.jpg │ ├── list-view.jpg │ ├── settings.jpg │ ├── smart_sel.jpg │ ├── edit-linear.jpg │ ├── edit-spline.jpg │ ├── header-view.jpg │ ├── main-screen.jpg │ ├── main-screen-res.jpg │ ├── synthesis-main.jpg │ ├── synthesis-time.jpg │ ├── main-screen-selection.jpg │ ├── main-screen-selection-zoom.jpg │ └── main-screen-selection-discont.jpg ├── reconf ├── TODO ├── src │ ├── atsh │ │ ├── help.c │ │ ├── atsh-mask.c │ │ ├── mask.c │ │ ├── about.c │ │ ├── my_curve.h │ │ ├── popup.c │ │ ├── progress.c │ │ ├── header.c │ │ ├── ats-header.c │ │ ├── atsh-undo.c │ │ ├── undo.c │ │ ├── help.h │ │ ├── get_sparams.c │ │ ├── sel.c │ │ └── atsh-sel.c │ ├── atsa │ │ ├── atsa.c │ │ ├── save-load-sound.c │ │ ├── critical-bands.c │ │ ├── peak-detection.c │ │ ├── atsa-nogui.c │ │ ├── other-utils.c │ │ ├── peak-tracking.c │ │ ├── residual.c │ │ └── residual-analysis.c │ └── sndlib │ │ ├── README │ │ ├── sndlib-config.in │ │ ├── makefile.in │ │ ├── config.h.in │ │ ├── install-sh │ │ └── sndlib-strings.h ├── Makefile.am ├── README ├── configure.ac ├── mkinstalldirs ├── config.h.in ├── compile └── install-sh ├── icmc-paper ├── ATS_final.pdf ├── ATS_User_Interfaces_final.pdf └── chicago.sty └── ats-csound ├── README.txt ├── docs ├── atsinfo.html ├── atsread.html ├── atssynth.html └── atsbuffuncs.html └── ugnorman.h /README.md: -------------------------------------------------------------------------------- 1 | This project has moved to https://gitlab.com/dxarts/projects/ats 2 | -------------------------------------------------------------------------------- /ats-pd/cl.ats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats-pd/cl.ats -------------------------------------------------------------------------------- /ats-pd/crt.ats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats-pd/crt.ats -------------------------------------------------------------------------------- /ats/doc/analysis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/analysis.jpg -------------------------------------------------------------------------------- /ats/doc/list-view.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/list-view.jpg -------------------------------------------------------------------------------- /ats/doc/settings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/settings.jpg -------------------------------------------------------------------------------- /ats/doc/smart_sel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/smart_sel.jpg -------------------------------------------------------------------------------- /ats/doc/edit-linear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/edit-linear.jpg -------------------------------------------------------------------------------- /ats/doc/edit-spline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/edit-spline.jpg -------------------------------------------------------------------------------- /ats/doc/header-view.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/header-view.jpg -------------------------------------------------------------------------------- /ats/doc/main-screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/main-screen.jpg -------------------------------------------------------------------------------- /icmc-paper/ATS_final.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/icmc-paper/ATS_final.pdf -------------------------------------------------------------------------------- /ats/doc/main-screen-res.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/main-screen-res.jpg -------------------------------------------------------------------------------- /ats/doc/synthesis-main.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/synthesis-main.jpg -------------------------------------------------------------------------------- /ats/doc/synthesis-time.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/synthesis-time.jpg -------------------------------------------------------------------------------- /ats/doc/main-screen-selection.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/main-screen-selection.jpg -------------------------------------------------------------------------------- /ats/doc/main-screen-selection-zoom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/main-screen-selection-zoom.jpg -------------------------------------------------------------------------------- /ats/doc/main-screen-selection-discont.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/ats/doc/main-screen-selection-discont.jpg -------------------------------------------------------------------------------- /icmc-paper/ATS_User_Interfaces_final.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamezilla/ats/HEAD/icmc-paper/ATS_User_Interfaces_final.pdf -------------------------------------------------------------------------------- /ats/reconf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo removing junk... 3 | rm -f aclocal.m4 config.cache config.h configure *.in config.status Makefile 4 | rm -rf autom4te.cache/ 5 | echo running aclocal... 6 | aclocal 7 | echo running autoconf... 8 | autoconf 9 | echo running autoheader... 10 | autoheader 11 | echo running automake... 12 | automake --foreign -a 13 | -------------------------------------------------------------------------------- /ats-pd/help-atsreadhelp.pd: -------------------------------------------------------------------------------- 1 | #N canvas 603 133 514 568 10; 2 | #X obj 40 100 osc~; 3 | #X obj 58 132 *~; 4 | #X obj 102 33 packel \$1; 5 | #X obj 7 31 packel \$1; 6 | #X obj 59 156 throw~ \$2-atsaudio; 7 | #X obj 102 11 r \$2-atsamp; 8 | #X obj 7 9 r \$2-atsfreq; 9 | #X obj 101 107 lop~ 10; 10 | #X connect 0 0 1 0; 11 | #X connect 1 0 4 0; 12 | #X connect 2 0 7 0; 13 | #X connect 3 0 0 0; 14 | #X connect 5 0 2 0; 15 | #X connect 6 0 3 0; 16 | #X connect 7 0 1 1; 17 | -------------------------------------------------------------------------------- /ats/TODO: -------------------------------------------------------------------------------- 1 | 2 | Synthesis: 3 | 4 | 1-Add DC Blocker to the residual 5 | 2-Substractive Synthesis 6 | 3-Rethink Time envelope (possibly have a time transformation function) 7 | 4-Amplitude of residual bands with curves. (we will do it "on the fly" in the Synthesis, can't do it now because I do no have sound output to test the results) 8 | 9 | 10 | Editing: 11 | 12 | 2-Track deleting 13 | 3-Region deleting 14 | 4-Add dismiss button to list view. 15 | 5-SMR/Amplitude display. 16 | 6-Smart selection using frequency with harmonic factor and SMR threshold. 17 | 18 | Analysis: make info printed to stdout into a form with progress bar 19 | 20 | - label the zoom bars and contrast bar or separate the two zoom bars out of the contrast one. Take out the number on the latter. 21 | 22 | 23 | View menu 24 | Replace Sinusoidal and Noise by a call to a Configuration View Window 25 | 26 | - add Help/Documentation menu item that launches the html documentation 27 | 28 | 29 | 30 | all menus: rethink keyboard commands. several commands do not need a keyboard shortcut, and others need a better letter. 31 | 32 | -------------------------------------------------------------------------------- /ats/src/atsh/help.c: -------------------------------------------------------------------------------- 1 | /* 2 | HELP.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | #include "atsh.h" 6 | #include "help.h" 7 | 8 | void help(void) 9 | { 10 | GtkWidget *label, *window, *scrolled_window; 11 | 12 | window = gtk_window_new(GTK_WINDOW_DIALOG); 13 | // set_window_icon(window); 14 | gtk_window_set_title(GTK_WINDOW(window), "Help for ATSH"); 15 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 16 | gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE); 17 | 18 | scrolled_window = gtk_scrolled_window_new (NULL, NULL); 19 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); 20 | gtk_widget_set_usize(GTK_WIDGET(scrolled_window), 500, 500); 21 | gtk_container_add(GTK_CONTAINER(window), scrolled_window); 22 | 23 | label = gtk_label_new(HELP_STR); 24 | gtk_widget_set_usize(GTK_WIDGET(label), 450, 1500); 25 | gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT); 26 | gtk_label_set_line_wrap (GTK_LABEL(label), TRUE); 27 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), label); 28 | 29 | gtk_widget_show_all (window); 30 | } 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ats/src/atsa/atsa.c: -------------------------------------------------------------------------------- 1 | /* atsa.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | /* main_anal 9 | * ========= 10 | * main analysis function 11 | * soundfile: path to input file 12 | * out_file: path to output ats file 13 | * anargs: pointer to analysis parameters 14 | * returns error status 15 | */ 16 | int main_anal(char *soundfile, char *ats_outfile, ANARGS *anargs, char *resfile) 17 | { 18 | /* create pointers and structures */ 19 | ATS_SOUND *sound = NULL; 20 | FILE *outfile; 21 | /* open output file */ 22 | outfile = fopen(ats_outfile, "wb"); 23 | if (outfile == NULL) { 24 | printf("\n Could not open %s for writing, bye...\n\n", ats_outfile); 25 | return(-1); 26 | } 27 | /* call tracker */ 28 | sound = tracker(anargs, soundfile, resfile); 29 | /* save sound */ 30 | if(sound != NULL) { 31 | fprintf(stderr,"saving ATS data..."); 32 | ats_save(sound, outfile, anargs->SMR_thres, anargs->type); 33 | fprintf(stderr, "done!\n"); 34 | } 35 | else{ 36 | /* file I/O error */ 37 | return(-2); 38 | } 39 | /* close output file */ 40 | fclose(outfile); 41 | /* free ATS_SOUND memory */ 42 | free_sound(sound); 43 | return(0); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /ats/src/sndlib/README: -------------------------------------------------------------------------------- 1 | This directory contains a version of sndlib customized to work with atsa. 2 | The text below comes form the COPYING file distributed with sndlib at: 3 | 4 | http://www-ccrma.satnford.edu/software/snd/sndlib/ 5 | 6 | sndlib is a library written by Bill Schottstaedt (bil@ccrma.stanford.edu). 7 | Except where otherwise noted, it is Copyright 1996-2003 The Board of Trustees 8 | of Stanford University. 9 | 10 | The authors hereby grant permission to use, copy, modify, distribute, 11 | and license this software and its documentation for any purpose. No 12 | written agreement, license, or royalty fee is required. Modifications 13 | to this software may be copyrighted by their authors and need not 14 | follow the licensing terms described here. 15 | 16 | IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY 17 | FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 18 | ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY 19 | DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE 20 | POSSIBILITY OF SUCH DAMAGE. 21 | 22 | THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, 23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE 25 | IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE 26 | NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 27 | MODIFICATIONS. 28 | -------------------------------------------------------------------------------- /ats/src/sndlib/sndlib-config.in: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # borrowed from gsl-config.in 4 | 5 | prefix=@prefix@ 6 | exec_prefix=@exec_prefix@ 7 | includedir=@includedir@ 8 | 9 | usage() 10 | { 11 | cat <partials ; i++){ 17 | peaks[i].frq = sound->frq[i][frame]; 18 | peaks[i].amp = sound->amp[i][frame]; 19 | peaks[i].smr = (double)0.0; 20 | } 21 | } 22 | 23 | /* atsh_compute_SMR 24 | * ================ 25 | * computes the SMR data for a set of frames 26 | * *sound: pointer to an ATS_SOUND structure 27 | * from_frame: initial frame 28 | * to_frame: last frame 29 | */ 30 | void atsh_compute_SMR(ATS_SOUND *sound, int from_frame, int to_frame) 31 | { 32 | ATS_PEAK *peaks; 33 | int i, j, nValue=0; 34 | int todo = to_frame - from_frame; 35 | 36 | peaks = (ATS_PEAK *)malloc(sound->partials * sizeof(ATS_PEAK)); 37 | 38 | StartProgress("Computing SMR...", FALSE); 39 | for(i = from_frame; i < to_frame; i++) 40 | { 41 | //fprintf(stderr," frm=%d", i); 42 | 43 | make_peaks(sound,peaks,i); 44 | evaluate_smr(peaks, sound->partials); 45 | for(j = 0 ; j < sound->partials ; j++) 46 | { 47 | sound->smr[j][i] = peaks[j].smr; 48 | //fprintf(stderr,"%8.3f ",sound->smr[j][i] ); 49 | } 50 | //fprintf(stderr,"\n"); 51 | ++nValue; 52 | UpdateProgress(nValue,todo); 53 | } 54 | EndProgress(); 55 | smr_done=TRUE; 56 | free(peaks); 57 | } 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /ats/src/atsh/mask.c: -------------------------------------------------------------------------------- 1 | /* 2 | ATSH-MASK.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | 6 | extern short smr_done; 7 | 8 | #include "atsh.h" 9 | 10 | /* make_peaks 11 | * ========== 12 | * creates peaks from data in a frame 13 | * and store them in *peaks 14 | */ 15 | void make_peaks(ATS_SOUND *sound, ATS_PEAK *peaks, int frame) 16 | { 17 | int i; 18 | for(i = 0; i < sound->partials ; i++){ 19 | peaks[i].frq = sound->frq[i][frame]; 20 | peaks[i].amp = sound->amp[i][frame]; 21 | peaks[i].smr = (double)0.0; 22 | } 23 | } 24 | 25 | /* atsh_compute_SMR 26 | * ================ 27 | * computes the SMR data for a set of frames 28 | * *sound: pointer to an ATS_SOUND structure 29 | * from_frame: initial frame 30 | * to_frame: last frame 31 | */ 32 | void atsh_compute_SMR(ATS_SOUND *sound, int from_frame, int to_frame) 33 | { 34 | ATS_PEAK *peaks; 35 | int i, j, nValue=0; 36 | int todo = to_frame - from_frame; 37 | 38 | peaks = (ATS_PEAK *)malloc(sound->partials * sizeof(ATS_PEAK)); 39 | 40 | StartProgress("Computing SMR...", FALSE); 41 | for(i = from_frame; i < to_frame; i++) 42 | { 43 | //fprintf(stderr," frm=%d", i); 44 | 45 | make_peaks(sound,peaks,i); 46 | evaluate_smr(peaks, sound->partials); 47 | for(j = 0 ; j < sound->partials ; j++) 48 | { 49 | sound->smr[j][i] = peaks[j].smr; 50 | //fprintf(stderr,"%8.3f ",sound->smr[j][i] ); 51 | } 52 | //fprintf(stderr,"\n"); 53 | ++nValue; 54 | UpdateProgress(nValue,todo); 55 | } 56 | EndProgress(); 57 | smr_done=TRUE; 58 | free(peaks); 59 | } 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /ats/src/sndlib/makefile.in: -------------------------------------------------------------------------------- 1 | SHELL = /bin/sh 2 | top_srcdir = . 3 | 4 | INSTALL = @INSTALL@ 5 | prefix = @prefix@ 6 | exec_prefix = @exec_prefix@ 7 | bindir = @bindir@ 8 | srcdir = @srcdir@ 9 | mandir = @mandir@ 10 | libdir = @libdir@ 11 | includedir = @includedir@ 12 | VPATH = @srcdir@ 13 | mkinstalldirs = $(SHELL) $(srcdir)/mkinstalldirs 14 | 15 | CC = @CC@ 16 | DEFS = @DEFS@ 17 | CFLAGS = @CFLAGS@ 18 | LDFLAGS = @LDFLAGS@ 19 | LIBS = @LIBS@ 20 | 21 | 22 | LDSO_FLAGS = @LDSO_FLAGS@ 23 | SO_INSTALL = @SO_INSTALL@ 24 | SO_LD = @SO_LD@ 25 | A_LD = ld 26 | A_LD_FLAGS = @A_LD_FLAGS@ 27 | LD_FLAGS = @LD_FLAGS@ 28 | 29 | .c.o: 30 | $(CC) -c $(DEFS) $(CFLAGS) $< 31 | 32 | SNDLIB_HEADERS = sndlib.h sndlib-strings.h clm.h 33 | SNDLIB_O_FILES = headers.o io.o sound.o clm.o 34 | 35 | sndlib: $(SNDLIB_HEADERS) $(SNDLIB_O_FILES) 36 | $(A_LD) $(LD_FLAGS) $(LDFLAGS) $(SNDLIB_O_FILES) -o sndlib.a $(A_LD_FLAGS) 37 | 38 | $(SNDLIB_O_FILES): $(SNDLIB_HEADERS) 39 | 40 | clean: 41 | rm -f $(SNDLIB_O_FILES) sndlib.a 42 | 43 | install: sndlib 44 | $(mkinstalldirs) $(bindir) 45 | $(mkinstalldirs) $(libdir) 46 | $(mkinstalldirs) $(includedir) 47 | $(SO_INSTALL) sndlib.so $(libdir)/libsndlib.so 48 | $(INSTALL) sndlib.a $(libdir)/libsndlib.a 49 | $(INSTALL) sndlib-config $(bindir)/sndlib-config 50 | $(INSTALL) $(srcdir)/sndlib.h $(includedir)/sndlib.h 51 | 52 | uninstall: 53 | rm -f $(libdir)/libsndlib.so 54 | rm -f $(libdir)/libsndlib.a 55 | 56 | Makefile: Makefile.in config.status 57 | ./config.status 58 | 59 | config.status: configure 60 | ./config.status --recheck 61 | 62 | configure: configure.in 63 | cd $(srcdir); autoconf 64 | 65 | -------------------------------------------------------------------------------- /ats/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to create Makefile.in 2 | noinst_LIBRARIES = libatsa.a 3 | libatsa_a_DEPENDENCIES = src/sndlib/sndlib.a 4 | libatsa_a_SOURCES = src/atsa/atsa.h src/atsa/critical-bands.c src/atsa/other-utils.c src/atsa/peak-detection.c src/atsa/peak-tracking.c src/atsa/residual-analysis.c src/atsa/residual.c src/atsa/save-load-sound.c src/atsa/tracker.c src/atsa/utilities.c 5 | libatsa_a_LIBADD = src/sndlib/sndlib.a 6 | libatsa_a_CFLAGS = -Isrc/sndlib 7 | 8 | bin_PROGRAMS = atsa atsh 9 | 10 | atsa_SOURCES = src/atsa/atsa-nogui.c src/atsa/atsa.c 11 | atsa_LDADD = libatsa.a 12 | atsa_CFLAGS = -Isrc/sndlib 13 | 14 | atsh_SOURCES = src/atsh/about.c src/atsh/atsh-analysis.c src/atsh/atsh.c src/atsh/atsh-curves.c src/atsh/ats-header.c src/atsh/atsh-files.c src/atsh/atsh-graphics.c src/atsh/atsh.h src/atsh/atsh-mask.c src/atsh/atsh-misc.c src/atsh/atsh-sel.c src/atsh/atsh-undo.c src/atsh/get_sparams.c src/atsh/list_view.c src/atsh/my_curve.c src/atsh/my_curve.h src/atsh/popup.c src/atsh/progress.c src/atsh/synth-funcs.c src/atsh/help.c src/atsh/help.h 15 | atsh_LDADD = libatsa.a @GTK_LIBS@ 16 | atsh_CFLAGS = -Isrc/sndlib -Isrc/atsa @GTK_CFLAGS@ 17 | 18 | src/sndlib/sndlib.a: 19 | cd src/sndlib ; ./configure --with-doubles ; make 20 | 21 | sclean: 22 | cd src/sndlib ; make clean 23 | 24 | dist-hook: 25 | rm -rf `find $(distdir)/doc -name CVS` 26 | 27 | EXTRA_DIST = README TODO doc \ 28 | src/sndlib/clm.c src/sndlib/clm.h src/sndlib/clm-strings.h src/sndlib/config.guess src/sndlib/config.h.in src/sndlib/config.sub src/sndlib/configure src/sndlib/headers.c src/sndlib/install-sh src/sndlib/io.c src/sndlib/makefile.in src/sndlib/README src/sndlib/sndlib-config.in src/sndlib/sndlib.h src/sndlib/sndlib-strings.h src/sndlib/sound.c 29 | #DIST_SUBDIRS = examples doc 30 | -------------------------------------------------------------------------------- /ats/src/atsh/about.c: -------------------------------------------------------------------------------- 1 | /* 2 | ABOUT.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | #include "atsh.h" 6 | 7 | void about(void) 8 | { 9 | GtkWidget *label, *window, *box; 10 | gchar str[10] = "ATSH "; 11 | 12 | window = gtk_window_new(GTK_WINDOW_DIALOG); 13 | gtk_window_set_title(GTK_WINDOW(window), "About ATSH"); 14 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 15 | gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE); 16 | 17 | box = gtk_vbox_new(FALSE, 0); 18 | gtk_container_set_border_width(GTK_CONTAINER(box), 20); 19 | gtk_container_add(GTK_CONTAINER(window), box); 20 | 21 | label = gtk_label_new(strcat((char *)str, VERSION)); 22 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 23 | gtk_widget_show(label); 24 | 25 | label = gtk_label_new("\nDeveloped by:\n" \ 26 | "Oscar Pablo Di Liscia - odiliscia@unq.edu.ar\n" \ 27 | "Pete Moss - petemoss@u.washington.edu\n" \ 28 | "Juan Pampin - pampin@u.washington.edu\n\n" \ 29 | "This Program is partially supported by:\n" \ 30 | "Universidad Nacional de Quilmes, Argentina\n" \ 31 | "http://www.unq.edu.ar/cme\n" \ 32 | "Center for Digital Arts and Experimental Media (DXARTS)\n" \ 33 | "University of Washington, Seattle\n" \ 34 | "http://www.washington.edu/dxarts\n\n" \ 35 | "ATS Homepage:\nhttp://www.dxarts.washington.edu/ats"); 36 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 37 | gtk_widget_show(label); 38 | 39 | gtk_widget_show (box); 40 | gtk_widget_show(window); 41 | } 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ats-pd/README: -------------------------------------------------------------------------------- 1 | Fri May 21 07:57:23 PDT 2004 2 | 3 | This is the atsread function for PD (pure-data) by Miller Puckette It reads 4 | data and outputs data from atsfiles based on a time pointer. See the 5 | help-atsread.pd file for more info about how to use it. The external does not 6 | depend on any other externals but the help-file uses the zexy external to 7 | synthesize the sine waves. 8 | 9 | I have only tested it for Linux and haven't had any problems with the current 10 | software, please e-mail me if you find problems. 11 | 12 | Here is how I compile it (with "m_pd.h" from the PD source in the same directory) 13 | gcc -shared -o atsread.pd_linux atsread.c 14 | 15 | or to allow byte swapping (using big endian files on little endian machines, 16 | and visa versa): 17 | gcc -DBYTESWAP -shared -o atsread.pd_linux atsread.c 18 | 19 | for Mac OS X (with "m_pd.h" from the PD source in the same directory): 20 | cc -DBYTESWAP -bundle -flat_namespace -undefined suppress -o atsread.pd_darwin atscread.c 21 | 22 | (byte swapping should allow Mac users to use the cl.ats and crt.ats files that come with atsread) 23 | 24 | Then put the atsread.pd_linux file into your path somewhere (most likely your 25 | "externals" directory) and put the help-*.pd, cl.ats and crt.ats in your help 26 | directory (which should also be in your pd path hopefully). 27 | 28 | 29 | web-sites of interest: 30 | 31 | ATS: http://sourceforge.net/projects/atsa/ 32 | http://www.dxarts.washington.edu/ats/ 33 | 34 | PureData: www.pure-data.info 35 | http://crca.ucsd.edu/~msp/software.html 36 | 37 | This software is free for non-commercial use, use it at your own risk, I assume 38 | no responsibility, though if you do find a problem I'll try to fix it. If you 39 | have a suggestion for optimization or any improvements them my way. 40 | 41 | External Written by: Alex Norman alexnorman@users.sourceforge.net 42 | -------------------------------------------------------------------------------- /ats/README: -------------------------------------------------------------------------------- 1 | About ATSA: 2 | The atsa libray implements the analysis part of Juan Pampin's ATS system. 3 | For information about ATS visit: http://www-ccrma.stanford.edu/~juan/ATS.html 4 | For ATSH documentation see doc/atsh-doc.html 5 | 6 | Compilation: 7 | To compile atsa or atsh do the standard 8 | ./configure ; make ; make install 9 | This will configure the system and create the sndlib library, the atsa library, 10 | and the atsa and atsh binaries. 11 | 12 | 13 | ATS Copyright: 14 | The atsa library and atsh ware developed as part of the "Desarrollo de Software 15 | para analisis y sintesis de sonido digital (Digital Sound Analysis and 16 | Synthesis Software Development)" research and development project with 17 | the support of: Universidad Nacional de Quilmes, Buenos Aires, Argentina 18 | (http://www.unq.edu.ar), and the Center for Digital Arts and Experimental 19 | Media, University of Washington, Seattle, USA 20 | (http://www.washington.edu/dxarts). 21 | 22 | Except where otherwise noted, ATSA and ATSH is Copyright 2002-2004 Oscar Pablo 23 | Di Liscia, Pete Moss and Juan Pampin. 24 | 25 | The authors hereby grant permission to use, copy, modify, distribute, 26 | and license this software and its documentation for any purpose. No 27 | written agreement, license, or royalty fee is required. Modifications 28 | to this software may be copyrighted by their authors and need not 29 | follow the licensing terms described here. 30 | 31 | IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY 32 | FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 33 | ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY 34 | DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE 35 | POSSIBILITY OF SUCH DAMAGE. 36 | 37 | THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, 38 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, 39 | FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE 40 | IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE 41 | NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 42 | MODIFICATIONS. 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /ats-csound/README.txt: -------------------------------------------------------------------------------- 1 | Sat May 8 17:59:17 PDT 2004 2 | 3 | ATScsound Ugens, adapted by Alex Norman (2003) from the phase vocoder csound code by Richard Karpen 4 | This software uses files created by ATS: http://sourceforge.net/projects/atsa/ 5 | There is no warranty for this software. 6 | If you find bugs contact me at alexnorman@users.sourceforge.net 7 | There is HTML documentation in the docs directory 8 | 9 | To install (pre Csound 5): 10 | 11 | 1) put ugnorman.c and ugnorman.h into your Csound directory 12 | 2) put ugnorman.c ugnorman.h and ugnorman.o in the correct place in your csound Makefile 13 | 3) put the following in the correct place in entry.c 14 | 15 | ----------------------------------- 16 | 17 | #include "ugnorman.h" 18 | 19 | void atsreadset(void*), atsread(void*); 20 | void atsreadnzset(void*), atsreadnz(void*); 21 | void atsaddset(void*), atsadd(void*); 22 | void atsaddnzset(void*), atsaddnz(void*); 23 | void atssinnoiset(void*), atssinnoi(void*); 24 | void atsbufreadset(void*), atsbufread(void*); 25 | void atspartialtapset(void*), atspartialtap(void*); 26 | void atsinterpreadset(void*), atsinterpread(void*); 27 | void atscrossset(void*), atscross(void*); 28 | void atsinfo(void*); 29 | 30 | { "atsread", S(ATSREAD), 3, "kk", "kSi", atsreadset, atsread, NULL}, 31 | { "atsreadnz", S(ATSREADNZ), 3, "k", "kSi", atsreadnzset, atsreadnz, NULL}, 32 | { "atsadd", S(ATSADD), 5, "a", "kkSiiopo", atsaddset, NULL, atsadd}, 33 | { "atsaddnz", S(ATSADDNZ), 5, "a", "kSiop", atsaddnzset, NULL, atsaddnz}, 34 | { "atssinnoi", S(ATSSINNOI), 5, "a", "kkkkSiop", atssinnoiset, NULL, atssinnoi}, 35 | { "atsbufread", S(ATSBUFREAD), 3, "", "kkSiop", atsbufreadset, atsbufread, NULL}, 36 | { "atspartialtap", S(ATSPARTIALTAP), 3, "kk", "i", atspartialtapset, atspartialtap, NULL}, 37 | { "atsinterpread", S(ATSINTERPREAD), 3, "k", "k", atsinterpreadset, atsinterpread, NULL}, 38 | { "atscross", S(ATSCROSS), 5, "a", "kkSikkiopo", atscrossset, NULL, atscross}, 39 | { "atsinfo", S(ATSINFO), 1, "i", "Si", atsinfo, NULL, NULL}, 40 | 41 | -------------------------------------- 42 | 43 | 4) Then rebuild Csound 44 | -------------------------------------------------------------------------------- /ats/configure.ac: -------------------------------------------------------------------------------- 1 | # Process this file with autoconf to produce a configure script. 2 | AC_PREREQ(2.57) 3 | 4 | # initialize everything 5 | AC_INIT(ats, 1.0) 6 | AC_CONFIG_SRCDIR(src/atsa/atsa.c) 7 | AM_INIT_AUTOMAKE(foreign) 8 | 9 | #AC_CONFIG_AUX_DIR(src) 10 | AM_CONFIG_HEADER(config.h) 11 | 12 | # Checks for programs. 13 | AC_PROG_CC 14 | AC_PROG_RANLIB 15 | 16 | # Checks for libraries. 17 | AC_CHECK_LIB(m, sin) 18 | AC_CHECK_LIB(gslcblas,main) 19 | AC_CHECK_LIB(gsl,main) 20 | 21 | GTK_CONFIG=gtk-config 22 | AC_MSG_CHECKING(for GTK 1.x) 23 | if $GTK_CONFIG --version > /dev/null 2>&1; then 24 | dnl We need the "%d" in order not to get e-notation on hpux. 25 | vers=`$GTK_CONFIG --version | awk 'BEGIN { FS = "."; } { printf "%d", ($[1] * 1000 + $[2]) * 1000 + $[3];}'` 26 | if test "$vers" -le 2000000; then 27 | AC_MSG_RESULT(found) 28 | else 29 | AC_MSG_ERROR(You need GTK+ 1.x to use atsh) 30 | fi 31 | else 32 | AC_MSG_ERROR(Did not find GTK+ installed) 33 | fi 34 | GTK_CFLAGS=`$GTK_CONFIG --cflags` 35 | GTK_LIBS=`$GTK_CONFIG --libs` 36 | AC_SUBST(GTK_CFLAGS) 37 | AC_SUBST(GTK_LIBS) 38 | 39 | # Checks for header files. 40 | AC_HEADER_STDC 41 | AC_CHECK_HEADERS([stdlib.h string.h unistd.h]) #fcntl.h limits.h unistd.h) 42 | 43 | # Set the gsl flag to no by default 44 | #gsl=no 45 | #AC_ARG_ENABLE(gsl, [ --enable-gsl Enable linking with gsl and gslcblas if you need them], [gsl=yes]) 46 | #if test "x$gsl" = "xyes" ; then 47 | # GSL_LIBS="-lgsl -lgslcblas" 48 | #else 49 | # GSL_LIBS= 50 | #fi 51 | #AC_SUBST(GSL_LIBS) 52 | 53 | # Checks for typedefs, structures, and compiler characteristics. 54 | AC_C_CONST 55 | #AC_TYPE_MODE_T 56 | #AC_TYPE_OFF_T 57 | #AC_TYPE_SIZE_T 58 | 59 | # Checks for library functions. 60 | AC_FUNC_ERROR_AT_LINE 61 | AC_FUNC_MALLOC 62 | AC_FUNC_REALLOC 63 | #AC_FUNC_STRFTIME 64 | #AC_FUNC_VPRINTF 65 | AC_CHECK_FUNCS([floor pow sqrt strerror memset]) #[getcwd getwd strdup strerror]) 66 | 67 | AC_CANONICAL_HOST 68 | case $host in 69 | *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) 70 | AC_DEFINE(WINDOWS, 1, [system type]) 71 | ;; 72 | *) 73 | AC_DEFINE(UNIX, 1, [system type]) 74 | ;; 75 | esac 76 | 77 | AC_CONFIG_FILES([Makefile]) 78 | AC_OUTPUT 79 | -------------------------------------------------------------------------------- /ats/src/atsh/my_curve.h: -------------------------------------------------------------------------------- 1 | /* 2 | my_curve.h 3 | 4 | The Gtk_My_Curve Widget is only an "alias" of the original Gtk_Curve one by the GIMP Team. 5 | I am just trying to fix some bugs of it... 6 | */ 7 | 8 | #ifndef __GTK_MY_CURVE_H__ 9 | #define __GTK_MY_CURVE_H__ 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | 18 | #define GTK_TYPE_MY_CURVE (gtk_my_curve_get_type ()) 19 | #define GTK_MY_CURVE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MY_CURVE, GtkMyCurve)) 20 | #define GTK_MY_CURVE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MY_CURVE, GtkMyCurveClass)) 21 | #define GTK_IS_MY_CURVE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MY_CURVE)) 22 | #define GTK_IS_MY_CURVE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MY_CURVE)) 23 | 24 | 25 | typedef struct _GtkCurve GtkMyCurve; 26 | typedef struct _GtkCurveClass GtkMyCurveClass; 27 | 28 | 29 | struct _GtkMyCurve 30 | { 31 | GtkDrawingArea graph; 32 | 33 | gint cursor_type; 34 | gfloat min_x; 35 | gfloat max_x; 36 | gfloat min_y; 37 | gfloat max_y; 38 | GdkPixmap *pixmap; 39 | GtkCurveType curve_type; 40 | gint height; /* (cached) graph height in pixels */ 41 | gint grab_point; /* point currently grabbed */ 42 | gint last; 43 | 44 | /* (cached) curve points: */ 45 | gint num_points; 46 | GdkPoint *point; 47 | 48 | /* control points: */ 49 | gint num_ctlpoints; /* number of control points */ 50 | gfloat (*ctlpoint)[2]; /* array of control points */ 51 | }; 52 | 53 | struct _GtkMyCurveClass 54 | { 55 | GtkDrawingAreaClass parent_class; 56 | 57 | void (* curve_type_changed) (GtkMyCurve *my_curve); 58 | }; 59 | 60 | 61 | GtkType gtk_my_curve_get_type (void); 62 | GtkWidget* gtk_my_curve_new (void); 63 | void gtk_my_curve_reset (GtkMyCurve *my_curve); 64 | void gtk_my_curve_set_gamma (GtkMyCurve *my_curve, gfloat gamma); 65 | void gtk_my_curve_set_range (GtkMyCurve *my_curve, 66 | gfloat min_x, gfloat max_x, 67 | gfloat min_y, gfloat max_y); 68 | void gtk_my_curve_get_vector (GtkMyCurve *my_curve, 69 | int veclen, gfloat vector[]); 70 | void gtk_my_curve_set_vector (GtkMyCurve *my_curve, 71 | int veclen, gfloat vector[]); 72 | 73 | void gtk_my_curve_set_curve_type (GtkMyCurve *my_curve, GtkCurveType type); 74 | 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif /* __cplusplus */ 79 | 80 | 81 | #endif /* __GTK_MY_CURVE_H__ */ 82 | -------------------------------------------------------------------------------- /ats/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | errstatus=0 8 | dirmode="" 9 | 10 | usage="\ 11 | Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 12 | 13 | # process command line arguments 14 | while test $# -gt 0 ; do 15 | case $1 in 16 | -h | --help | --h*) # -h for help 17 | echo "$usage" 1>&2 18 | exit 0 19 | ;; 20 | -m) # -m PERM arg 21 | shift 22 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } 23 | dirmode=$1 24 | shift 25 | ;; 26 | --) # stop option processing 27 | shift 28 | break 29 | ;; 30 | -*) # unknown option 31 | echo "$usage" 1>&2 32 | exit 1 33 | ;; 34 | *) # first non-opt arg 35 | break 36 | ;; 37 | esac 38 | done 39 | 40 | for file 41 | do 42 | if test -d "$file"; then 43 | shift 44 | else 45 | break 46 | fi 47 | done 48 | 49 | case $# in 50 | 0) exit 0 ;; 51 | esac 52 | 53 | case $dirmode in 54 | '') 55 | if mkdir -p -- . 2>/dev/null; then 56 | echo "mkdir -p -- $*" 57 | exec mkdir -p -- "$@" 58 | fi 59 | ;; 60 | *) 61 | if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 62 | echo "mkdir -m $dirmode -p -- $*" 63 | exec mkdir -m "$dirmode" -p -- "$@" 64 | fi 65 | ;; 66 | esac 67 | 68 | for file 69 | do 70 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 71 | shift 72 | 73 | pathcomp= 74 | for d 75 | do 76 | pathcomp="$pathcomp$d" 77 | case $pathcomp in 78 | -*) pathcomp=./$pathcomp ;; 79 | esac 80 | 81 | if test ! -d "$pathcomp"; then 82 | echo "mkdir $pathcomp" 83 | 84 | mkdir "$pathcomp" || lasterr=$? 85 | 86 | if test ! -d "$pathcomp"; then 87 | errstatus=$lasterr 88 | else 89 | if test ! -z "$dirmode"; then 90 | echo "chmod $dirmode $pathcomp" 91 | lasterr="" 92 | chmod "$dirmode" "$pathcomp" || lasterr=$? 93 | 94 | if test ! -z "$lasterr"; then 95 | errstatus=$lasterr 96 | fi 97 | fi 98 | fi 99 | fi 100 | 101 | pathcomp="$pathcomp/" 102 | done 103 | done 104 | 105 | exit $errstatus 106 | 107 | # Local Variables: 108 | # mode: shell-script 109 | # sh-indentation: 2 110 | # End: 111 | # mkinstalldirs ends here 112 | -------------------------------------------------------------------------------- /ats-csound/docs/atsinfo.html: -------------------------------------------------------------------------------- 1 | ~ 2 | 3 | atsinfo 4 | 5 | 6 | Signal Generators: STFT Resynthesis (Vocoding) 7 | 8 |
9 | 10 |

atsinfo

11 | 12 |
 idata      atsinfo      iatsfile, ilocation
13 |
14 |

Description

15 |

atsinfo reads data out of the header of an ATS file. 16 |

17 |

Initialization

18 |

iatsfile – the ATS number (n in ats.n) or the name in quotes of the analysis file made using ATS.

19 |

ilocation – indicates which location in the header file to return. The data in the header 20 | gives information about the data contained in the rest of the ATS file. The possible values for ilocation are given in the following list: 21 |
22 |

    23 |
  1. Sample rate (Hz) 24 |
  2. Frame Size (samples) 25 |
  3. Window Size (samples) 26 |
  4. Number of Partials 27 |
  5. Number of Frames 28 |
  6. Maximum Amplitude 29 |
  7. Maximum Frequency (Hz) 30 |
  8. Duration (seconds) 31 |
  9. ATS file Type 32 |
33 |

34 | 35 |

Performance

36 |

Macros can really improve the legibility of your csound code, I've provided my Macro Definitions below: 37 |
38 |

39 | 	#define ATS_SAMP_RATE #0#
40 | 	#define ATS_FRAME_SZ #1#
41 | 	#define ATS_WIN_SZ #2#
42 | 	#define ATS_N_PARTIALS #3#
43 | 	#define ATS_N_FRAMES #4#
44 | 	#define ATS_AMP_MAX #5#
45 | 	#define ATS_FREQ_MAX #6#
46 | 	#define ATS_DUR #7#
47 | 	#define ATS_TYPE #8#
48 |

49 |

atsinfo can be useful for writing generic instruments that will work with many ATS files, even if they have different lengths and different numbers of partials etc. Example 2 is a simple application of this. 50 |

51 |

Examples

52 | 1. 53 |
  imax_freq	atsinfo "cl.ats", $ATS_FREQ_MAX
54 |

In the example above we get the maximum frequency value from the ATS file "cl.ats" and store it in imax_freq. We use at Csound Macro (defined above) $ATS_FREQ_MAX, which is equivalent to the number 6

55 | 2. 56 |
57 |   i_npartials	atsinfo p4, $ATS_N_PARTIALS
58 |   i_dur		atsinfo p4, $ATS_DUR
59 |   ktimepnt	line 0, p3, i_dur
60 |   aout		atsadd ktimepnt, 1, p4, 1, i_npartials
61 |

In the example above we use atsinfo to retrieve the duration and number of partials in the ATS file indicated by p4. With this info we synthesize the partials using atsadd. Since the duration and number of partials are not "hard-coded" we can use this code with any ats file.

62 | 63 |

Author

64 |

Alex Norman 65 |
Seattle, Washington 66 |
2004 67 |

68 | 69 | -------------------------------------------------------------------------------- /ats/src/atsa/save-load-sound.c: -------------------------------------------------------------------------------- 1 | /* save-load-sound.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | /* ats_save 9 | * ======== 10 | * saves an ATS_SOUND to disk. 11 | * sound: pointer to ATS_SOUND structure 12 | * outfile: pointer to output ats file 13 | * SMR_thres: partials with and avreage SMR 14 | * below this value are considered masked 15 | * and not written out to the ats file 16 | * type: file type 17 | * NOTE: sound MUST be optimized using optimize_sound 18 | * before calling this function 19 | */ 20 | void ats_save(ATS_SOUND *sound, FILE *outfile, float SMR_thres, int type) 21 | { 22 | int frm, i, par, dead=0; 23 | double daux; 24 | ATS_HEADER header; 25 | 26 | if( sound->optimized == NIL ){ 27 | fprintf(stderr, "Error: sound not optimized!\n"); 28 | exit(1); 29 | } 30 | /* count how many partials are dead 31 | * unfortunately we have to do this first to 32 | * write the number of partials in the header 33 | */ 34 | for(i = 0 ; i < sound->partials ; i++){ 35 | /* see if partial is dead */ 36 | if( !(sound->av[i].frq > 0.0) || !(sound->av[i].smr >= SMR_thres) ){ 37 | dead++; 38 | } 39 | } 40 | /* sort partials by increasing frequency */ 41 | qsort(sound->av, sound->partials, sizeof(ATS_PEAK), peak_frq_inc); 42 | /* fill header up */ 43 | header.mag = (double)123.0; 44 | header.sr = (double)sound->srate; 45 | header.fs = (double)sound->frame_size; 46 | header.ws = (double)sound->window_size; 47 | header.par = (double)(sound->partials - dead); 48 | header.fra = (double)sound->frames; 49 | header.ma = sound->ampmax; 50 | header.mf = sound->frqmax; 51 | header.dur = sound->dur; 52 | header.typ = (double)type; 53 | /* write header */ 54 | fseek(outfile, 0, SEEK_SET); 55 | fwrite(&header, 1, sizeof(ATS_HEADER), outfile); 56 | /* write frame data */ 57 | for(frm=0; frmframes; frm++) { 58 | daux = sound->time[0][frm]; 59 | fwrite(&daux, 1, sizeof(double), outfile); 60 | for(i=0; ipartials; i++) { 61 | /* we ouput data in increasing frequency order 62 | * and we check for dead partials 63 | */ 64 | if((sound->av[i].frq > 0.0) && (sound->av[i].smr >= SMR_thres)){ 65 | /* get partial number from sound */ 66 | par = sound->av[i].track; 67 | /* output data to file */ 68 | daux = sound->amp[par][frm]; 69 | fwrite(&daux, 1, sizeof(double), outfile); 70 | daux = sound->frq[par][frm]; 71 | fwrite(&daux, 1, sizeof(double), outfile); 72 | if( type == 2 || type == 4){ 73 | daux = sound->pha[par][frm]; 74 | fwrite(&daux, 1, sizeof(double), outfile); 75 | } 76 | } 77 | } 78 | /* write noise data */ 79 | if( type == 3 || type == 4){ 80 | for(i=0 ; iband_energy[i][frm]; 82 | fwrite(&daux, 1, sizeof(double), outfile); 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /ats/src/atsa/critical-bands.c: -------------------------------------------------------------------------------- 1 | /* critical-bands.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | /* private function prototypes */ 9 | void clear_mask(ATS_PEAK *peaks, int peaks_size); 10 | double compute_slope_r(double val); 11 | double frq2bark(double frq, double *edges); 12 | int find_band(double frq, double *edges); 13 | 14 | /* frq2bark 15 | * ======== 16 | * frequency to bark scale conversion 17 | */ 18 | double frq2bark(double frq, double *edges) 19 | { 20 | double lo_frq, hi_frq; 21 | int band; 22 | 23 | if(frq <= 400.0) return(frq * .01); 24 | if(frq >= 20000.0) return(NIL); 25 | 26 | band = find_band(frq, edges); 27 | lo_frq = edges[band]; 28 | hi_frq = edges[band+1]; 29 | return(1 + band + fabs(log10(frq/lo_frq) / log10(lo_frq/hi_frq))); 30 | } 31 | 32 | /* find_band 33 | * ========= 34 | * returns the critical band number 35 | * corresponding to frq 36 | */ 37 | int find_band(double frq, double *edges) 38 | { 39 | int i = 0; 40 | while(frq > edges[i++]); 41 | return(i-2); 42 | } 43 | 44 | /* compute_slope_r 45 | * =============== 46 | * computes masking curve's right slope from val 47 | */ 48 | double compute_slope_r(double val) 49 | { 50 | double i = val - 40.0; 51 | return(((i > 0.0) ? i : 0.0) * 0.37 - 27.0); 52 | } 53 | 54 | /* clear_mask 55 | * ========== 56 | * clears masking curves 57 | * peaks: array of peaks representing the masking curve 58 | * peaks_size: number of peaks in curve 59 | */ 60 | void clear_mask(ATS_PEAK *peaks, int peaks_size) 61 | { 62 | while(peaks_size--) peaks[peaks_size].smr = 0.0; 63 | } 64 | 65 | /* evaluate_smr 66 | * ============ 67 | * evalues the masking curves of an analysis frame 68 | * setting the peaks smr slot. 69 | * peaks: pointer to an array of peaks 70 | * peaks_size: number of peaks 71 | */ 72 | void evaluate_smr(ATS_PEAK *peaks, int peaks_size) 73 | { 74 | double slope_l = -27.0, slope_r, delta_dB = -50.0; 75 | double frq_masker, amp_masker, frq_maskee, amp_maskee, mask_term; 76 | int i, j; 77 | ATS_PEAK *maskee; 78 | double edges[ATSA_CRITICAL_BANDS+1] = ATSA_CRITICAL_BAND_EDGES; 79 | clear_mask(peaks, peaks_size); 80 | if(peaks_size == 1) peaks[0].smr = amp2db_spl(peaks[0].amp); 81 | else for(i=0; ifrq, edges); 84 | amp_maskee = amp2db_spl(maskee->amp); 85 | for(j=0; j maskee->smr) maskee->smr = mask_term; 94 | } 95 | maskee->smr = amp_maskee - maskee->smr; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /ats/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the `floor' function. */ 4 | #undef HAVE_FLOOR 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the `gsl' library (-lgsl). */ 10 | #undef HAVE_LIBGSL 11 | 12 | /* Define to 1 if you have the `gslcblas' library (-lgslcblas). */ 13 | #undef HAVE_LIBGSLCBLAS 14 | 15 | /* Define to 1 if you have the `m' library (-lm). */ 16 | #undef HAVE_LIBM 17 | 18 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 19 | to 0 otherwise. */ 20 | #undef HAVE_MALLOC 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #undef HAVE_MEMORY_H 24 | 25 | /* Define to 1 if you have the `memset' function. */ 26 | #undef HAVE_MEMSET 27 | 28 | /* Define to 1 if you have the `pow' function. */ 29 | #undef HAVE_POW 30 | 31 | /* Define to 1 if your system has a GNU libc compatible `realloc' function, 32 | and to 0 otherwise. */ 33 | #undef HAVE_REALLOC 34 | 35 | /* Define to 1 if you have the `sqrt' function. */ 36 | #undef HAVE_SQRT 37 | 38 | /* Define to 1 if you have the header file. */ 39 | #undef HAVE_STDINT_H 40 | 41 | /* Define to 1 if you have the header file. */ 42 | #undef HAVE_STDLIB_H 43 | 44 | /* Define to 1 if you have the `strerror' function. */ 45 | #undef HAVE_STRERROR 46 | 47 | /* Define to 1 if you have the header file. */ 48 | #undef HAVE_STRINGS_H 49 | 50 | /* Define to 1 if you have the header file. */ 51 | #undef HAVE_STRING_H 52 | 53 | /* Define to 1 if you have the header file. */ 54 | #undef HAVE_SYS_STAT_H 55 | 56 | /* Define to 1 if you have the header file. */ 57 | #undef HAVE_SYS_TYPES_H 58 | 59 | /* Define to 1 if you have the header file. */ 60 | #undef HAVE_UNISTD_H 61 | 62 | /* Name of package */ 63 | #undef PACKAGE 64 | 65 | /* Define to the address where bug reports for this package should be sent. */ 66 | #undef PACKAGE_BUGREPORT 67 | 68 | /* Define to the full name of this package. */ 69 | #undef PACKAGE_NAME 70 | 71 | /* Define to the full name and version of this package. */ 72 | #undef PACKAGE_STRING 73 | 74 | /* Define to the one symbol short name of this package. */ 75 | #undef PACKAGE_TARNAME 76 | 77 | /* Define to the version of this package. */ 78 | #undef PACKAGE_VERSION 79 | 80 | /* Define to 1 if you have the ANSI C header files. */ 81 | #undef STDC_HEADERS 82 | 83 | /* system type */ 84 | #undef UNIX 85 | 86 | /* Version number of package */ 87 | #undef VERSION 88 | 89 | /* system type */ 90 | #undef WINDOWS 91 | 92 | /* Define to empty if `const' does not conform to ANSI C. */ 93 | #undef const 94 | 95 | /* Define to rpl_malloc if the replacement function should be used. */ 96 | #undef malloc 97 | 98 | /* Define to rpl_realloc if the replacement function should be used. */ 99 | #undef realloc 100 | -------------------------------------------------------------------------------- /ats/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Wrapper for compilers which do not understand `-c -o'. 4 | 5 | # Copyright 1999, 2000 Free Software Foundation, Inc. 6 | # Written by Tom Tromey . 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2, or (at your option) 11 | # any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # Usage: 28 | # compile PROGRAM [ARGS]... 29 | # `-o FOO.o' is removed from the args passed to the actual compile. 30 | 31 | prog=$1 32 | shift 33 | 34 | ofile= 35 | cfile= 36 | args= 37 | while test $# -gt 0; do 38 | case "$1" in 39 | -o) 40 | # configure might choose to run compile as `compile cc -o foo foo.c'. 41 | # So we do something ugly here. 42 | ofile=$2 43 | shift 44 | case "$ofile" in 45 | *.o | *.obj) 46 | ;; 47 | *) 48 | args="$args -o $ofile" 49 | ofile= 50 | ;; 51 | esac 52 | ;; 53 | *.c) 54 | cfile=$1 55 | args="$args $1" 56 | ;; 57 | *) 58 | args="$args $1" 59 | ;; 60 | esac 61 | shift 62 | done 63 | 64 | if test -z "$ofile" || test -z "$cfile"; then 65 | # If no `-o' option was seen then we might have been invoked from a 66 | # pattern rule where we don't need one. That is ok -- this is a 67 | # normal compilation that the losing compiler can handle. If no 68 | # `.c' file was seen then we are probably linking. That is also 69 | # ok. 70 | exec "$prog" $args 71 | fi 72 | 73 | # Name of file we expect compiler to create. 74 | cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 75 | 76 | # Create the lock directory. 77 | # Note: use `[/.-]' here to ensure that we don't use the same name 78 | # that we are using for the .o file. Also, base the name on the expected 79 | # object file name, since that is what matters with a parallel build. 80 | lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d 81 | while true; do 82 | if mkdir $lockdir > /dev/null 2>&1; then 83 | break 84 | fi 85 | sleep 1 86 | done 87 | # FIXME: race condition here if user kills between mkdir and trap. 88 | trap "rmdir $lockdir; exit 1" 1 2 15 89 | 90 | # Run the compile. 91 | "$prog" $args 92 | status=$? 93 | 94 | if test -f "$cofile"; then 95 | mv "$cofile" "$ofile" 96 | fi 97 | 98 | rmdir $lockdir 99 | exit $status 100 | -------------------------------------------------------------------------------- /ats/src/atsh/popup.c: -------------------------------------------------------------------------------- 1 | /* 2 | POPUP.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | 6 | #include "atsh.h" 7 | 8 | /* 9 | * CloseDialog 10 | * 11 | * Close the dialog window. The dialog handle is passed 12 | * in as the data. 13 | */ 14 | void CloseDialog (GtkWidget *widget, gpointer data) 15 | { 16 | 17 | /* --- Close it. --- */ 18 | gtk_widget_destroy (GTK_WIDGET (data)); 19 | } 20 | 21 | /* 22 | * ClosingDialog 23 | * 24 | * Calls when window is about to close. returns FALSE 25 | * to let it close. 26 | */ 27 | void ClosingDialog (GtkWidget *widget, gpointer data) 28 | { 29 | gtk_grab_remove (GTK_WIDGET (widget)); 30 | } 31 | 32 | 33 | /* 34 | * Popup 35 | * 36 | * Display a popup dialog window with a message and an 37 | * "Ok" button 38 | */ 39 | void Popup (char *szMessage) 40 | { 41 | static GtkWidget *label; 42 | GtkWidget *button; 43 | GtkWidget *dialog_window; 44 | 45 | /* --- Create a dialog window --- */ 46 | dialog_window = gtk_dialog_new (); 47 | gtk_window_set_policy(GTK_WINDOW (dialog_window),FALSE,FALSE,FALSE); 48 | /* --- Trap the window close signal to release the grab --- */ 49 | gtk_signal_connect (GTK_OBJECT (dialog_window), "destroy", 50 | GTK_SIGNAL_FUNC (ClosingDialog), 51 | &dialog_window); 52 | 53 | /* --- Add a title to the window --- */ 54 | gtk_window_set_title (GTK_WINDOW (dialog_window), "HEY...!!!"); 55 | 56 | /* --- Create a small border --- */ 57 | gtk_container_border_width (GTK_CONTAINER (dialog_window), 5); 58 | 59 | /* 60 | * --- Create the message 61 | */ 62 | 63 | /* --- Create the message in a label --- */ 64 | label = gtk_label_new (szMessage); 65 | 66 | /* --- Put some room around the label --- */ 67 | gtk_misc_set_padding (GTK_MISC (label), 10, 10); 68 | 69 | /* --- Add the label to the dialog --- */ 70 | gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->vbox), 71 | label, TRUE, TRUE, 0); 72 | 73 | /* --- Make the label visible --- */ 74 | gtk_widget_show (label); 75 | 76 | /* 77 | * --- "ok" button 78 | */ 79 | 80 | /* --- Create the "ok" button --- */ 81 | button = gtk_button_new_with_label ("Ok"); 82 | 83 | /* --- Need to close the window if they press "ok" --- */ 84 | gtk_signal_connect (GTK_OBJECT (button), "clicked", 85 | GTK_SIGNAL_FUNC (CloseDialog), 86 | dialog_window); 87 | 88 | /* --- Allow it to be the default button --- */ 89 | GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); 90 | 91 | /* --- Add the button to the dialog --- */ 92 | gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->action_area), 93 | button, TRUE, TRUE, 0); 94 | 95 | /* --- Make the button the default button --- */ 96 | gtk_widget_grab_default (button); 97 | 98 | /* --- Make the button visible --- */ 99 | gtk_widget_show (button); 100 | 101 | /* --- Make the dialog visible --- */ 102 | gtk_window_set_position(GTK_WINDOW(dialog_window),GTK_WIN_POS_CENTER); 103 | gtk_widget_show (dialog_window); 104 | 105 | gtk_grab_add (dialog_window); 106 | } 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /ats/src/atsh/progress.c: -------------------------------------------------------------------------------- 1 | /* 2 | PROGRESS.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | 6 | #include "atsh.h" 7 | 8 | 9 | ///////////////////////////////////////////////////////////////// 10 | 11 | void StartProgress(char *message, int canstop) 12 | { 13 | GtkWidget *label; 14 | GtkWidget *table; 15 | GtkWidget *window; 16 | GtkAdjustment *adj; 17 | GtkWidget *sbut; 18 | GtkWidget *hseparator2; 19 | 20 | pdata= g_malloc (sizeof (typProgressData)); 21 | pdata->nLastPct= -1; 22 | pdata->bProgressUp=TRUE; 23 | 24 | window=gtk_window_new(GTK_WINDOW_TOPLEVEL); 25 | pdata->window=window; 26 | 27 | gtk_signal_connect(GTK_OBJECT (window), "delete_event", 28 | GTK_SIGNAL_FUNC ((gint)CanWindowClose), pdata); 29 | gtk_container_border_width(GTK_CONTAINER (window),10); 30 | 31 | table=gtk_table_new(4,2,TRUE); 32 | gtk_container_add(GTK_CONTAINER(window),table); 33 | 34 | label=gtk_label_new(message); 35 | gtk_table_attach_defaults (GTK_TABLE(table),label,0,2,0,1); 36 | gtk_widget_show(label); 37 | 38 | adj= (GtkAdjustment *) gtk_adjustment_new (0,0,400,0,0,0); 39 | pdata->progressbar= gtk_progress_bar_new_with_adjustment(adj); 40 | gtk_table_attach_defaults(GTK_TABLE(table),pdata->progressbar,0,2,1,2); 41 | gtk_widget_show(pdata->progressbar); 42 | 43 | if(canstop==TRUE) { 44 | hseparator2 = gtk_hseparator_new (); 45 | gtk_widget_ref (hseparator2); 46 | gtk_object_set_data_full (GTK_OBJECT (window), "hseparator2", hseparator2, 47 | (GtkDestroyNotify) gtk_widget_unref); 48 | gtk_widget_show (hseparator2); 49 | gtk_table_attach (GTK_TABLE (table), hseparator2, 0, 2, 2, 3, 50 | (GtkAttachOptions) (GTK_FILL), 51 | (GtkAttachOptions) (GTK_FILL), 0, 0); 52 | 53 | sbut = gtk_button_new_with_label (("stop me...!")); 54 | gtk_widget_ref (sbut); 55 | gtk_object_set_data_full (GTK_OBJECT (window), "sbut", sbut, 56 | (GtkDestroyNotify) gtk_widget_unref); 57 | gtk_widget_show (sbut); 58 | gtk_table_attach (GTK_TABLE (table), sbut, 0, 2, 3, 4, 59 | (GtkAttachOptions) (GTK_FILL), 60 | (GtkAttachOptions) (GTK_FILL), 0, 0); 61 | gtk_signal_connect (GTK_OBJECT (sbut), "clicked",GTK_SIGNAL_FUNC (stop_process),NULL); 62 | } 63 | 64 | gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); 65 | gtk_widget_show(table); 66 | gtk_grab_add (window); 67 | gtk_widget_show(window); 68 | 69 | } 70 | //////////////////////////////////////////////////////////////////// 71 | void UpdateProgress(int pos, int len) 72 | { 73 | gfloat pvalue; 74 | int pct; 75 | 76 | if(len > 0) { 77 | pvalue=(gfloat)pos / (gfloat)len; 78 | pct=pvalue * 100; 79 | if(pdata->nLastPct != pct) { 80 | gtk_progress_set_percentage (GTK_PROGRESS (pdata->progressbar),pvalue); 81 | while(gtk_events_pending()) { 82 | gtk_main_iteration(); 83 | } 84 | pdata->nLastPct=pct; 85 | } 86 | } 87 | } 88 | //////////////////////////////////////////////////////////////////// 89 | void EndProgress () 90 | { 91 | pdata->bProgressUp=FALSE; 92 | gtk_widget_destroy(pdata->window); 93 | free(pdata); 94 | } 95 | //////////////////////////////////////////////////////////////////// 96 | gint CanWindowClose(GtkWidget *widget) 97 | { 98 | return(pdata->bProgressUp); 99 | 100 | } 101 | ///////////////////////////////////////////////////////////////// 102 | void stop_process() 103 | { 104 | 105 | stopper=TRUE; 106 | return; 107 | } 108 | -------------------------------------------------------------------------------- /ats/src/sndlib/config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H_LOADED 2 | #define CONFIG_H_LOADED 3 | 4 | #undef const 5 | 6 | #undef CLOSEDIR_VOID 7 | #undef RETSIGTYPE 8 | 9 | /* Define to `int' or something if doesn't define. */ 10 | #undef mode_t 11 | #undef pid_t 12 | #undef size_t 13 | #undef off_t 14 | 15 | #undef WORDS_BIGENDIAN 16 | 17 | #undef HAVE_GETCWD 18 | #undef HAVE_STRFTIME 19 | #undef HAVE_STRERROR 20 | #undef HAVE_VPRINTF 21 | #undef HAVE_READLINK 22 | #undef HAVE_SETLOCALE 23 | #undef HAVE_SLEEP 24 | #undef HAVE_ACCESS 25 | #undef HAVE_OPENDIR 26 | #undef HAVE_SIGNAL 27 | #undef HAVE_FINITE 28 | #undef HAVE_ISNAN 29 | #undef HAVE_STRDUP 30 | #undef HAVE_FSTATFS 31 | #undef HAVE_CLOCK 32 | #undef HAVE_VSNPRINTF 33 | #undef HAVE_SNPRINTF 34 | 35 | #undef STDC_HEADERS 36 | #undef TM_IN_SYS_TIME 37 | #undef HAVE_SYS_MOUNT_H 38 | #undef HAVE_DIRENT_H 39 | #undef HAVE_NDIR_H 40 | #undef HAVE_SYS_DIR_H 41 | #undef HAVE_SYS_NDIR_H 42 | #undef HAVE_FCNTL_H 43 | #undef HAVE_LIMITS_H 44 | #undef HAVE_STRING_H 45 | #undef HAVE_UNISTD_H 46 | #undef HAVE_SYS_TIME_H 47 | #undef HAVE_SCHED_H 48 | #undef HAVE_DLFCN_H 49 | #undef HAVE_SOUNDCARD_H 50 | #undef HAVE_SYS_SOUNDCARD_H 51 | #undef HAVE_MACHINE_SOUNDCARD_H 52 | #undef HAVE_SYS_MIXER_H 53 | #undef USR_LIB_OSS 54 | #undef USR_LOCAL_LIB_OSS 55 | #undef OPT_OSS 56 | #undef VAR_LIB_OSS 57 | #undef HAVE_LIBC_H 58 | #undef HAVE_SYS_VFS_H 59 | #undef HAVE_SYS_STATFS_H 60 | #undef HAVE_FPU_CONTROL_H 61 | #undef HAVE_SETJMP_H 62 | #undef TIME_WITH_SYS_TIME 63 | #undef HAVE_GNU_LIBC_VERSION_H 64 | #undef HAVE_PWD_H 65 | #undef HAVE_LOCALE_H 66 | #undef HAVE_SYS_FPU_H 67 | #undef HAVE_SYS_PARAM_H 68 | #undef HAVE_ALSA_ASOUNDLIB_H 69 | #undef HAVE_BYTESWAP_H 70 | 71 | #define SIZEOF_INT 0 72 | #define SIZEOF_CHAR 0 73 | #define SIZEOF_LONG 0 74 | #define SIZEOF_SHORT 0 75 | #define SIZEOF_INT_P 0 76 | #define SIZEOF_FLOAT 0 77 | #define SIZEOF_VOID_P 0 78 | #undef SIZEOF_OFF_T 79 | 80 | #undef LINUX 81 | #undef SGI 82 | #undef ALPHA 83 | #undef HPUX 84 | #undef SUN 85 | #undef SOLARIS 86 | #undef SCO5 87 | #undef OPENBSD 88 | #undef WINDOZE 89 | #undef HAVE_OSS 90 | #undef HAVE_ALSA 91 | #undef HAVE_SAM_9407 92 | #undef MAC_OSX 93 | #undef ESD 94 | #undef BSDI 95 | 96 | #undef HAVE_GUILE 97 | #undef HAVE_RUBY 98 | #undef HAVE_EXTENSION_LANGUAGE 99 | #undef RUBY_SEARCH_PATH 100 | #undef SND_CONFIG_GET_ID_ARGS 101 | #undef Float 102 | #undef _FILE_OFFSET_BITS 103 | #undef _LARGE_FILES 104 | #undef HAVE_GSL 105 | #undef HAVE_GSL_DHT_NEW 106 | #undef GSL_VERSION 107 | #undef SNDLIB_USE_FLOATS 108 | #undef MUS_SAMPLE_BITS 109 | #undef ESD_VERSION 110 | #undef AUDIOFILE_VERSION 111 | #undef HAVE_GETTEXT 112 | #undef HAVE_READLINE 113 | #undef HAVE_APPLICABLE_SMOB 114 | #undef HAVE_SCM_REMEMBER_UPTO_HERE 115 | #undef HAVE_SCM_MAKE_REAL 116 | #undef HAVE_SCM_CREATE_HOOK 117 | #undef HAVE_SCM_STRPORT_TO_STRING 118 | #undef HAVE_SCM_OBJECT_TO_STRING 119 | #undef HAVE_SCM_NUM2LONG_LONG 120 | #undef HAVE_SCM_C_MAKE_VECTOR 121 | #undef HAVE_SCM_C_DEFINE 122 | #undef HAVE_SCM_C_DEFINE_GSUBR 123 | #undef HAVE_SCM_C_EVAL_STRING 124 | #undef HAVE_SCM_NUM2INT 125 | #undef HAVE_SCM_LIST_N 126 | #undef HAVE_SCM_STR2SYMBOL 127 | #undef HAVE_SCM_C_DEFINE_MODULE 128 | #undef HAVE_SCM_T_CATCH_BODY 129 | #undef HAVE_RB_NUM2LL 130 | #undef HAVE_RB_GC_DISABLE 131 | #undef WITH_MODULES 132 | #undef HAVE_KAUDIODEVICEPROPERTYTRANSPORTTYPE 133 | #undef HAVE_KLINEARPCMFORMATFLAGISNONINTERLEAVED 134 | 135 | #define USE_SND 0 136 | #endif 137 | -------------------------------------------------------------------------------- /ats/src/atsh/header.c: -------------------------------------------------------------------------------- 1 | /* 2 | ATS-HEADER.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | 6 | #include "atsh.h" 7 | extern char ats_title[]; 8 | extern int floaded; 9 | ATS_HEADER atshed; 10 | 11 | void show_header (void) 12 | { 13 | GtkWidget *box, *window, *label; 14 | int siz, fra, len; 15 | char str[50]; 16 | 17 | if(floaded) { 18 | siz = sizeof(double); 19 | fra = (int)atshed.fra; 20 | len = sizeof(ATS_HEADER) + (siz * fra) + 21 | ((int)atshed.par * fra * siz * (FILE_HAS_PHASE ? 3 : 2)) + 22 | (FILE_HAS_NOISE ? (ATSA_CRITICAL_BANDS * fra * siz) : 0); 23 | 24 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 25 | gtk_window_set_title(GTK_WINDOW(window), "ATS File Header Data"); 26 | gtk_window_set_resizable(GTK_WINDOW(window), FALSE); 27 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 28 | 29 | box = gtk_vbox_new(FALSE, 5); 30 | gtk_container_set_border_width(GTK_CONTAINER(box), 20); 31 | gtk_container_add(GTK_CONTAINER(window), box); 32 | 33 | sprintf(str, "Filename: %s", ats_title); 34 | label = gtk_label_new(str); 35 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 36 | gtk_widget_show(label); 37 | 38 | sprintf(str,"File Size: %d bytes",len); 39 | label = gtk_label_new(str); 40 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 41 | gtk_widget_show(label); 42 | 43 | sprintf(str,"Sample Rate: %d Hz",(int)atshed.sr); 44 | label = gtk_label_new(str); 45 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 46 | gtk_widget_show(label); 47 | 48 | sprintf(str,"Frame Size: %d samples (%4.3f s)", (int)atshed.fs, atshed.fs/atshed.sr); 49 | label = gtk_label_new(str); 50 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 51 | gtk_widget_show(label); 52 | 53 | sprintf(str,"Window Size: %d",(int)atshed.ws); 54 | label = gtk_label_new(str); 55 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 56 | gtk_widget_show(label); 57 | 58 | sprintf(str,"Partials per Frame: %d",(int)atshed.par); 59 | label = gtk_label_new(str); 60 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 61 | gtk_widget_show(label); 62 | 63 | sprintf(str,"Frames: %d",(int)atshed.fra); 64 | label = gtk_label_new(str); 65 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 66 | gtk_widget_show(label); 67 | 68 | sprintf(str,"Duration: %7.3f s",(float)atshed.dur); 69 | label = gtk_label_new(str); 70 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 71 | gtk_widget_show(label); 72 | 73 | sprintf(str,"Maximum Amplitude: %5.3f",(float)atshed.ma); 74 | label = gtk_label_new(str); 75 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 76 | gtk_widget_show(label); 77 | 78 | sprintf(str,"Maximum Frequency: %7.2f Hz",(float)atshed.mf); 79 | label = gtk_label_new(str); 80 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 81 | gtk_widget_show(label); 82 | 83 | sprintf(str,"Type: %d",(int)atshed.typ); 84 | switch ((int)atshed.typ) { 85 | case 1: 86 | strcat(str, " (Amplitude and Frequency)"); 87 | break; 88 | case 2: 89 | strcat(str, " (Amplitude, Frequency, and Phase)"); 90 | break; 91 | case 3: 92 | strcat(str, " (Amplitude, Frequency, and Noise)"); 93 | break; 94 | case 4: 95 | strcat(str, " (Amplitude, Frequency, Phase, and Noise)"); 96 | break; 97 | } 98 | label = gtk_label_new(str); 99 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 100 | gtk_widget_show(label); 101 | 102 | gtk_widget_show (box); 103 | gtk_widget_show(window); 104 | } 105 | } 106 | 107 | -------------------------------------------------------------------------------- /ats/src/atsh/ats-header.c: -------------------------------------------------------------------------------- 1 | /* 2 | ATS-HEADER.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | 6 | #include "atsh.h" 7 | extern char *ats_tittle; 8 | extern int floaded; 9 | 10 | void show_header (void) 11 | { 12 | GtkWidget *box, *window, *label; 13 | int siz, fra, len; 14 | char str[50]; 15 | 16 | if(floaded) { 17 | siz = sizeof(double); 18 | fra = (int)atshed->fra; 19 | len = sizeof(ATS_HEADER) + (siz * fra) + 20 | ((int)atshed->par * fra * siz * (FILE_HAS_PHASE ? 3 : 2)) + 21 | (FILE_HAS_NOISE ? (ATSA_CRITICAL_BANDS * fra * siz) : 0); 22 | 23 | window = gtk_window_new(GTK_WINDOW_DIALOG); 24 | gtk_window_set_title(GTK_WINDOW(window), "ATS File Header Data"); 25 | gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE); 26 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 27 | 28 | box = gtk_vbox_new(FALSE, 5); 29 | gtk_container_set_border_width(GTK_CONTAINER(box), 20); 30 | gtk_container_add(GTK_CONTAINER(window), box); 31 | 32 | sprintf(str, "Filename: %s", ats_tittle); 33 | label = gtk_label_new(str); 34 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 35 | gtk_widget_show(label); 36 | 37 | sprintf(str,"File Size: %d bytes",len); 38 | label = gtk_label_new(str); 39 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 40 | gtk_widget_show(label); 41 | 42 | sprintf(str,"Sample Rate: %d Hz",(int)atshed->sr); 43 | label = gtk_label_new(str); 44 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 45 | gtk_widget_show(label); 46 | 47 | sprintf(str,"Frame Size: %d samples (%4.3f s)", (int)atshed->fs, atshed->fs/atshed->sr); 48 | label = gtk_label_new(str); 49 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 50 | gtk_widget_show(label); 51 | 52 | sprintf(str,"Window Size: %d",(int)atshed->ws); 53 | label = gtk_label_new(str); 54 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 55 | gtk_widget_show(label); 56 | 57 | sprintf(str,"Partials per Frame: %d",(int)atshed->par); 58 | label = gtk_label_new(str); 59 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 60 | gtk_widget_show(label); 61 | 62 | sprintf(str,"Frames: %d",(int)atshed->fra); 63 | label = gtk_label_new(str); 64 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 65 | gtk_widget_show(label); 66 | 67 | sprintf(str,"Duration: %7.3f s",(float)atshed->dur); 68 | label = gtk_label_new(str); 69 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 70 | gtk_widget_show(label); 71 | 72 | sprintf(str,"Maximum Amplitude: %5.3f",(float)atshed->ma); 73 | label = gtk_label_new(str); 74 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 75 | gtk_widget_show(label); 76 | 77 | sprintf(str,"Maximum Frequency: %7.2f Hz",(float)atshed->mf); 78 | label = gtk_label_new(str); 79 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 80 | gtk_widget_show(label); 81 | 82 | sprintf(str,"Type: %d",(int)atshed->typ); 83 | switch ((int)atshed->typ) { 84 | case 1: 85 | strcat(str, " (Amplitude and Frequency)"); 86 | break; 87 | case 2: 88 | strcat(str, " (Amplitude, Frequency, and Phase)"); 89 | break; 90 | case 3: 91 | strcat(str, " (Amplitude, Frequency, and Noise)"); 92 | break; 93 | case 4: 94 | strcat(str, " (Amplitude, Frequency, Phase, and Noise)"); 95 | break; 96 | } 97 | label = gtk_label_new(str); 98 | gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); 99 | gtk_widget_show(label); 100 | 101 | gtk_widget_show (box); 102 | gtk_widget_show(window); 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /ats-csound/docs/atsread.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | atsread, atsreadnz 4 | 5 | 6 | Signal Generators: STFT Resynthesis (Vocoding) 7 | 8 |
9 | 10 |

atsread, atsreadnz

11 | 12 | 13 |
14 |   kfreq, kamp	atsread     ktimepnt, ifile, ipartial
15 |   
16 |   kenergy	atsreadnz    ktimepnt, ifile, iband
17 | 
18 |
19 |

Description

20 | 21 |

atsread and atsreadnz read data from an ATS file. atsread returns the amplitude (kamp) and frequency (kfreq) 22 | information of a user specified partial contained in the ATS 23 | analysis file at the time indicated by the time pointer ktimepnt. atsreadnz returns the energy (kenergy) of a user specified noise band (1-25 bands) at the time indicated by the time 24 | pointer ktimepnt. 25 |

26 | 27 |

Initialization

28 |

ifile – the ATS number (n in ats.n) or the name in quotes of the analysis file made using ATS.

29 |

ipartial / iband – the number of the analysis partial to return the frequency in Hz and amplitude (in the case of atsread) 30 | or the number of the noise band to return the energy data (in the case of atsreadnz). 31 |

32 | 33 |

Performance

34 | 35 |

kfreq, kamp – outputs of the atsread unit. These values represent the frequency and amplitude of a specific partial 36 | selected by the user using ipartial. The partials' informations are derived from an ATS analysis. atsread linearly interpolates the 37 | frequency and amplitude between frames in the ATS analysis file; this happens at the k-rate. The output is dependent on the data in the analysis file and the ktimepnt. 38 |

39 |

kenergy – output of the atsreadnz unit. At the k-rate the linearly interpolated energy of the noise band indicated in iband is 40 | output. The output is dependent on the data in the analysis file and the ktimepnt. 41 | 42 |

43 |

ktimepnt – used for atsread and atsreadnz exactly the same as for pvoc and atsadd. 44 |

45 |

46 |

47 |

Examples

48 | 1. 49 |
  ktime	line  0, p3, 2.5
50 |   kfreq, kamp	atsread	ktime, "clarinet.ats", 2
51 |   aout	oscili	1000000 * kamp, kfreq, 1
52 |

Here we're using atsread to get the 2nd partial's frequency and amplitude data out of the clarinet.ats ATS analysis file. 53 | We're using that data to drive an oscillator, but we could use it for anything else that can take a k-rate input, like the bandwidth and resonance of a filter etc. 54 |

55 | 56 | 2. 57 |
  ktime	line	2.5, p3, 0
58 |   kenergy	atsreadnz ktime, "clarinet.ats", 5
59 |   
60 |

Here we are extracting the noise energy from band 5 in the clarinet.ats ATS analysis file. We're actually reading backwards from 2.5 seconds to the beginning of the analysis file. We could use this to synthesize noise like this:

61 | 62 |
  anoise	randi	sqrt(kenergy), 55
63 |   aout        oscili  4000000000000000000000000, 455, 2
64 |   aout = aout * anoise
65 |

Function table 2 used in the oscillator is a cosine, which is needed to shift the band limited noise into the correct place in the frequency spectrum. The randi function 66 | creates a band of noise centered about 0 Hz that has a bandwidth of about 110 Hz; multiplying it by a cosine will shift it to be centered at 455 Hz, which is the center frequency of the 5th critical noise band. 67 | This is only an example, for synthesizing the noise you'd be better off just using atsaddnz unless you want to use your own noise synthesis algorithm. 68 | Maybe you could use the noise energy for something else like applying a small amount of jitter to specific partials or for controlling something totally unrelated 69 | to the source sound? 70 |

71 | 72 |

Author

73 |

Alex Norman (edited from Richard Karpen's pvread documentation)
74 | Seattle, Wash
75 | 2003
76 |

77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /ats/src/atsa/peak-detection.c: -------------------------------------------------------------------------------- 1 | /* peak-detection.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | /* private function prototypes */ 9 | void parabolic_interp(double alpha, double beta, double gamma, double *offset, double *height); 10 | double phase_interp(double PeakPhase, double OtherPhase, double offset); 11 | void to_polar(ATS_FFT *ats_fft, double *mags, double *phase, int N, double norm); 12 | 13 | /* peak_detection 14 | * ============== 15 | * detects peaks in a ATS_FFT block 16 | * returns pointer to an array of detected peaks. 17 | * ats_fft: pointer to ATS_FFT structure 18 | * lowest_bin: lowest fft bin to start detection 19 | * highest_bin: highest fft bin to end detection 20 | * lowest_mag: lowest magnitude to detect peaks 21 | * norm: analysis window norm 22 | * peaks_size: pointer to size of the returned peaks array 23 | */ 24 | ATS_PEAK *peak_detection(ATS_FFT *ats_fft, int lowest_bin, int highest_bin, float lowest_mag, double norm, int *peaks_size) 25 | { 26 | int k, N = (highest_bin ? highest_bin : ats_fft->size/2); 27 | int first_bin = (lowest_bin ? ((lowest_bin>2)?lowest_bin:2) : 2); 28 | double fft_mag = ((double)ats_fft->rate/ats_fft->size), *fftmags, *fftphase; 29 | double right_bin, left_bin, central_bin, offset; 30 | ATS_PEAK ats_peak, *peaks = NULL; 31 | 32 | lowest_mag = (float)db2amp(lowest_mag); 33 | 34 | /* init peak */ 35 | ats_peak.amp = (double)0.0; 36 | ats_peak.frq = (double)0.0; 37 | ats_peak.pha = (double)0.0; 38 | ats_peak.smr = (double)0.0; 39 | 40 | fftmags = (double *)malloc(N * sizeof(double)); 41 | fftphase = (double *)malloc(N * sizeof(double)); 42 | /* convert spectrum to polar coordinates */ 43 | to_polar(ats_fft, fftmags, fftphase, N, norm); 44 | central_bin = fftmags[first_bin - 2]; 45 | right_bin = fftmags[first_bin - 1]; 46 | /* peak detection */ 47 | for (k=first_bin; k (double)lowest_mag) && (central_bin > right_bin) && (central_bin > left_bin)) { 52 | parabolic_interp(left_bin, central_bin, right_bin, &offset, &ats_peak.amp); 53 | ats_peak.frq = fft_mag * ((k - 1) + offset); 54 | ats_peak.pha = (offset < 0.0) ? phase_interp(fftphase[k-2], fftphase[k-1], abs(offset)) : phase_interp(fftphase[k-1], fftphase[k], offset); 55 | ats_peak.track = -1; 56 | /* push peak into peaks list */ 57 | peaks = push_peak(&ats_peak, peaks, peaks_size); 58 | } 59 | } 60 | /* free up fftmags and fftphase */ 61 | free(fftmags); 62 | free(fftphase); 63 | return(peaks); 64 | } 65 | 66 | /* to_polar 67 | * ======== 68 | * rectangular to polar conversion 69 | * values are also scaled by window norm 70 | * and stored into separate arrays of 71 | * magnitudes and phases. 72 | * ats_fft: pointer to ATS_FFT structure 73 | * mags: pointer to array of magnitudes 74 | * phase: pointer to array of phases 75 | * N: highest bin in fft data array 76 | * norm: window norm used to scale magnitudes 77 | */ 78 | void to_polar(ATS_FFT *ats_fft, double *mags, double *phase, int N, double norm) 79 | { 80 | int k; 81 | double x, y; 82 | 83 | for(k=0; kdata[k][0]; 86 | y = ats_fft->data[k][1]; 87 | #else 88 | x = ats_fft->fdr[k]; 89 | y = ats_fft->fdi[k]; 90 | #endif 91 | mags[k] = norm * sqrt(x*x + y*y); 92 | phase[k] = ((x==0.0 && y==0.0) ? 0.0 : atan2(-y, x)); 93 | } 94 | } 95 | 96 | 97 | /* parabolic_interp 98 | * ================ 99 | * parabolic peak interpolation 100 | */ 101 | void parabolic_interp(double alpha, double beta, double gamma, double *offset, double *height) 102 | { 103 | double dbAlpha = amp2db(alpha), dbBeta = amp2db(beta), dbGamma = amp2db(gamma); 104 | *offset = .5 * ((dbAlpha - dbGamma) / (dbAlpha - 2*dbBeta + dbGamma)); 105 | *height = db2amp(dbBeta - ((dbAlpha - dbGamma) * .25 * *offset)); 106 | } 107 | 108 | /* phase_interp 109 | * ============ 110 | * phase interpolation 111 | */ 112 | double phase_interp(double PeakPhase, double RightPhase, double offset) 113 | { 114 | if ((PeakPhase - RightPhase) > PI*1.5) RightPhase += TWOPI; 115 | else if ((RightPhase - PeakPhase) > PI*1.5) PeakPhase += TWOPI; 116 | return ((RightPhase - PeakPhase) * offset + PeakPhase); 117 | } 118 | 119 | -------------------------------------------------------------------------------- /ats/src/atsa/atsa-nogui.c: -------------------------------------------------------------------------------- 1 | /* atsa-nogui.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | void usage(void) 9 | { 10 | fprintf(stderr, "ATSA "); 11 | fprintf(stderr, VERSION); 12 | fprintf(stderr, "\natsa soundfile atsfile [flags]\n"); 13 | fprintf(stderr, "Flags:\n"); 14 | fprintf(stderr, "\t -b start (%f seconds)\n" \ 15 | "\t -e duration (%f seconds or end)\n" \ 16 | "\t -l lowest frequency (%f Hertz)\n" \ 17 | "\t -H highest frequency (%f Hertz)\n" \ 18 | "\t -d frequency deviation (%f of partial freq.)\n" \ 19 | "\t -c window cycles (%d cycles)\n" \ 20 | "\t -w window type (type: %d)\n" \ 21 | "\t\t(Options: 0=BLACKMAN, 1=BLACKMAN_H, 2=HAMMING, 3=VONHANN)\n" \ 22 | "\t -h hop size (%f of window size)\n" \ 23 | "\t -m lowest magnitude (%f)\n" \ 24 | "\t -t track length (%d frames)\n" \ 25 | "\t -s min. segment length (%d frames)\n" \ 26 | "\t -g min. gap length (%d frames)\n" \ 27 | "\t -T SMR threshold (%f dB SPL)\n" \ 28 | "\t -S min. segment SMR (%f dB SPL)\n" \ 29 | "\t -P last peak contribution (%f of last peak's parameters)\n" \ 30 | "\t -M SMR contribution (%f)\n" \ 31 | "\t -F File Type (type: %d)\n" \ 32 | "\t\t(Options: 1=amp.and freq. only, 2=amp.,freq. and phase, 3=amp.,freq. and residual, 4=amp.,freq.,phase, and residual)\n\n", 33 | ATSA_START, 34 | ATSA_DUR, 35 | ATSA_LFREQ, 36 | ATSA_HFREQ, 37 | ATSA_FREQDEV, 38 | ATSA_WCYCLES, 39 | ATSA_WTYPE, 40 | ATSA_HSIZE, 41 | ATSA_LMAG, 42 | ATSA_TRKLEN, 43 | ATSA_MSEGLEN, 44 | ATSA_MGAPLEN, 45 | ATSA_SMRTHRES, 46 | ATSA_MSEGSMR, 47 | ATSA_LPKCONT, 48 | ATSA_SMRCONT, 49 | ATSA_TYPE); 50 | exit(1); 51 | } 52 | 53 | 54 | int main(int argc, char **argv) 55 | { 56 | int i, val; 57 | ANARGS *anargs; 58 | char *soundfile, *ats_outfile; 59 | 60 | if(argc < 3 || argv[1][0] == '-' || argv[2][0] == '-') usage(); 61 | 62 | anargs=(ANARGS*)malloc(sizeof(ANARGS)); 63 | 64 | /* default values for analysis args */ 65 | anargs->start = ATSA_START; 66 | anargs->duration = ATSA_DUR; 67 | anargs->lowest_freq = ATSA_LFREQ; 68 | anargs->highest_freq = ATSA_HFREQ; 69 | anargs->freq_dev = ATSA_FREQDEV; 70 | anargs->win_cycles = ATSA_WCYCLES; 71 | anargs->win_type = ATSA_WTYPE; 72 | anargs->hop_size = ATSA_HSIZE; 73 | anargs->lowest_mag = ATSA_LMAG; 74 | anargs->track_len = ATSA_TRKLEN; 75 | anargs->min_seg_len = ATSA_MSEGLEN; 76 | anargs->min_gap_len = ATSA_MGAPLEN; 77 | anargs->SMR_thres = ATSA_SMRTHRES; 78 | anargs->min_seg_SMR = ATSA_MSEGSMR; 79 | anargs->last_peak_cont = ATSA_LPKCONT; 80 | anargs->SMR_cont = ATSA_SMRCONT ; 81 | anargs->type = ATSA_TYPE; 82 | 83 | soundfile = argv[1]; 84 | ats_outfile = argv[2]; 85 | 86 | for(i=3; istart)); break; 91 | case 'e' : sscanf(argv[i]+2, "%f\n", &(anargs->duration)); break; 92 | case 'l' : sscanf(argv[i]+2, "%f\n", &(anargs->lowest_freq)); break; 93 | case 'H' : sscanf(argv[i]+2, "%f\n", &(anargs->highest_freq)); break; 94 | case 'd' : sscanf(argv[i]+2, "%f\n", &(anargs->freq_dev)); break; 95 | case 'c' : sscanf(argv[i]+2, "%d\n", &(anargs->win_cycles)); break; 96 | case 'w' : sscanf(argv[i]+2, "%d\n", &(anargs->win_type)); break; 97 | case 'h' : sscanf(argv[i]+2, "%f\n", &(anargs->hop_size)); break; 98 | case 'm' : sscanf(argv[i]+2, "%f\n", &(anargs->lowest_mag)); break; 99 | case 't' : sscanf(argv[i]+2, "%d\n", &(anargs->track_len)); break; 100 | case 's' : sscanf(argv[i]+2, "%d\n", &(anargs->min_seg_len)); break; 101 | case 'g' : sscanf(argv[i]+2, "%d\n", &(anargs->min_gap_len)); break; 102 | case 'T' : sscanf(argv[i]+2, "%fL\n", &(anargs->SMR_thres)); break; 103 | case 'S' : sscanf(argv[i]+2, "%f\n", &(anargs->min_seg_SMR)); break; 104 | case 'P' : sscanf(argv[i]+2, "%f\n", &(anargs->last_peak_cont)); break; 105 | case 'M' : sscanf(argv[i]+2, "%f\n", &(anargs->SMR_cont)); break; 106 | case 'F' : sscanf(argv[i]+2, "%d\n", &(anargs->type)); break; 107 | default : usage(); 108 | } 109 | break; 110 | } 111 | default : usage(); 112 | } 113 | } 114 | val = main_anal(soundfile, ats_outfile, anargs, ATSA_RES_FILE); 115 | free(anargs); 116 | return(val); 117 | } 118 | -------------------------------------------------------------------------------- /ats/src/atsh/atsh-undo.c: -------------------------------------------------------------------------------- 1 | /* 2 | ATSH-UNDO.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | 6 | #include "atsh.h" 7 | 8 | extern UNDO_DATA *undat; 9 | 10 | //////////////////////////////////////////////////////////////////////////// 11 | void do_undo(GtkWidget *widget,gpointer data) 12 | { 13 | int aflag; 14 | FILE *pundo; 15 | int seek_point=0; 16 | int i,x; 17 | short shaux; 18 | double daux; 19 | 20 | if(undo==FALSE) {return;} 21 | if(floaded==FALSE || ned == 0) {return;} 22 | 23 | aflag=GPOINTER_TO_INT(data); 24 | led +=aflag; 25 | if(led < 0) {led=0; ned=1;} 26 | if(led == ned) {led=ned-1;} 27 | 28 | if((pundo=fopen(undo_file,"rb"))==NULL) { 29 | Popup("Could not open the UNDO backup file: /nUNDO DISABLED"); 30 | undo=FALSE; 31 | return; 32 | } 33 | fseek(pundo, (long int)seek_point, SEEK_SET); 34 | //find out where data starts and store it in seek_point 35 | 36 | for(i=0; i < led; ++i){ 37 | seek_point += (int)(atshed->par * sizeof(short)); 38 | seek_point += (int)((undat[i].to - undat[i].from) + 1 ) * sizeof(double) * undat[i].nsel; 39 | } 40 | 41 | //go in seek_point bytes 42 | fseek(pundo, (long int)seek_point, SEEK_SET); 43 | //read the backup data 44 | for(i=0; i < (int)atshed->par; ++i) { 45 | if(fread(&shaux,1,sizeof(short),pundo)==0) { 46 | Popup("Could not read on backup file: \nUNDO DISABLED"); 47 | fclose(pundo); 48 | undo=FALSE; 49 | return; 50 | } 51 | selected[i]=shaux; 52 | //g_print(" %d ", selected[i]); 53 | } 54 | //g_print("retrieving(%d): from=%d to=%d \n",ned,undat[led].from,undat[led].to); 55 | 56 | for(i=undat[led].from; i < undat[led].to+1; ++i) { 57 | 58 | for(x = 0; x < (int)atshed->par; ++x) { 59 | if(selected[x]==TRUE) { 60 | if(fread(&daux,1,sizeof(double),pundo)==0) { 61 | Popup("Could not read on backup file:(2) \nUNDO DISABLED"); 62 | //g_print("\n led= %d ned=%d \n", led, ned); 63 | fclose(pundo); 64 | undo=FALSE; 65 | return; 66 | } 67 | switch (undat[led].ed_kind) { 68 | case AMP_EDIT: 69 | ats_sound->amp[x][i]=daux; 70 | break; 71 | case FRE_EDIT: 72 | ats_sound->frq[x][i]=daux; 73 | break; 74 | } 75 | } 76 | } 77 | } 78 | 79 | 80 | selection->from=undat[led].from; 81 | selection->to=undat[led].to; 82 | selection->f1=undat[led].f1; 83 | selection->f2=undat[led].f2; 84 | vertex1=FALSE; vertex2=TRUE; //something IS selected 85 | set_avec(); 86 | fclose(pundo); 87 | if(scale_type==SMR_SCALE) { //smr values are computed only if the user is viewing them 88 | atsh_compute_SMR(ats_sound,selection->from,selection->to); 89 | } 90 | else { 91 | smr_done=FALSE; 92 | } 93 | draw_pixm(); 94 | repaint(NULL); 95 | 96 | return; 97 | } 98 | //////////////////////////////////////////////////////////////// 99 | void backup_edition(int eddie) 100 | { 101 | FILE *pundo; 102 | int i, x; 103 | short shaux; 104 | double daux; 105 | 106 | if(undo==FALSE) {return;} 107 | pundo=fopen(undo_file,"ab"); 108 | if(pundo==0) { 109 | Popup("Could not open the UNDO backup file: \nUNDO DISABLED"); 110 | undo=FALSE; 111 | return; 112 | } 113 | fseek(pundo, 0L, SEEK_END); 114 | //store edition data 115 | undat=(UNDO_DATA*)realloc(undat,( ned + 1 ) * sizeof(UNDO_DATA)); 116 | 117 | undat[ned].from=selection->from; 118 | undat[ned].to =selection->to; 119 | undat[ned].f1 =selection->f1; 120 | undat[ned].f2 =selection->f2; 121 | undat[ned].ed_kind= eddie; 122 | undat[ned].nsel =0; 123 | //g_print("saving(%d): from=%d to=%d",ned,undat[ned].from,undat[ned].to); 124 | //write first the selected partials data 125 | for(i = 0; i < (int)atshed->par; ++i) { 126 | shaux=selected[i]; 127 | if(selected[i]==TRUE) { 128 | ++undat[ned].nsel; 129 | } 130 | if(fwrite(&shaux,1,sizeof(short),pundo)==FALSE) { 131 | Popup("Could not write on backup file: \nUNDO DISABLED"); 132 | fclose(pundo); 133 | undo=FALSE; 134 | return; 135 | } 136 | } 137 | 138 | //if changed, write either amplitude or frequency data 139 | //ONLY selected partials data are written 140 | for(i=0; i < aveclen; ++i) { 141 | 142 | for(x=0; x < (int)atshed->par; ++x) { 143 | if (selected[x]==TRUE){ 144 | switch (undat[ned].ed_kind) { 145 | case AMP_EDIT: 146 | daux=ats_sound->amp[x][selection->from + i]; 147 | break; 148 | case FRE_EDIT: 149 | daux=ats_sound->frq[x][selection->from + i]; 150 | break; 151 | } 152 | if(fwrite(&daux,1,sizeof(double),pundo)==FALSE) { 153 | Popup("Could not write on backup file: \nUNDO DISABLED"); 154 | fclose(pundo); 155 | undo=FALSE; 156 | return; 157 | } 158 | } 159 | } 160 | } 161 | 162 | 163 | // 164 | ++ned; //update editions counter 165 | led=ned; //set the edition level to NED 166 | fclose(pundo); 167 | return; 168 | } 169 | //////////////////////////////////////////////////////////////// 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /ats/src/atsa/other-utils.c: -------------------------------------------------------------------------------- 1 | /* other-utils.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | #ifndef FFTW 9 | /* private function prototypes */ 10 | void fft_bit_reversal(double* rl, double* im, int n); 11 | #endif 12 | 13 | /* make_window 14 | * =========== 15 | * makes an analysis window, returns a pointer to it. 16 | * win_type: window type, available types are: 17 | * BLACKMAN, BLACKMAN_H, HAMMING and VONHANN 18 | * win_size: window size 19 | */ 20 | float *make_window(int win_type, int win_size) 21 | { 22 | float *buffer; 23 | int i; 24 | float arg = TWOPI / (float)(win_size - 1); 25 | 26 | buffer = (float *)malloc(win_size*sizeof(float)); 27 | 28 | for(i=0; i < win_size; i++) { 29 | switch (win_type) { 30 | case BLACKMAN: //Blackman (3 term) 31 | buffer[i]= 0.42 - 0.5*cos(arg*i) + 0.08*cos(arg*i*2.); 32 | break; 33 | case BLACKMAN_H: //Blackman-Harris (4 term) 34 | buffer[i]= 0.35875 - 0.48829*cos(arg*i) + 0.14128*cos(arg*i*2.) - 0.01168*cos(arg*i*3.); 35 | break; 36 | case HAMMING: //Hamming 37 | buffer[i]= 0.54 - 0.46*cos(arg*i); 38 | break; 39 | case VONHANN: //Von Hann ("hanning") 40 | buffer[i]= 0.5 - 0.5*cos(arg*i); 41 | break; 42 | } 43 | } 44 | return(buffer); 45 | } 46 | 47 | /* window_norm 48 | * =========== 49 | * computes the norm of a window 50 | * returns the norm value 51 | * win: pointer to a window 52 | * size: window size 53 | */ 54 | float window_norm(float *win, int size) 55 | { 56 | float acc=0.0; 57 | int i; 58 | for(i=0 ; ifrq - ((ATS_PEAK *)b)->frq)); 88 | } 89 | 90 | /* peak_amp_inc 91 | * ============ 92 | * function used by qsort to sort an array of peaks 93 | * in increasing amplitude order. 94 | */ 95 | int peak_amp_inc(void const *a, void const *b) 96 | { 97 | return(1000.0 * (((ATS_PEAK *)a)->amp - ((ATS_PEAK *)b)->amp)); 98 | } 99 | 100 | /* peak_smr_dec 101 | * ============ 102 | * function used by qsort to sort an array of peaks 103 | * in decreasing SMR order. 104 | */ 105 | int peak_smr_dec(void const *a, void const *b) 106 | { 107 | return(1000.0 * (((ATS_PEAK *)b)->smr - ((ATS_PEAK *)a)->smr)); 108 | } 109 | 110 | #ifndef FFTW 111 | /* fft_slow 112 | * === 113 | * standard fft based on simplfft by Joerg Arndt. 114 | * rl: pointer to real part data 115 | * im: pointer to imaginary part data 116 | * n: size of data 117 | * is: 1=forward trasnform -1=backward transform 118 | */ 119 | void fft_slow(double *rl, double *im, int n, int is) 120 | { 121 | int m, j, mh, ldm, lg, i, i2, j2, imh; 122 | double ur, ui, u, vr, vi, angle, c, s; 123 | imh = (int)(log(n + 1) / log(2.0)); 124 | fft_bit_reversal(rl, im, n); 125 | m = 2; 126 | ldm = 1; 127 | mh = n >> 1; 128 | angle = (M_PI * is); 129 | for (lg = 0; lg < imh; lg++) 130 | { 131 | c = cos(angle); 132 | s = sin(angle); 133 | ur = 1.0; 134 | ui = 0.0; 135 | for (i2 = 0; i2 < ldm; i2++) 136 | { 137 | i = i2; 138 | j = i2 + ldm; 139 | for (j2 = 0; j2 < mh; j2++) 140 | { 141 | vr = ur * rl[j] - ui * im[j]; 142 | vi = ur * im[j] + ui * rl[j]; 143 | rl[j] = rl[i] - vr; 144 | im[j] = im[i] - vi; 145 | rl[i] += vr; 146 | im[i] += vi; 147 | i += m; 148 | j += m; 149 | } 150 | u = ur; 151 | ur = (ur * c) - (ui * s); 152 | ui = (ui * c) + (u * s); 153 | } 154 | mh >>= 1; 155 | ldm = m; 156 | angle *= 0.5; 157 | m <<= 1; 158 | } 159 | } 160 | 161 | /* bit reversal */ 162 | void fft_bit_reversal(double* rl, double* im, int n) 163 | { 164 | int i, m, j; 165 | double vr, vi; 166 | j = 0; 167 | for (i = 0; i < n; i++) { 168 | if (j > i) { 169 | vr = rl[j]; 170 | vi = im[j]; 171 | rl[j] = rl[i]; 172 | im[j] = im[i]; 173 | rl[i] = vr; 174 | im[i] = vi; 175 | } 176 | m = n >> 1; 177 | while ((m >= 2) && (j >= m)) { 178 | j -= m; 179 | m = m >> 1; 180 | } 181 | j += m; 182 | } 183 | } 184 | #endif 185 | -------------------------------------------------------------------------------- /ats-pd/help-atsread.pd: -------------------------------------------------------------------------------- 1 | #N canvas 40 73 860 617 10; 2 | #X obj 12 108 vsl 15 128 0 2.5 0 0 empty empty empty 0 -8 0 8 -225280 3 | -1 -1 12700 1; 4 | #X obj 7 573 dac~; 5 | #X obj 8 548 *~; 6 | #X obj 95 565 hsl 128 15 0 1 0 0 empty empty volume 50 -6 0 10 -225271 7 | -33289 -1 7800 1; 8 | #X text 5 446 our array of oscilators; 9 | #X obj 186 374 s \$0-atsamp; 10 | #X obj 96 374 s \$0-atsfreq; 11 | #X obj 7 488 catch~ \$0-atsaudio; 12 | #X msg 91 547 0; 13 | #X obj 91 528 loadbang; 14 | #X msg 428 535 \; pd dsp 1; 15 | #X msg 428 572 \; pd dsp 0; 16 | #X text 293 542 turn pd's audio on; 17 | #X text 287 577 turn pd's audio off; 18 | #X msg 419 240 nosines; 19 | #X msg 419 221 sines; 20 | #X msg 419 259 noise; 21 | #X msg 419 278 nonoise; 22 | #X text 481 240 turns off the sine output; 23 | #X text 481 221 turns on the sine output (default); 24 | #X text 483 279 turns off the noise output; 25 | #X text 481 259 turns on the noise output (default)*; 26 | #X msg 219 89 set 1 2 4 10..20; 27 | #X text 32 54 time pointer; 28 | #X text 31 69 for data access; 29 | #X msg 219 109 add 3 5..11; 30 | #X text 337 109 adds partials to be output; 31 | #X text 339 90 sets the partials to be output; 32 | #X msg 208 55 open cl.ats; 33 | #N canvas 0 0 1071 572 oscilators 0; 34 | #X obj 13 11 help-atsreadhelp 42 \$0; 35 | #X obj 13 31 help-atsreadhelp 41 \$0; 36 | #X obj 13 51 help-atsreadhelp 40 \$0; 37 | #X obj 13 71 help-atsreadhelp 39 \$0; 38 | #X obj 13 91 help-atsreadhelp 38 \$0; 39 | #X obj 13 111 help-atsreadhelp 37 \$0; 40 | #X obj 172 11 help-atsreadhelp 36 \$0; 41 | #X obj 172 31 help-atsreadhelp 35 \$0; 42 | #X obj 172 51 help-atsreadhelp 34 \$0; 43 | #X obj 172 71 help-atsreadhelp 33 \$0; 44 | #X obj 172 91 help-atsreadhelp 32 \$0; 45 | #X obj 172 111 help-atsreadhelp 31 \$0; 46 | #X obj 331 11 help-atsreadhelp 30 \$0; 47 | #X obj 331 31 help-atsreadhelp 29 \$0; 48 | #X obj 331 51 help-atsreadhelp 28 \$0; 49 | #X obj 331 71 help-atsreadhelp 27 \$0; 50 | #X obj 331 91 help-atsreadhelp 26 \$0; 51 | #X obj 331 111 help-atsreadhelp 25 \$0; 52 | #X obj 489 11 help-atsreadhelp 24 \$0; 53 | #X obj 489 31 help-atsreadhelp 23 \$0; 54 | #X obj 489 51 help-atsreadhelp 22 \$0; 55 | #X obj 489 71 help-atsreadhelp 21 \$0; 56 | #X obj 489 91 help-atsreadhelp 20 \$0; 57 | #X obj 489 111 help-atsreadhelp 19 \$0; 58 | #X obj 648 11 help-atsreadhelp 18 \$0; 59 | #X obj 648 31 help-atsreadhelp 17 \$0; 60 | #X obj 648 51 help-atsreadhelp 16 \$0; 61 | #X obj 648 71 help-atsreadhelp 15 \$0; 62 | #X obj 648 91 help-atsreadhelp 14 \$0; 63 | #X obj 648 111 help-atsreadhelp 13 \$0; 64 | #X obj 807 11 help-atsreadhelp 12 \$0; 65 | #X obj 807 31 help-atsreadhelp 11 \$0; 66 | #X obj 807 51 help-atsreadhelp 10 \$0; 67 | #X obj 807 71 help-atsreadhelp 9 \$0; 68 | #X obj 807 91 help-atsreadhelp 8 \$0; 69 | #X obj 807 111 help-atsreadhelp 7 \$0; 70 | #X obj 807 131 help-atsreadhelp 6 \$0; 71 | #X obj 807 151 help-atsreadhelp 5 \$0; 72 | #X obj 807 171 help-atsreadhelp 4 \$0; 73 | #X obj 807 191 help-atsreadhelp 3 \$0; 74 | #X obj 807 211 help-atsreadhelp 2 \$0; 75 | #X obj 807 231 help-atsreadhelp 1 \$0; 76 | #X text 176 155 you'd probably be better off just using an external 77 | like clone for this \, but since we don't want to require additional 78 | externals for this help file \, we do it this way; 79 | #X restore 10 463 pd oscilators; 80 | #X msg 220 128 remove 2 5 7; 81 | #X text 337 128 removes partials from output; 82 | #X msg 220 159 setnz 1 2 4 10..20; 83 | #X text 355 159 sets the noise bands to be output; 84 | #X msg 221 178 addnz 3 5..11; 85 | #X msg 221 197 removenz 2 5 7; 86 | #X text 355 177 adds bands to be output; 87 | #X text 356 196 removes bands from output; 88 | #X text 295 55 opens/stores the data file to read from; 89 | #X text 562 103 partials and noise bands are always output in order 90 | from lowest to highest; 91 | #X text 365 342 creation arguments: name of a data file \, noise \, 92 | sines \, nosines \, nonoise. these work just as the above except the 93 | data file doesn't require an "open" beforehand (order is not important) 94 | ; 95 | #X obj 149 334 atsread crt.ats noise sines; 96 | #X text 480 296 * note \, only atsfile types 3 & 4 will output noise 97 | ; 98 | #X text 165 401 output 1: frequency list (sines); 99 | #X text 166 413 output 2: amp list (sines); 100 | #X text 166 425 output 3: noise energy list (if there is any); 101 | #X obj 54 158 line; 102 | #X msg 54 131 0 0 \, 2.5 2500; 103 | #X text 32 190 <- move slider to; 104 | #X text 31 202 access data manually; 105 | #X text 36 100 press msg box to play; 106 | #X text 37 113 note at normal speed; 107 | #X text 4 4 ATSREAD example (the help-atsreadhelp which syntheizes 108 | the sines requires the Zexy external); 109 | #X connect 0 0 41 0; 110 | #X connect 2 0 1 0; 111 | #X connect 2 0 1 1; 112 | #X connect 3 0 2 1; 113 | #X connect 7 0 2 0; 114 | #X connect 8 0 3 0; 115 | #X connect 9 0 8 0; 116 | #X connect 14 0 41 0; 117 | #X connect 15 0 41 0; 118 | #X connect 16 0 41 0; 119 | #X connect 17 0 41 0; 120 | #X connect 22 0 41 0; 121 | #X connect 25 0 41 0; 122 | #X connect 28 0 41 0; 123 | #X connect 30 0 41 0; 124 | #X connect 32 0 41 0; 125 | #X connect 34 0 41 0; 126 | #X connect 35 0 41 0; 127 | #X connect 41 0 6 0; 128 | #X connect 41 1 5 0; 129 | #X connect 46 0 0 0; 130 | #X connect 47 0 46 0; 131 | -------------------------------------------------------------------------------- /ats/src/atsh/undo.c: -------------------------------------------------------------------------------- 1 | /* 2 | ATSH-UNDO.C 3 | Oscar Pablo Di Liscia / Juan Pampin 4 | */ 5 | 6 | #include "atsh.h" 7 | 8 | extern ATS_SOUND *ats_sound; 9 | extern UNDO_DATA *undat; 10 | extern int floaded, scale_type, aveclen; 11 | extern short smr_done; 12 | extern char undo_file[]; 13 | int ned = 0, led = 1, undo = TRUE; 14 | extern SELECTION selection, position; 15 | extern ATS_HEADER atshed; 16 | 17 | //////////////////////////////////////////////////////////////////////////// 18 | void do_undo(GtkWidget *widget,gpointer data) 19 | { 20 | int aflag; 21 | FILE *pundo; 22 | int seek_point=0; 23 | int i,x; 24 | short shaux; 25 | double daux; 26 | 27 | if(undo==FALSE) {return;} 28 | if(floaded==FALSE || ned == 0) {return;} 29 | 30 | aflag=GPOINTER_TO_INT(data); 31 | led +=aflag; 32 | if(led < 0) {led=0; ned=1;} 33 | if(led == ned) {led=ned-1;} 34 | 35 | if((pundo=fopen(undo_file,"rb"))==NULL) { 36 | Popup("Could not open the UNDO backup file: /nUNDO DISABLED"); 37 | undo=FALSE; 38 | return; 39 | } 40 | fseek(pundo, (long int)seek_point, SEEK_SET); 41 | //find out where data starts and store it in seek_point 42 | 43 | for(i=0; i < led; ++i){ 44 | seek_point += (int)(atshed.par * sizeof(short)); 45 | seek_point += (int)((undat[i].to - undat[i].from) + 1 ) * sizeof(double) * undat[i].nsel; 46 | } 47 | 48 | //go in seek_point bytes 49 | fseek(pundo, (long int)seek_point, SEEK_SET); 50 | //read the backup data 51 | for(i=0; i < (int)atshed.par; ++i) { 52 | if(fread(&shaux,1,sizeof(short),pundo)==0) { 53 | Popup("Could not read on backup file: \nUNDO DISABLED"); 54 | fclose(pundo); 55 | undo=FALSE; 56 | return; 57 | } 58 | selected[i]=shaux; 59 | //g_print(" %d ", selected[i]); 60 | } 61 | //g_print("retrieving(%d): from=%d to=%d \n",ned,undat[led].from,undat[led].to); 62 | 63 | for(i=undat[led].from; i < undat[led].to+1; ++i) { 64 | 65 | for(x = 0; x < (int)atshed.par; ++x) { 66 | if(selected[x]==TRUE) { 67 | if(fread(&daux,1,sizeof(double),pundo)==0) { 68 | Popup("Could not read on backup file:(2) \nUNDO DISABLED"); 69 | //g_print("\n led= %d ned=%d \n", led, ned); 70 | fclose(pundo); 71 | undo=FALSE; 72 | return; 73 | } 74 | switch (undat[led].ed_kind) { 75 | case AMP_EDIT: 76 | ats_sound->amp[x][i]=daux; 77 | break; 78 | case FRE_EDIT: 79 | ats_sound->frq[x][i]=daux; 80 | break; 81 | } 82 | } 83 | } 84 | } 85 | 86 | 87 | selection.from=undat[led].from; 88 | selection.to=undat[led].to; 89 | selection.f1=undat[led].f1; 90 | selection.f2=undat[led].f2; 91 | vertex1=FALSE; vertex2=TRUE; //something IS selected 92 | // set_avec(selection.to - selection.from); 93 | fclose(pundo); 94 | if(scale_type==SMR_SCALE) { //smr values are computed only if the user is viewing them 95 | atsh_compute_SMR(ats_sound,selection.from,selection.to); 96 | } 97 | else { 98 | smr_done=FALSE; 99 | } 100 | draw_pixm(); 101 | // repaint(); 102 | 103 | // return; 104 | } 105 | //////////////////////////////////////////////////////////////// 106 | void backup_edition(int eddie) 107 | { 108 | FILE *pundo; 109 | int i, x; 110 | short shaux; 111 | double daux; 112 | 113 | if(undo==FALSE) {return;} 114 | pundo=fopen(undo_file,"ab"); 115 | if(pundo==0) { 116 | Popup("Could not open the UNDO backup file: \nUNDO DISABLED"); 117 | undo=FALSE; 118 | return; 119 | } 120 | fseek(pundo, 0L, SEEK_END); 121 | //store edition data 122 | undat=(UNDO_DATA*)realloc(undat,( ned + 1 ) * sizeof(UNDO_DATA)); 123 | 124 | undat[ned].from=selection.from; 125 | undat[ned].to =selection.to; 126 | undat[ned].f1 =selection.f1; 127 | undat[ned].f2 =selection.f2; 128 | undat[ned].ed_kind= eddie; 129 | undat[ned].nsel =0; 130 | //g_print("saving(%d): from=%d to=%d",ned,undat[ned].from,undat[ned].to); 131 | //write first the selected partials data 132 | for(i = 0; i < (int)atshed.par; ++i) { 133 | shaux=selected[i]; 134 | if(selected[i]==TRUE) { 135 | ++undat[ned].nsel; 136 | } 137 | if(fwrite(&shaux,1,sizeof(short),pundo)==FALSE) { 138 | Popup("Could not write on backup file: \nUNDO DISABLED"); 139 | fclose(pundo); 140 | undo=FALSE; 141 | return; 142 | } 143 | } 144 | 145 | //if changed, write either amplitude or frequency data 146 | //ONLY selected partials data are written 147 | for(i=0; i < aveclen; ++i) { 148 | 149 | for(x=0; x < (int)atshed.par; ++x) { 150 | if (selected[x]==TRUE){ 151 | switch (undat[ned].ed_kind) { 152 | case AMP_EDIT: 153 | daux=ats_sound->amp[x][selection.from + i]; 154 | break; 155 | case FRE_EDIT: 156 | daux=ats_sound->frq[x][selection.from + i]; 157 | break; 158 | } 159 | if(fwrite(&daux,1,sizeof(double),pundo)==FALSE) { 160 | Popup("Could not write on backup file: \nUNDO DISABLED"); 161 | fclose(pundo); 162 | undo=FALSE; 163 | return; 164 | } 165 | } 166 | } 167 | } 168 | 169 | 170 | // 171 | ++ned; //update editions counter 172 | led=ned; //set the edition level to NED 173 | fclose(pundo); 174 | return; 175 | } 176 | //////////////////////////////////////////////////////////////// 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /ats/src/atsh/help.h: -------------------------------------------------------------------------------- 1 | #define HELP_STR "***** Analysis Parameters Explanation*****\n\n" \ 2 | "Analysis parameters must be carefully tuned for the Analysis Algorithm to properly capture the nature of the signal to be analyzed. As there are a significant number of them, ATSH offers the possibility of Saving/Loading them in a Binary File carrying the extension \"*.apf\". The extension is not mandatory, but recommended. A brief explanation of each Analysis Parameters follows:\n\n" \ 3 | "1-Start (secs.): the starting time of the analysis in seconds.\n\n" \ 4 | "2-Duration (secs.): the duration time of the analysis in seconds. A zero means the whole duration of the input sound file.\n\n" \ 5 | "3-Lowest Frequency (Hz.): this parameter will partially determine the size of the Analysis Window to be used. To compute the size of the Analysis Window, the period of the Lowest Frequency in samples (SR / LF) is multiplied by the number of cycles of it the user wants to fit in the Analysis Window (see parameter 6). This value is rounded to the next power of two to determine the size of the FFT for the analysis. The remaining samples are zero-padded. If the signal is a single, harmonic sound, then the value of the Lowest Frequency should be its fundamental frequency or a sub-harmonic of it. If it is not harmonic, then its lowest significant frequency component may be a good starting value.\n\n" \ 6 | "4-Highest Frequency (Hz.): highest frequency to be taken into account for Peak Detection. Once it is determined that no relevant information is found beyond a certain frequency, the analysis may be faster and more accurate setting the Highest Frequency parameter to that value.\n\n" \ 7 | "5-Frequency Deviation (Ratio): frequency deviation allowed for each peak in the Peak Continuation Algorithm, as a ratio of the frequency involved. For instance, considering a peak at 440 Hz and a Deviation of .1 will produce that the Peak Continuation Algorithm will only try to find candidates for its continuation between 396 and 484 Hz (10% above and below the frequency of the peak). A small value is likely to produce more trajectories whilst a large value will reduce them, but at the cost of rendering information difficult to be further processed.\n\n" \ 8 | "6-Number of Cycles of Lowest Frequency to fit in Analysis Window: this will also partially determine the size of the Fourier Analysis Window to be used. See Parameter 3. For single harmonic signals, it is supposed to be more than one (typically 4).\n\n" \ 9 | "7-Hop Size (Ratio): size of the gap between one Analysis Window and the next expressed as a ratio of the Window Size. For instance, a Hop Size value of .25 will produce an Analysis Window of 2048 samples to \"jump\" by 512 samples (Windows will overlap for a 75% of their size). This parameter will also determine the size of the analysis frames obtained. Signals that change their spectra very fast (such as Speech sounds) may need a high frame rate in order to properly track their changes.\n\n" \ 10 | "8-Amplitude Threshold (dB): the highest amplitude value to be taken into account for Peak Detection.\n\n" \ 11 | "9-Window Type: the shape of the smoothing function to be used for the Fourier Analysis. There are four choices available at present: Blackman, Blackman-Harris, Von Hann, and Hanning. Precise specifications about them are easily found in any DSP book.\n\n" \ 12 | "10-Track Length (Frames): The Peak Continuation Algorithm will \"look-back\" by Length frames in order to do its job better, preventing frequency trajectories from curving too much and loosing stability. However, a large value for this parameter will slow down the analysis significantly.\n\n" \ 13 | "11-Minimal Segment Length (Frames): once the analysis is done, the spectral data can be further \"cleaned\" up during post-processing. Trajectories shorter than this value are suppressed if their average SMR is below Minimal Segment SMR (see parameters 16 and 14). This might help to avoid non-relevant sudden changes while keeping a high frame rate, reducing also the number of intermittent sinusoids during synthesis.\n\n" \ 14 | "12-Minimal Gap Length (Frames): as parameter 11, this one is also used to clean up the data during post-processing. In this case, gaps (zero amplitude values, i.e. theoretical \"silence\") longer than Length frames are filled up with amplitude/frequency values obtained by linear interpolation of the adjacent active frames. This parameter prevents sudden interruptions of stable trajectories while keeping a high frame rate.\n\n" \ 15 | "13-SMR Threshold (dB SPL): also a post-processing parameter, the SMR Threshold is used to eliminate partials with low averages.\n\n" \ 16 | "14-Minimal Segment SMR (dB SPL): this parameter is used in combination with parameter 11. Short segments with SMR average below this value will be removed during post-processing.\n\n" \ 17 | "15-Last Peak Contribution (0 to 1): as explained in Parameter 10, the Peak Continuation Algorithm \"looks-back\" several number of frames to do its job better. This parameter will help to weight the contribution of the first precedent peak over the others. A zero value means that all precedent peaks (to the size of Parameter 10) are equally taken in account.\n\n" \ 18 | "16-SMR Contribution (0 to 1): In addition to the proximity in frequency of the peaks, the ATS Peak Continuation Algorithm may use psycho-acoustic information (the Signal-to-Mask-Ratio, or SMR) to improve the perceptual results. This parameter indicates how much the SMR information is used during tracking. For instance, a value of .5 makes the Peak Continuation Algorithm to use a 50% of SMR information and a 50% of Frequency Proximity information to decide which is the best candidate to continue a sinusoidal track." 19 | 20 | -------------------------------------------------------------------------------- /ats/src/sndlib/install-sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd="$cpprog" 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd="$stripprog" 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "install: no input file specified" 110 | exit 1 111 | else 112 | true 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d $dst ]; then 120 | instcmd=: 121 | else 122 | instcmd=mkdir 123 | fi 124 | else 125 | 126 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 127 | # might cause directories to be created, which would be especially bad 128 | # if $src (and thus $dsttmp) contains '*'. 129 | 130 | if [ -f $src -o -d $src ] 131 | then 132 | true 133 | else 134 | echo "install: $src does not exist" 135 | exit 1 136 | fi 137 | 138 | if [ x"$dst" = x ] 139 | then 140 | echo "install: no destination specified" 141 | exit 1 142 | else 143 | true 144 | fi 145 | 146 | # If destination is a directory, append the input filename; if your system 147 | # does not like double slashes in filenames, you may need to add some logic 148 | 149 | if [ -d $dst ] 150 | then 151 | dst="$dst"/`basename $src` 152 | else 153 | true 154 | fi 155 | fi 156 | 157 | ## this sed command emulates the dirname command 158 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 159 | 160 | # Make sure that the destination directory exists. 161 | # this part is taken from Noah Friedman's mkinstalldirs script 162 | 163 | # Skip lots of stat calls in the usual case. 164 | if [ ! -d "$dstdir" ]; then 165 | defaultIFS=' 166 | ' 167 | IFS="${IFS-${defaultIFS}}" 168 | 169 | oIFS="${IFS}" 170 | # Some sh's can't handle IFS=/ for some reason. 171 | IFS='%' 172 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 173 | IFS="${oIFS}" 174 | 175 | pathcomp='' 176 | 177 | while [ $# -ne 0 ] ; do 178 | pathcomp="${pathcomp}${1}" 179 | shift 180 | 181 | if [ ! -d "${pathcomp}" ] ; 182 | then 183 | $mkdirprog "${pathcomp}" 184 | else 185 | true 186 | fi 187 | 188 | pathcomp="${pathcomp}/" 189 | done 190 | fi 191 | 192 | if [ x"$dir_arg" != x ] 193 | then 194 | $doit $instcmd $dst && 195 | 196 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 197 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 198 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 199 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 200 | else 201 | 202 | # If we're going to rename the final executable, determine the name now. 203 | 204 | if [ x"$transformarg" = x ] 205 | then 206 | dstfile=`basename $dst` 207 | else 208 | dstfile=`basename $dst $transformbasename | 209 | sed $transformarg`$transformbasename 210 | fi 211 | 212 | # don't allow the sed command to completely eliminate the filename 213 | 214 | if [ x"$dstfile" = x ] 215 | then 216 | dstfile=`basename $dst` 217 | else 218 | true 219 | fi 220 | 221 | # Make a temp file name in the proper directory. 222 | 223 | dsttmp=$dstdir/#inst.$$# 224 | 225 | # Move or copy the file name to the temp name 226 | 227 | $doit $instcmd $src $dsttmp && 228 | 229 | trap "rm -f ${dsttmp}" 0 && 230 | 231 | # and set any options; do chmod last to preserve setuid bits 232 | 233 | # If any of these fail, we abort the whole thing. If we want to 234 | # ignore errors from any of these, just make sure not to ignore 235 | # errors from the above "$doit $instcmd $src $dsttmp" command. 236 | 237 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 238 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 239 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 240 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 241 | 242 | # Now rename the file to the real destination. 243 | 244 | $doit $rmcmd -f $dstdir/$dstfile && 245 | $doit $mvcmd $dsttmp $dstdir/$dstfile 246 | 247 | fi && 248 | 249 | 250 | exit 0 251 | -------------------------------------------------------------------------------- /ats-csound/ugnorman.h: -------------------------------------------------------------------------------- 1 | /* header file for all of the ATScsound functions by Alex Norman 2 | */ 3 | 4 | typedef struct atsdataloc 5 | { 6 | double amp; 7 | double freq; 8 | } ATS_DATA_LOC; 9 | 10 | typedef struct _randiats 11 | { //the data for the randi UG 12 | int size; //size of the frame in samples this should be sr/freq. 13 | float a1; //first amplitude value 14 | float a2; //next amplitude value 15 | int cnt; //sample position counter 16 | } RANDIATS; 17 | 18 | typedef struct _atsnzaux 19 | { 20 | double buf[25]; 21 | float phaseinc[25]; 22 | float nfreq[25]; 23 | RANDIATS randinoise[25]; 24 | } atsnzAUX; 25 | 26 | typedef struct atsstruct 27 | { 28 | double magic; /* ats magic number */ 29 | double sampr; /* sampling rate */ 30 | double frmsz; /* frame size in samples */ 31 | double winsz; /* window size in samples */ 32 | double npartials; /* number of partials */ 33 | double nfrms; /* number of frames */ 34 | double ampmax; /* max amplitude */ 35 | double freqmax; // max frequency 36 | double dur; /* duration seconds */ 37 | double type; /* Ats Frame type 1-4 */ 38 | } ATSSTRUCT; 39 | 40 | 41 | typedef struct _atsinfo 42 | { 43 | OPDS h; 44 | float *ireturn, *ifileno, *ilocation; //the return value, the ats file and a location selection 45 | } ATSINFO; 46 | 47 | 48 | /* structures to pass data to the opcodes */ 49 | 50 | typedef struct _atsread 51 | { 52 | OPDS h; 53 | float *kfreq, *kamp, *ktimpnt, *ifileno, *ipartial; //outputs (2) and inputs 54 | int maxFr; // indicates the maximun frame 55 | int prFlg; //a flag used to indicate if we've steped out of the time range of the data, so we don't print too many warnings 56 | double * datastart; //points to the start of the data 57 | int partialloc, frmInc; //tells the location of the partal to output and the number of doubles to increment to get to the next frame 58 | MEMFIL * atsmemfile; 59 | double timefrmInc; 60 | int swapped; //indicates if the data file is byte swapped or not 61 | } ATSREAD; 62 | 63 | typedef struct _atsreadnz 64 | { 65 | OPDS h; 66 | float *kenergy, *ktimpnt, *ifileno, *inzbin; //outputs (1) and inputs 67 | int maxFr; 68 | int prFlg; //a flag used to indicate if we've steped out of the time range of the data, so we don't print too many warnings 69 | double * datastart; //points to the start of the data 70 | int nzbandloc, frmInc; 71 | MEMFIL * atsmemfile; 72 | double timefrmInc; 73 | int swapped; //indicates if the data file is byte swapped or not 74 | } ATSREADNZ; 75 | 76 | typedef struct _atsadd 77 | { 78 | OPDS h; 79 | float *aoutput, *ktimpnt, *kfmod, *ifileno, *ifn, *iptls; // audio output and k & i inputs 80 | float *iptloffset, *iptlincr, *igatefun; // optional arguments 81 | 82 | FUNC *ftp, *AmpGateFunc; // pointer to table with wave to synthesize sound 83 | AUXCH auxch; 84 | MEMFIL * atsmemfile; 85 | 86 | double maxFr; 87 | int prFlg; //a flag used to indicate if we've steped out of the time range of the data, so we don't print too many warnings 88 | double timefrmInc; 89 | double MaxAmp; // maximum amplitude in anaylsis file 90 | int firstpartial, partialinc, frmInc; 91 | double * datastart; 92 | int memsize; //stores the size of memeory in the aux alloc 93 | double *oscphase; // oscillator phase 94 | ATS_DATA_LOC * buf; 95 | int swapped; //indicates if the data file is byte swapped or not 96 | } ATSADD; 97 | 98 | typedef struct _atsaddnz 99 | { 100 | OPDS h; 101 | float *aoutput, *ktimpnt, *ifileno, *ibands; // audio output and k & i inputs 102 | float *ibandoffset, *ibandincr; // optional arguments 103 | 104 | MEMFIL *atsmemfile; // a pointer into the ATS file 105 | 106 | double maxFr; 107 | int prFlg; 108 | int frmInc; // amount to increment frame pointer to get to next frame 109 | double timefrmInc; 110 | double winsize; // size of windows in analysis file, used to compute RMS amplitude from energy in noise band 111 | 112 | double * datastart; 113 | double firstband; 114 | 115 | double buf[25]; // stores band information for passing data 116 | double phaseinc[25]; // to create an array of noise 117 | double oscphase[25]; //the phase of all the oscilators 118 | RANDIATS randinoise[25]; // a pointer to the interpolated random noise info 119 | double nfreq[25]; 120 | ATSSTRUCT atshead; 121 | int swapped; //indicates if the data file is byte swapped or not 122 | } ATSADDNZ; 123 | 124 | typedef struct _atsbufread 125 | { 126 | OPDS h; 127 | float *ktimpnt, *kfmod, *ifileno, *iptls; 128 | float *iptloffset, *iptlincr; // optional arguments 129 | MEMFIL *mfp; 130 | int maxFr, prFlg; 131 | /* base Frame (in frameData0) and maximum frame on file, ptr to fr, size */ 132 | AUXCH auxch; 133 | ATS_DATA_LOC *table; //store freq and amp info for later use 134 | ATS_DATA_LOC *utable; //store freq and amp info for later use (unsorted) 135 | int frmInc; // amount to increment frame pointer to get to next frame 136 | int firstpartial; // location of first wanted partial in the frame 137 | int partialinc; // amount to increment pointer by to get at the next partial in a frame 138 | int memsize; // memory size of aux channel 139 | double timefrmInc; 140 | float MaxAmp; // maximum amplitude in anaylsis file 141 | double *datastart; // pointer to the data (past the header) 142 | ATSSTRUCT atshead; 143 | int swapped; //indicates if the data file is byte swapped or not 144 | } ATSBUFREAD; 145 | 146 | typedef struct _atscross 147 | { 148 | OPDS h; 149 | float *aoutput, *ktimpnt, *kfmod, *ifileno, *ifn, *kmyamp, *katsbufamp, *iptls; // audio output and k & i inputs 150 | float *iptloffset, *iptlincr, *igatefun; // optional arguments 151 | 152 | FUNC *ftp, *AmpGateFunc; // pointer to table with wave to synthesize sound 153 | AUXCH auxch; 154 | MEMFIL * atsmemfile; 155 | 156 | double maxFr; 157 | int prFlg; //a flag used to indicate if we've steped out of the time range of the data, so we don't print too many warnings 158 | double timefrmInc; 159 | double MaxAmp; // maximum amplitude in anaylsis file 160 | int firstpartial, partialinc, frmInc; 161 | double * datastart; 162 | int memsize; //stores the size of memeory in the aux alloc 163 | double *oscphase; // oscillator phase 164 | ATS_DATA_LOC * buf; 165 | int swapped; //indicates if the data file is byte swapped or not 166 | } ATSCROSS; //modified from atsadd 167 | 168 | typedef struct _atssinnoi 169 | { 170 | OPDS h; 171 | float *aoutput, *ktimpnt, *ksinamp, *knzamp, *kfreq, *ifileno, *iptls; // audio output and k & i inputs 172 | float *iptloffset, *iptlincr, *igatefun; // optional arguments 173 | 174 | MEMFIL *atsmemfile; // a pointer into the ATS file 175 | AUXCH auxch; 176 | 177 | double maxFr; 178 | int prFlg; 179 | int memsize; 180 | int nzmemsize; 181 | //double winsize; // size of windows in analysis file, used to compute RMS amplitude from energy in noise band 182 | 183 | double * datastart; 184 | double * nzdata; 185 | 186 | int firstpartial; 187 | int partialinc; 188 | int firstband; 189 | int frmInc; // amount to increment frame pointer to get to next frame 190 | double timefrmInc; 191 | int npartials; 192 | 193 | ATS_DATA_LOC * oscbuf; // stores band information for passing data 194 | 195 | double * nzbuf; // stores band information for passing data 196 | double * oscphase; //the phase of all the oscilators 197 | RANDIATS * randinoise; // a pointer to the interpolated random noise info 198 | ATSSTRUCT * atshead; 199 | char * filename; 200 | int swapped; //indicates if the data file is byte swapped or not 201 | } ATSSINNOI; 202 | 203 | typedef struct _atspartialtap 204 | { 205 | OPDS h; 206 | float *kfreq, *kamp, *iparnum; //output freq, amp, input: partialnumber 207 | } ATSPARTIALTAP; 208 | 209 | typedef struct _atsinterpread 210 | { 211 | OPDS h; 212 | float *kamp, *kfreq; //output amp, input: frequency 213 | int overflowflag; 214 | } ATSINTERPREAD; 215 | 216 | -------------------------------------------------------------------------------- /ats/src/sndlib/sndlib-strings.h: -------------------------------------------------------------------------------- 1 | #ifndef SNDLIB_STRINGS_H 2 | #define SNDLIB_STRINGS_H 3 | 4 | #define S_make_sound_data "make-sound-data" 5 | #define S_mus_aifc "mus-aifc" 6 | #define S_mus_aiff "mus-aiff" 7 | #define S_mus_alaw "mus-alaw" 8 | #define S_mus_audio_adat_in "mus-audio-adat-in" 9 | #define S_mus_audio_adat_out "mus-audio-adat-out" 10 | #define S_mus_audio_aes_in "mus-audio-aes-in" 11 | #define S_mus_audio_aes_out "mus-audio-aes-out" 12 | #define S_mus_audio_amp "mus-audio-amp" 13 | #define S_mus_audio_aux_input "mus-audio-aux-input" 14 | #define S_mus_audio_aux_output "mus-audio-aux-output" 15 | #define S_mus_audio_bass "mus-audio-bass" 16 | #define S_mus_audio_cd "mus-audio-cd" 17 | #define S_mus_audio_channel "mus-audio-channel" 18 | #define S_mus_audio_close "mus-audio-close" 19 | #define S_mus_audio_dac_filter "mus-audio-dac-filter" 20 | #define S_mus_audio_dac_out "mus-audio-dac-out" 21 | #define S_mus_audio_default "mus-audio-default" 22 | #define S_mus_audio_digital_in "mus-audio-digital-in" 23 | #define S_mus_audio_digital_out "mus-audio-digital-out" 24 | #define S_mus_audio_direction "mus-audio-direction" 25 | #define S_mus_audio_duplex_default "mus-audio-duplex-default" 26 | #define S_mus_audio_format "mus-audio-format" 27 | #define S_mus_audio_igain "mus-audio-igain" 28 | #define S_mus_audio_imix "mus-audio-imix" 29 | #define S_mus_audio_line "mus-audio-line" 30 | #define S_mus_audio_line1 "mus-audio-line1" 31 | #define S_mus_audio_line2 "mus-audio-line2" 32 | #define S_mus_audio_line3 "mus-audio-line3" 33 | #define S_mus_audio_line_in "mus-audio-line-in" 34 | #define S_mus_audio_line_out "mus-audio-line-out" 35 | #define S_mus_audio_microphone "mus-audio-microphone" 36 | #define S_mus_audio_mixer "mus-audio-mixer" 37 | #define S_mus_audio_mixer_read "mus-audio-mixer-read" 38 | #define S_mus_audio_mixer_write "mus-audio-mixer-write" 39 | #define S_mus_audio_ogain "mus-audio-ogain" 40 | #define S_mus_audio_open_input "mus-audio-open-input" 41 | #define S_mus_audio_open_output "mus-audio-open-output" 42 | #define S_mus_audio_pcm "mus-audio-pcm" 43 | #define S_mus_audio_pcm2 "mus-audio-pcm2" 44 | #define S_mus_audio_port "mus-audio-port" 45 | #define S_mus_audio_read "mus-audio-read" 46 | #define S_mus_audio_reclev "mus-audio-reclev" 47 | #define S_mus_audio_report "mus-audio-report" 48 | #define S_mus_audio_restore "mus-audio-restore" 49 | #define S_mus_audio_samples_per_channel "mus-audio-samples-per-channel" 50 | #define S_mus_audio_save "mus-audio-save" 51 | #define S_mus_audio_set_oss_buffers "mus-audio-set-oss-buffers" 52 | #define S_mus_audio_spdif_in "mus-audio-spdif-in" 53 | #define S_mus_audio_spdif_out "mus-audio-spdif-out" 54 | #define S_mus_audio_speakers "mus-audio-speakers" 55 | #define S_mus_audio_srate "mus-audio-srate" 56 | #define S_mus_audio_sun_outputs "mus-audio-sun-outputs" 57 | #define S_mus_audio_synth "mus-audio-synth" 58 | #define S_mus_audio_systems "mus-audio-systems" 59 | #define S_mus_audio_treble "mus-audio-treble" 60 | #define S_mus_audio_write "mus-audio-write" 61 | #define S_mus_b24int "mus-b24int" 62 | #define S_mus_bdouble "mus-bdouble" 63 | #define S_mus_bdouble_unscaled "mus-bdouble-unscaled" 64 | #define S_mus_bfloat "mus-bfloat" 65 | #define S_mus_bfloat_unscaled "mus-bfloat-unscaled" 66 | #define S_mus_bicsf "mus-bicsf" 67 | #define S_mus_bint "mus-bint" 68 | #define S_mus_bintn "mus-bintn" 69 | #define S_mus_bshort "mus-bshort" 70 | #define S_mus_byte "mus-byte" 71 | #define S_mus_data_format_bytes_per_sample "mus-data-format-bytes-per-sample" 72 | #define S_mus_data_format_name "mus-data-format-name" 73 | #define S_mus_error_to_string "mus-error-to-string" 74 | #define S_mus_expand_filename "mus-expand-filename" 75 | #define S_mus_file_data_clipped "mus-file-data-clipped" 76 | #define S_mus_file_prescaler "mus-file-prescaler" 77 | #define S_mus_header_type_name "mus-header-type-name" 78 | #define S_mus_ircam "mus-ircam" 79 | #define S_mus_l24int "mus-l24int" 80 | #define S_mus_ldouble "mus-ldouble" 81 | #define S_mus_ldouble_unscaled "mus-ldouble-unscaled" 82 | #define S_mus_lfloat "mus-lfloat" 83 | #define S_mus_lfloat_unscaled "mus-lfloat-unscaled" 84 | #define S_mus_lint "mus-lint" 85 | #define S_mus_lintn "mus-lintn" 86 | #define S_mus_lshort "mus-lshort" 87 | #define S_mus_mulaw "mus-mulaw" 88 | #define S_mus_next "mus-next" 89 | #define S_mus_nist "mus-nist" 90 | #define S_mus_out_format "mus-out-format" 91 | #define S_mus_raw "mus-raw" 92 | #define S_mus_riff "mus-riff" 93 | #define S_mus_sound_chans "mus-sound-chans" 94 | #define S_mus_sound_close_input "mus-sound-close-input" 95 | #define S_mus_sound_close_output "mus-sound-close-output" 96 | #define S_mus_sound_comment "mus-sound-comment" 97 | #define S_mus_sound_data_format "mus-sound-data-format" 98 | #define S_mus_sound_data_location "mus-sound-data-location" 99 | #define S_mus_sound_datum_size "mus-sound-datum-size" 100 | #define S_mus_sound_duration "mus-sound-duration" 101 | #define S_mus_sound_forget "mus-sound-forget" 102 | #define S_mus_sound_frames "mus-sound-frames" 103 | #define S_mus_sound_header_type "mus-sound-header-type" 104 | #define S_mus_sound_length "mus-sound-length" 105 | #define S_mus_sound_loop_info "mus-sound-loop-info" 106 | #define S_mus_sound_maxamp "mus-sound-maxamp" 107 | #define S_mus_sound_maxamp_exists "mus-sound-maxamp-exists?" 108 | #define S_mus_sound_open_input "mus-sound-open-input" 109 | #define S_mus_sound_open_output "mus-sound-open-output" 110 | #define S_mus_sound_prune "mus-sound-prune" 111 | #define S_mus_sound_read "mus-sound-read" 112 | #define S_mus_sound_reopen_output "mus-sound-reopen-output" 113 | #define S_mus_sound_report_cache "mus-sound-report-cache" 114 | #define S_mus_sound_samples "mus-sound-samples" 115 | #define S_mus_sound_seek_frame "mus-sound-seek-frame" 116 | #define S_mus_sound_srate "mus-sound-srate" 117 | #define S_mus_sound_type_specifier "mus-sound-type-specifier" 118 | #define S_mus_sound_write "mus-sound-write" 119 | #define S_mus_sound_write_date "mus-sound-write-date" 120 | #define S_mus_soundfont "mus-soundfont" 121 | #define S_mus_svx "mus-svx" 122 | #define S_mus_ubshort "mus-ubshort" 123 | #define S_mus_ubyte "mus-ubyte" 124 | #define S_mus_ulshort "mus-ulshort" 125 | #define S_mus_voc "mus-voc" 126 | 127 | #define S_new_sound_hook "new-sound-hook" 128 | 129 | #define S_sound_data2vct "sound-data->vct" 130 | #define S_sound_data_chans "sound-data-chans" 131 | #define S_sound_data_length "sound-data-length" 132 | #define S_sound_data_maxamp "sound-data-maxamp" 133 | #define S_sound_data_p "sound-data?" 134 | #define S_sound_data_ref "sound-data-ref" 135 | #define S_sound_data_setB "sound-data-set!" 136 | #define S_vct2sound_data "vct->sound-data" 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /ats/src/atsa/peak-tracking.c: -------------------------------------------------------------------------------- 1 | /* peak-tracking.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | /* private types */ 9 | typedef struct { 10 | int size; 11 | ATS_PEAK *cands; 12 | } ATS_CANDS; 13 | 14 | /* private function prototypes */ 15 | ATS_PEAK *find_candidates(ATS_PEAK *peaks, int peaks_size, double lo, double hi, int *cand_size); 16 | void sort_candidates(ATS_CANDS *cands, ATS_PEAK peak, float SMR_cont); 17 | 18 | /* peak_tracking 19 | * ============= 20 | * connects peaks from one analysis frame to tracks 21 | * returns a pointer to two frames of orphaned peaks. 22 | * tracks: pointer to the tracks 23 | * tracks_size: numeber of tracks 24 | * peaks: peaks to connect 25 | * peaks_size: number of peaks 26 | * frq_dev: frequency deviation from tracks 27 | * SMR_cont: contribution of SMR to tracking 28 | * n_partials: pointer to the number of partials before tracking 29 | */ 30 | ATS_FRAME *peak_tracking(ATS_PEAK *tracks, int *tracks_size, ATS_PEAK *peaks, int *peaks_size, float frq_dev, float SMR_cont, int *n_partials) 31 | { 32 | ATS_CANDS *track_candidates = (ATS_CANDS *)malloc(*peaks_size*sizeof(ATS_CANDS)); 33 | double lo, hi; 34 | int k, j, used, goback; 35 | ATS_FRAME *returned_peaks = (ATS_FRAME *)malloc(2*sizeof(ATS_FRAME)); 36 | 37 | returned_peaks[0].peaks = returned_peaks[1].peaks = NULL; 38 | returned_peaks[0].n_peaks = returned_peaks[1].n_peaks = 0; 39 | 40 | /* sort data to prepare for matching */ 41 | qsort(tracks, *tracks_size, sizeof(ATS_PEAK), peak_frq_inc); 42 | qsort(peaks, *peaks_size, sizeof(ATS_PEAK), peak_frq_inc); 43 | 44 | /* find candidates for each peak and set each peak to best candidate */ 45 | for (k=0; k<*peaks_size; k++) { 46 | /* find frq limits for candidates */ 47 | lo = peaks[k].frq - (.5 * peaks[k].frq * frq_dev); 48 | hi = peaks[k].frq + (.5 * peaks[k].frq * frq_dev); 49 | /* get possible candidates */ 50 | track_candidates[k].size = 0; 51 | track_candidates[k].cands = find_candidates(tracks, *tracks_size, lo, hi, &track_candidates[k].size); 52 | if(track_candidates[k].size) { 53 | sort_candidates(&track_candidates[k], peaks[k], SMR_cont); 54 | peaks[k].track = track_candidates[k].cands[0].track; 55 | } 56 | } 57 | 58 | /* compare adjacent peaks track numbers to insure unique track numbers */ 59 | do { 60 | goback = 0; 61 | for (j=0; j<(*peaks_size - 1); j++) 62 | if((peaks[j].track == peaks[j+1].track) && (peaks[j].track > -1)) { 63 | if(track_candidates[j].cands[0].amp > track_candidates[j+1].cands[0].amp) { 64 | track_candidates[j].cands[0].amp = ATSA_HFREQ; 65 | qsort(track_candidates[j].cands, track_candidates[j].size, sizeof(ATS_PEAK), peak_amp_inc); 66 | if(track_candidates[j].cands[0].amp < ATSA_HFREQ) { 67 | peaks[j].track = track_candidates[j].cands[0].track; 68 | goback = 1; 69 | } else peaks[j].track = -1; 70 | } else { 71 | track_candidates[j+1].cands[0].amp = ATSA_HFREQ; 72 | qsort(track_candidates[j+1].cands, track_candidates[j+1].size, sizeof(ATS_PEAK), peak_amp_inc); 73 | if(track_candidates[j+1].cands[0].amp < ATSA_HFREQ) 74 | peaks[j+1].track = track_candidates[j+1].cands[0].track; 75 | else peaks[j+1].track = -1; 76 | } 77 | } 78 | } while (goback); 79 | 80 | /* by this point, all peaks will either have a unique track number, or -1 81 | now we need to take care of those left behind */ 82 | for(k=0; k<*peaks_size; k++) 83 | if(peaks[k].track == -1) { 84 | peaks[k].track = (*n_partials)++; 85 | returned_peaks[1].peaks = push_peak(&peaks[k], returned_peaks[1].peaks, &returned_peaks[1].n_peaks); 86 | } 87 | 88 | /* check for tracks that didnt get assigned */ 89 | for(k=0; k<*tracks_size; k++) { 90 | used = 0; 91 | for(j=0; j<*peaks_size; j++) 92 | if(tracks[k].track == peaks[j].track) { 93 | used = 1; 94 | break; 95 | } 96 | if(!used) returned_peaks[0].peaks = push_peak(&tracks[k], returned_peaks[0].peaks, &returned_peaks[0].n_peaks); 97 | } 98 | 99 | for (k=0; k<*peaks_size; k++) free(track_candidates[k].cands); 100 | free(track_candidates); 101 | return(returned_peaks); 102 | } 103 | 104 | /* find_candidates 105 | * =============== 106 | * find candidates to continue a track form an array of peaks 107 | * returns a pointer to an array of candidates 108 | * peaks: pointer to array of peaks 109 | * peaks_size: number of peaks 110 | * lo: lowest frequency to consider candidates 111 | * hi: highest frequency to consider candidates 112 | * cand_size: pointer to the number of candidates returned 113 | */ 114 | ATS_PEAK *find_candidates(ATS_PEAK *peaks, int peaks_size, double lo, double hi, int *cand_size) 115 | { 116 | int i; 117 | ATS_PEAK *cand_list = NULL; 118 | 119 | for(i=0; isize; i++) 140 | cands->cands[i].amp = (fabs(cands->cands[i].frq - peak.frq) + (SMR_cont * fabs(cands->cands[i].smr - peak.smr))) / (SMR_cont + 1); 141 | 142 | /* sort list by amp (increasing) */ 143 | qsort(cands->cands, cands->size, sizeof(ATS_PEAK), peak_amp_inc); 144 | 145 | } 146 | 147 | /* update_tracks 148 | * ============= 149 | * updates analysis tracks 150 | * returns a pointer to the tracks. 151 | * tracks: pointer to the tracks 152 | * tracks_size: numeber of tracks 153 | * track_len: length of tracks 154 | * frame_n: analysis frame number 155 | * ana_frames: pointer to previous analysis frames 156 | * last_peak_cont: contribution of last peak to the track 157 | */ 158 | ATS_PEAK *update_tracks (ATS_PEAK *tracks, int *tracks_size, int track_len, int frame_n, ATS_FRAME *ana_frames, float last_peak_cont) 159 | { 160 | int frames, first_frame, track, g, i, k; 161 | double frq_acc, last_frq, amp_acc, last_amp, smr_acc, last_smr; 162 | int f, a, s; 163 | ATS_PEAK *l_peaks, *peak; 164 | 165 | if (tracks != NULL) { 166 | frames = (frame_n < track_len) ? frame_n : track_len; 167 | first_frame = frame_n - frames; 168 | for(g=0; g<*tracks_size; g++) { 169 | track = tracks[g].track; 170 | frq_acc = last_frq = amp_acc = last_amp = smr_acc = last_smr = 0.0; 171 | f = a = s = 0; 172 | for(i=first_frame; ifrq > 0.0) { 182 | last_frq = peak->frq; 183 | frq_acc += peak->frq; 184 | f++; 185 | } 186 | if (peak->amp > 0.0) { 187 | last_amp = peak->amp; 188 | amp_acc += peak->amp; 189 | a++; 190 | } 191 | if (peak->smr > 0.0) { 192 | last_smr = peak->smr; 193 | smr_acc += peak->smr; 194 | s++; 195 | } 196 | } 197 | } 198 | if(f) tracks[g].frq = (last_peak_cont * last_frq) + ((1 - last_peak_cont) * (frq_acc / f)); 199 | if(a) tracks[g].amp = (last_peak_cont * last_amp) + ((1 - last_peak_cont) * (amp_acc / a)); 200 | if(s) tracks[g].smr = (last_peak_cont * last_smr) + ((1 - last_peak_cont) * (smr_acc / s)); 201 | } 202 | } else 203 | for(g=0; g&2 128 | exit 1 129 | else 130 | : 131 | fi 132 | 133 | if [ x"$dir_arg" != x ]; then 134 | dst=$src 135 | src="" 136 | 137 | if [ -d "$dst" ]; then 138 | instcmd=: 139 | chmodcmd="" 140 | else 141 | instcmd=$mkdirprog 142 | fi 143 | else 144 | 145 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 146 | # might cause directories to be created, which would be especially bad 147 | # if $src (and thus $dsttmp) contains '*'. 148 | 149 | if [ -f "$src" ] || [ -d "$src" ] 150 | then 151 | : 152 | else 153 | echo "$0: $src does not exist" >&2 154 | exit 1 155 | fi 156 | 157 | if [ x"$dst" = x ] 158 | then 159 | echo "$0: no destination specified" >&2 160 | exit 1 161 | else 162 | : 163 | fi 164 | 165 | # If destination is a directory, append the input filename; if your system 166 | # does not like double slashes in filenames, you may need to add some logic 167 | 168 | if [ -d "$dst" ] 169 | then 170 | dst=$dst/`basename "$src"` 171 | else 172 | : 173 | fi 174 | fi 175 | 176 | ## this sed command emulates the dirname command 177 | dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 178 | 179 | # Make sure that the destination directory exists. 180 | # this part is taken from Noah Friedman's mkinstalldirs script 181 | 182 | # Skip lots of stat calls in the usual case. 183 | if [ ! -d "$dstdir" ]; then 184 | defaultIFS=' 185 | ' 186 | IFS="${IFS-$defaultIFS}" 187 | 188 | oIFS=$IFS 189 | # Some sh's can't handle IFS=/ for some reason. 190 | IFS='%' 191 | set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` 192 | IFS=$oIFS 193 | 194 | pathcomp='' 195 | 196 | while [ $# -ne 0 ] ; do 197 | pathcomp=$pathcomp$1 198 | shift 199 | 200 | if [ ! -d "$pathcomp" ] ; 201 | then 202 | $mkdirprog "$pathcomp" 203 | else 204 | : 205 | fi 206 | 207 | pathcomp=$pathcomp/ 208 | done 209 | fi 210 | 211 | if [ x"$dir_arg" != x ] 212 | then 213 | $doit $instcmd "$dst" && 214 | 215 | if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && 216 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && 217 | if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && 218 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi 219 | else 220 | 221 | # If we're going to rename the final executable, determine the name now. 222 | 223 | if [ x"$transformarg" = x ] 224 | then 225 | dstfile=`basename "$dst"` 226 | else 227 | dstfile=`basename "$dst" $transformbasename | 228 | sed $transformarg`$transformbasename 229 | fi 230 | 231 | # don't allow the sed command to completely eliminate the filename 232 | 233 | if [ x"$dstfile" = x ] 234 | then 235 | dstfile=`basename "$dst"` 236 | else 237 | : 238 | fi 239 | 240 | # Make a couple of temp file names in the proper directory. 241 | 242 | dsttmp=$dstdir/_inst.$$_ 243 | rmtmp=$dstdir/_rm.$$_ 244 | 245 | # Trap to clean up temp files at exit. 246 | 247 | trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 248 | trap '(exit $?); exit' 1 2 13 15 249 | 250 | # Move or copy the file name to the temp name 251 | 252 | $doit $instcmd "$src" "$dsttmp" && 253 | 254 | # and set any options; do chmod last to preserve setuid bits 255 | 256 | # If any of these fail, we abort the whole thing. If we want to 257 | # ignore errors from any of these, just make sure not to ignore 258 | # errors from the above "$doit $instcmd $src $dsttmp" command. 259 | 260 | if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && 261 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && 262 | if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && 263 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && 264 | 265 | # Now remove or move aside any old file at destination location. We try this 266 | # two ways since rm can't unlink itself on some systems and the destination 267 | # file might be busy for other reasons. In this case, the final cleanup 268 | # might fail but the new file should still install successfully. 269 | 270 | { 271 | if [ -f "$dstdir/$dstfile" ] 272 | then 273 | $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || 274 | $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || 275 | { 276 | echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 277 | (exit 1); exit 278 | } 279 | else 280 | : 281 | fi 282 | } && 283 | 284 | # Now rename the file to the real destination. 285 | 286 | $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" 287 | 288 | fi && 289 | 290 | # The final little trick to "correctly" pass the exit status to the exit trap. 291 | 292 | { 293 | (exit 0); exit 294 | } 295 | -------------------------------------------------------------------------------- /ats/src/atsa/residual.c: -------------------------------------------------------------------------------- 1 | /* residual.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | /* private function prototypes */ 9 | int compute_m(double pha_1, double frq_1, double pha, double frq, int buffer_size); 10 | double compute_aux(double pha_1, double pha, double frq_1, int buffer_size, int M); 11 | double compute_alpha(double aux, double frq_1, double frq, int buffer_size); 12 | double compute_beta(double aux, double frq_1, double frq, int buffer_size); 13 | double interp_phase(double pha_1, double frq_1, double alpha, double beta, int i); 14 | void read_frame(mus_sample_t **fil, int fil_len, int samp_1, int samp_2, double *in_buffer); 15 | void synth_buffer(double a1,double a2, double f1, double f2, double p1, double p2, double *buffer, int frame_samps); 16 | 17 | 18 | /* Functions for phase interpolation 19 | * All this comes from JOS/XJS article on PARSHL. 20 | * Original phase interpolation eqns. by Qualtieri/McAulay. 21 | */ 22 | 23 | int compute_m(double pha_1, double frq_1, double pha, double frq, int buffer_size) 24 | { 25 | // int val = (int)((((pha_1 + (frq_1 * (double)buffer_size) - pha) + ((frq - frq_1) * 0.5 * (double)buffer_size)) / TWOPI) + 0.5); 26 | return((int)((((pha_1 + (frq_1 * (double)buffer_size) - pha) + ((frq - frq_1) * 0.5 * (double)buffer_size)) / TWOPI) + 0.5)); 27 | } 28 | 29 | 30 | double compute_aux(double pha_1, double pha, double frq_1, int buffer_size, int M) 31 | { 32 | // double val = (double)((pha + (TWOPI * (double)M)) - (pha_1 + (frq_1 * (double)buffer_size))); 33 | return((double)((pha + (TWOPI * (double)M)) - (pha_1 + (frq_1 * (double)buffer_size)))); 34 | } 35 | 36 | double compute_alpha(double aux, double frq_1, double frq, int buffer_size) 37 | { 38 | // double val = (double)(((3.0 / (double)(buffer_size * buffer_size)) * aux ) - ((frq - frq_1) / (double)buffer_size)); 39 | return((double)(((3.0 / (double)(buffer_size * buffer_size)) * aux ) - ((frq - frq_1) / (double)buffer_size))); 40 | } 41 | 42 | double compute_beta(double aux, double frq_1, double frq, int buffer_size) 43 | { 44 | // double val = (double)(((-2.0 / (double)(buffer_size * buffer_size * buffer_size)) * aux) + ((frq - frq_1) / (double)(buffer_size * buffer_size))); 45 | return((double)(((-2.0 / (double)(buffer_size * buffer_size * buffer_size)) * aux) + ((frq - frq_1) / (double)(buffer_size * buffer_size)))); 46 | } 47 | 48 | double interp_phase(double pha_1, double frq_1, double alpha, double beta, int i) 49 | { 50 | // double val = (double)((beta * (double)(i * i * i)) + (alpha * (double)(i * i)) + (frq_1 * (double)i) + pha_1); 51 | return((double)((beta * (double)(i * i * i)) + (alpha * (double)(i * i)) + (frq_1 * (double)i) + pha_1)); 52 | } 53 | 54 | 55 | /* read_frame 56 | * ========== 57 | * reads a frame from the input file 58 | * fil: pointer to an array with sound data 59 | * fil_len: length of datas in samples 60 | * samp_1: first sample number in frame 61 | * samp_2: last sample number in frame 62 | * in_buffer: pointer to input buffer 63 | * which is filled out by the function 64 | * NOTE: caller should allocate memory for buffer 65 | */ 66 | void read_frame(mus_sample_t **fil, int fil_len, int samp_1, int samp_2, double *in_buffer) 67 | { 68 | int i, index, samps = samp_2 - samp_1; 69 | mus_sample_t tmp; 70 | // samps = samp_2 - samp_1; 71 | for(i=0; i array contains the sample numbers in the input file corresponding to each frame 118 | * fil: pointer to analyzed data 119 | * fil_len: length of data in samples 120 | * output_file: output file path 121 | * sound: pointer to ATS_SOUND 122 | * win_samps: pointer to array of analysis windows center times 123 | * file_sampling_rate: sampling rate of analysis file 124 | */ 125 | void compute_residual(mus_sample_t **fil, int fil_len, char *output_file, ATS_SOUND *sound, int *win_samps, int file_sampling_rate) 126 | { 127 | int i, frm, frm_1, frm_2, par, frames, partials, frm_samps, out_smp=0, ptout; 128 | double *in_buff, *synth_buff, mag, a1, a2, f1, f2, p1, p2, diff, synth; 129 | mus_sample_t **obuf; 130 | 131 | frames = sound->frames; 132 | partials = sound->partials; 133 | frm_samps = sound->frame_size; 134 | mag = TWOPI / (double)file_sampling_rate; 135 | in_buff = (double *)malloc(frm_samps * sizeof(double)); 136 | synth_buff = (double *)malloc(frm_samps * sizeof(double)); 137 | /* open output file */ 138 | if((ptout=mus_sound_open_output(output_file,file_sampling_rate,2,MUS_LSHORT,MUS_RIFF,"created by ATSA"))==-1) { 139 | fprintf(stderr, "\nERROR: can't open file %s for writing\n", output_file); 140 | exit(1); 141 | } 142 | /* allocate memory */ 143 | obuf = (mus_sample_t **)malloc(2*sizeof(mus_sample_t *)); 144 | obuf[0] = (mus_sample_t *)calloc(frm_samps, sizeof(mus_sample_t)); 145 | obuf[1] = (mus_sample_t *)calloc(frm_samps, sizeof(mus_sample_t)); 146 | /* compute residual frame by frame */ 147 | for(frm=1; frmamp[par][frm_1]; 157 | a2 = sound->amp[par][frm_2]; 158 | /* have to convert the frequency into radians per sample!!! */ 159 | f1 = sound->frq[par][frm_1] * mag; 160 | f2 = sound->frq[par][frm_2] * mag; 161 | // f1 *= mag; 162 | // f2 *= mag; 163 | p1 = sound->pha[par][frm_1]; 164 | p2 = sound->pha[par][frm_2]; 165 | if( !( a1 <= 0.0 && a2 <= 0.0 ) ) { 166 | /* check amp 0 in frame 1 */ 167 | if(a1 <= 0.0) { 168 | f1 = f2; 169 | p1 = p2 - ( f2 * frm_samps ); 170 | while(p1 > PI) p1 -= TWOPI; 171 | while(p1 < (PI * -1)) p1 += TWOPI; 172 | } 173 | /* check amp 0 in frame 2 */ 174 | if(a2 <= 0.0) { 175 | f2 = f1; 176 | p2 = p1 + ( f1 * frm_samps ); 177 | while(p2 > PI) p2 -= TWOPI; 178 | while(p2 < (PI * -1)) p2 += TWOPI; 179 | } 180 | synth_buffer(a1, a2, f1, f2, p1, p2, synth_buff, frm_samps); 181 | } 182 | } 183 | /* write output: chan 0 residual chan 1 synthesis */ 184 | for(i=0; iactive) { 15 | sparams->allorsel=TRUE; 16 | if(SOMETHING_SELECTED) { 17 | sparams->beg=ats_sound->time[0][selection->from]; 18 | sparams->end=ats_sound->time[0][selection->to]+ ats_sound->time[0][1]; 19 | } 20 | } else { 21 | sparams->allorsel=FALSE; 22 | if(SOMETHING_SELECTED) { 23 | sparams->beg=0.; 24 | sparams->end=ats_sound->time[0][(int)atshed->fra - 1] + ats_sound->time[0][1]; 25 | } 26 | } 27 | } 28 | 29 | void set_params(void) 30 | { 31 | gchar *str; 32 | 33 | str=gtk_editable_get_chars(GTK_EDITABLE(sine_entry),0,9); 34 | sparams->amp=(float)atof((char*)str); 35 | g_free(str); 36 | 37 | if(FILE_HAS_NOISE) { 38 | str=gtk_editable_get_chars(GTK_EDITABLE(noise_entry),0,9); 39 | sparams->ramp=(float)atof((char*)str); 40 | g_free(str); 41 | } 42 | 43 | str=gtk_editable_get_chars(GTK_EDITABLE(freq_entry),0,9); 44 | sparams->frec=(float)atof((char*)str); 45 | g_free(str); 46 | 47 | str=gtk_editable_get_chars(GTK_EDITABLE(sr_entry),0,9); 48 | sparams->sr=(float)atof((char*)str); 49 | g_free(str); 50 | 51 | str=gtk_editable_get_chars(GTK_EDITABLE(file_entry),0,-1); 52 | strcpy(out_tittle, str); 53 | g_free(str); 54 | 55 | /* Phase information is not used for synthesis at present */ 56 | sparams->upha=FALSE; 57 | } 58 | 59 | //void delete_event (GtkWidget *widget, gpointer data) 60 | //{ 61 | // set_params();//retrieve parameters from entry fields 62 | // // do_synthesis(); 63 | //} 64 | 65 | void ok_button(GtkWidget *widget, gpointer data) 66 | { 67 | set_params(); /* retrieve parameters from entry fields */ 68 | gtk_widget_destroy(GTK_WIDGET(data)); 69 | do_synthesis(); 70 | } 71 | 72 | void cancel_dialog(GtkWidget *widget, gpointer data) 73 | { 74 | gtk_widget_destroy(GTK_WIDGET(data)); 75 | } 76 | 77 | void get_sparams(void) 78 | { 79 | GtkWidget *window, *hbox, *label, *voidbox, *button; 80 | char str[50]; 81 | 82 | if(floaded) { 83 | /* Create the top level window */ 84 | window = gtk_dialog_new(); 85 | gtk_window_set_title(GTK_WINDOW(window), "Synthesis"); 86 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 87 | gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE); 88 | gtk_container_set_border_width(GTK_CONTAINER(window), 20); 89 | 90 | /* create the various text entry boxes */ 91 | hbox = gtk_hbox_new(FALSE, 0); 92 | label = gtk_label_new("Sinusoidal output gain"); 93 | gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, FALSE,10); 94 | gtk_widget_show(label); 95 | sine_entry = gtk_entry_new(); 96 | gtk_entry_set_max_length(GTK_ENTRY(sine_entry), 10); 97 | gtk_widget_set_usize(GTK_WIDGET(sine_entry),60,20); 98 | sprintf(str, "%2.3f", sparams->amp); 99 | gtk_entry_set_text(GTK_ENTRY(sine_entry), str); 100 | gtk_box_pack_start(GTK_BOX(hbox), sine_entry, FALSE, FALSE, 0); 101 | gtk_widget_show(sine_entry); 102 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, FALSE, FALSE, 0); 103 | gtk_widget_show(hbox); 104 | 105 | hbox = gtk_hbox_new(FALSE, 0); 106 | label = gtk_label_new("Noise output gain"); 107 | gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, FALSE,10); 108 | gtk_widget_show(label); 109 | noise_entry = gtk_entry_new(); 110 | gtk_entry_set_max_length(GTK_ENTRY(noise_entry), 10); 111 | gtk_widget_set_usize(GTK_WIDGET(noise_entry),60,20); 112 | sprintf(str, "%2.3f", sparams->ramp); 113 | gtk_entry_set_text(GTK_ENTRY(noise_entry), str); 114 | gtk_box_pack_start(GTK_BOX(hbox), noise_entry, FALSE, FALSE, 0); 115 | gtk_editable_set_editable(GTK_EDITABLE(noise_entry), FILE_HAS_NOISE); 116 | gtk_widget_show(noise_entry); 117 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, FALSE, FALSE, 0); 118 | gtk_widget_show(hbox); 119 | 120 | hbox = gtk_hbox_new(FALSE, 0); 121 | label = gtk_label_new("Frequency Scalar"); 122 | gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, FALSE,10); 123 | gtk_widget_show(label); 124 | freq_entry = gtk_entry_new(); 125 | gtk_entry_set_max_length(GTK_ENTRY(freq_entry), 10); 126 | gtk_widget_set_usize(GTK_WIDGET(freq_entry),60,20); 127 | sprintf(str, "%2.3f", sparams->frec); 128 | gtk_entry_set_text(GTK_ENTRY(freq_entry), str); 129 | gtk_box_pack_start(GTK_BOX(hbox), freq_entry, FALSE, FALSE, 0); 130 | gtk_widget_show(freq_entry); 131 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, FALSE, FALSE, 0); 132 | gtk_widget_show(hbox); 133 | 134 | hbox = gtk_hbox_new(FALSE, 0); 135 | label = gtk_label_new("Sampling Rate"); 136 | gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, FALSE,10); 137 | gtk_widget_show(label); 138 | sr_entry = gtk_entry_new(); 139 | gtk_entry_set_max_length(GTK_ENTRY(sr_entry), 10); 140 | gtk_widget_set_usize(GTK_WIDGET(sr_entry),60,20); 141 | sprintf(str, "%d", (int)sparams->sr); 142 | gtk_entry_set_text(GTK_ENTRY(sr_entry), str); 143 | gtk_box_pack_start(GTK_BOX(hbox), sr_entry, FALSE, FALSE, 0); 144 | gtk_widget_show(sr_entry); 145 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), hbox, FALSE, FALSE, 0); 146 | gtk_widget_show(hbox); 147 | 148 | /* create a void box as separator */ 149 | voidbox = gtk_hbox_new(FALSE, 0); 150 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), voidbox, FALSE, FALSE, 3); 151 | gtk_widget_show(voidbox); 152 | 153 | // /* Create the toggle button for Partials */ 154 | // tlabel1 = gtk_label_new ("Selected Partials Only"); 155 | // button= gtk_toggle_button_new(); 156 | // gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(button),sparams->allorsel); 157 | // gtk_signal_connect (GTK_OBJECT (button), "toggled", 158 | // GTK_SIGNAL_FUNC (allorsel),NULL); 159 | // gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), button, FALSE, FALSE, 2); 160 | // gtk_container_add (GTK_CONTAINER (button), tlabel1); 161 | // gtk_widget_show (tlabel1); 162 | // gtk_widget_show (button); 163 | // allorsel(GTK_WIDGET(button), NULL); 164 | 165 | /* Create the check button for Partials */ 166 | button = gtk_check_button_new_with_label("Selected Partials Only"); 167 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), sparams->allorsel); 168 | gtk_signal_connect(GTK_OBJECT(button), "toggled", GTK_SIGNAL_FUNC(allorsel), NULL); 169 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), button, FALSE, FALSE, 2); 170 | gtk_widget_show (button); 171 | // allorsel(GTK_WIDGET(button), NULL); 172 | 173 | /* Create the "set time pointer" button */ 174 | button = gtk_button_new_with_label("Set Time Pointer"); 175 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), button, FALSE, FALSE, 2); 176 | gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(edit_tim), NULL); 177 | gtk_widget_show(button); 178 | 179 | /* Create the set output file button */ 180 | button = gtk_button_new_with_label ("Set Output File"); 181 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), button, FALSE, FALSE, 2); 182 | gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(filesel), "outsel"); 183 | gtk_widget_show(button); 184 | 185 | file_entry = gtk_entry_new(); 186 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), file_entry, FALSE, FALSE, 2); 187 | gtk_entry_set_text(GTK_ENTRY(file_entry), out_tittle); 188 | gtk_widget_show (file_entry); 189 | 190 | /* create a void box as separator */ 191 | voidbox = gtk_hbox_new(FALSE, 0); 192 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), voidbox, FALSE, FALSE, 5); 193 | gtk_widget_show(voidbox); 194 | 195 | /* Create standard OK/CANCEL buttons */ 196 | button = gtk_button_new_with_label("Do it"); 197 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area), button, TRUE, TRUE, 5); 198 | gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_button), window); 199 | gtk_widget_show(button); 200 | 201 | button = gtk_button_new_with_label ("Forget it"); 202 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area), button, TRUE, TRUE, 0); 203 | gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_dialog), window); 204 | gtk_widget_show(button); 205 | 206 | /* Make the main window visible */ 207 | gtk_widget_show(window); 208 | } 209 | } 210 | 211 | -------------------------------------------------------------------------------- /ats-csound/docs/atssynth.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | atsadd, atsaddnz & atssinnoi 4 | 5 | 6 | Signal Generators: STFT Resynthesis (Vocoding) 7 | 8 |
9 | 10 |

atsadd, atsaddnz, atssinnoi

11 | 12 | 13 |
 ar      atsadd      ktimepnt, kfmod, iatsfile, ifn, ipartials[, ipartialoffset, ipartialincr, igatefn]
14 |
 ar      atsaddnz    ktimepnt, iatsfile, ifn, ibands[, ibandoffset, ibandincr]
15 |
 ar      atssinnoi   ktimepnt, ksinlev, knzlev, kfmod, iatsfile, ipartials[, ipartialoffset, ipartialincr]
16 | 17 |
18 |

Description

19 |

atsadd and atsaddnz are based on pvadd by 20 | Richard Karpen and use files created by Juan Pampin's ATS (Analysis - 22 | Transformation - Synthesis). atssinnoi is based on ATS's 23 | sinnoi synth. atsadd reads from an ATS 25 | analysis file and uses the data to perform additive synthesis using an internal 26 | array of interpolating oscillators. The user supplies the wave table (usually 27 | one period of a sine wave), and can choose which analysis partials will be used 28 | in the re-synthesis. atsaddnz also reads from an ATS 30 | file but it resynthesizes the noise from noise energy data contained in the ATS 31 | file. It uses a modified randi function to create band limited noise and 32 | modulates that with a user supplied wave table (one period of a cosine wave), 33 | to synthesize a user specified selection of frequency bands. Modulating the 34 | noise is required to put the band limited noise in the correct place in the 35 | frequency spectrum. atssinnoi reads data from an ATS data 36 | file and uses the information to synthesize sines and noise together. The 37 | noise energy for each band is distributed equally among each partial that falls 38 | in that band. Each partial is then synthesized, along with that partial's 39 | noise component. Each noise component is then modulated by the corresponding 40 | partial to be put in the correct place in the frequency spectrum. The level of 41 | the noise and the partials are individually controllable. See the ATS webpage for more 43 | info about the sinnoi synthesis. An ATS 45 | analysis differs from a pvanal in that ATS tracks the partials and computes the 46 | noise energy of the sound being analyzed. For more info about ATS analysis 47 | read Juan Pampin's description on the the ATS 49 | web-page.

50 | 51 |

Initialization

52 | 53 |

ktimepnt – a time pointer for reading through the ats 54 | file

55 | 56 |

kfmod – an input for performing pitch transposition or 57 | frequency modulation on all of the synthesized partials, if no fm or pitch 58 | change is desired then use a 1 for this value

59 | 60 |

iatsfile – integer or character-string denoting a 61 | control-file derived from ATS analysis of an audio signal. An integer denotes 62 | the suffix of a file ats.m; a character-string (in double quotes) 63 | gives a filename, optionally a full pathname. If not full-path, the file is 64 | sought first in the current directory, then in the one given by the environment 65 | variable SADIR (if defined).

66 | 67 |

ifn – table number of a stored function containing a sine 68 | wave for atsadd and a cosine for atsaddnz (see examples below for more 69 | info)

70 | 71 |

ipartials / ibands – number of partials or noise bands that 72 | will be used in the resynthesis (the noise has a maximum of 25 bands)

73 | 74 |

ipartialoffset / ibandoffset (optional) – is the first 75 | partial or noise band used (defaults to 0).

76 | 77 |

ipartialincr / ibandincr (optional) – sets an increment by 78 | which these synthesis opcodes counts up from 79 | ipartialoffset/ibandoffset for ibins components in the 80 | re-synthesis (defaults to 1).

81 | 82 |

ksinlev controls the level of the sines in the 83 | atssinnoi ugen. A value of 1 gives full volume sinewaves.

84 | 85 |

knzlev controls the level of the noise components in the 86 | atssinnoi ugen. A value of 1 gives full volume noise.

87 | 88 |

igatefn (optional) – is the number of a stored function which 89 | will be applied to the amplitudes of the analysis bins before resynthesis takes 90 | place. If igatefn is greater than 0 the amplitudes of each bin will be 91 | scaled by igatefn through a simple mapping process. First, the 92 | amplitudes of all of the bins in all of the frames in the entire analysis file 93 | are compared to determine the maximum amplitude value. This value is then used 94 | create normalized amplitudes as indices into the stored function 95 | igatefn. The maximum amplitude will map to the last point in the 96 | function. An amplitude of 0 will map to the first point in the function. Values 97 | between 0 and 1 will map accordingly to points along the function table. This 98 | will be made clearer in the examples below.

99 | 100 |

Performance

101 |

ktimpnt and kfmod are used in the same way as in 102 | pvoc.

103 | 104 |

Examples

105 | 1. 106 |
  ktime line  0, p3, 2.5
107 |   asig  atsadd ktime, 1, "clarinet.ats", 1, 20, 2
108 |

In the example above, ipartials is 20 and ipartialoffset 109 | is 2. This will synthesize the 3rd thru 22nd partials in the "clarinet.ats" 110 | analysis file. kmod is 1 so there will be no pitch transformation. Since the 111 | ktimepnt envelope moves from 0 to 2.5 over the duration of the note, 112 | the analysis file will be read from 0 to 2.5 seconds of the original duration 113 | of the analysis over the duration of the csound note, this way we can change 114 | the duration independent of the pitch. 115 | 116 |

117 | 118 | 2. 119 |
  ktime line  0, p3, 2.5
120 |   asig  atsaddnz ktime, "clarinet.ats", 2, 25
121 |

In the example above we're synthesizing all 25 noise bands from the data 122 | contained in the ATS analysis file called "clarinet.ats", we're using function 123 | table 2, which should be a cosine ie:

124 | 125 |
  f2 0 4096 9 1 1 90
126 | 127 | 3. 128 |
  ktime line  0, p3, 2.5
129 |   asig  atsadd ktime, 1.0125, "clarinet.ats", 1, 20, 0, 2
130 |

In the above example we synthesize 20 partials as in example 1 except this 131 | time we're using a ipartialoffset of 0 and ipartialincr of 2, 132 | which means that we'll start from the first partial and synthesize 20 partials 133 | total, skipping every other one (ie. partial 1, 3, 5,...). We've also 134 | increased the pitch of the result (kfmod is set to 1.0125).

135 | 136 | 4. 137 |
  ktime line  2.5, p3, 0
138 |   asig atsaddnz ktime, 1, "clarinet.ats", 2, 1, 24
139 | 140 |

Here we synthesize only the 25th noise band (ibandoffset of 24 and 141 | ibands of 1). Also our time pointer is going from 2.5 to 0 over the 142 | duration of the note so we're reading backwards from 2.5 seconds in the 143 | analysis file.

144 | 145 | 5. 146 |
  ktime line  0, p3, 2.5
147 |   asig atssinnoi ktime, 1, 1, 1, "clarinet.ats", 42
148 | 149 |

Here we synthesize both the noise and the sinewaves (all 42 partials) 150 | contained in "clarinet.ats" together. The relative volumes of the noise and 151 | the partials are unaltered (each set to 1).

152 | 153 | 6. 154 |
  ktime line  0, p3, 2.5
155 |   knzfade expon  0.001, p3, 2.5
156 |   asig atssinnoi ktime, 1, knzfade, 1, "clarinet.ats", 42
157 | 158 |

This example here is like example 5 except that we use an envelope 159 | to control knzlev (the noise level). The result of this will be a 160 | clarinet sound that has its noise component fade in over the duration of the 161 | note.

162 | 163 |

Author

164 |

Alex Norman (an edited version of Richard Karpen's pvadd documentation)
165 | Seattle, Wash
166 | 2004
167 | 168 | -------------------------------------------------------------------------------- /ats/src/atsa/residual-analysis.c: -------------------------------------------------------------------------------- 1 | /* residual-analysis.c 2 | * atsa: ATS analysis implementation 3 | * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin 4 | */ 5 | 6 | #include "atsa.h" 7 | 8 | #define ATSA_RES_MIN_FFT_SIZE 4096 9 | #define ATSA_RES_PAD_FACTOR 2 10 | #define MAG_SQUARED(re, im, norm) (norm * (re*re+im*im)) 11 | 12 | /* private function prototypes */ 13 | int residual_get_N(int M, int min_fft_size, int factor); 14 | void residual_get_bands(double fft_mag, double *true_bands, int *limits, int bands); 15 | double residual_compute_time_domain_energy(ATS_FFT *fft_struct); 16 | double residual_get_band_energy(int lo, int hi, ATS_FFT *fft_struct, double norm); 17 | void residual_compute_band_energy(ATS_FFT *fft_struct, int *band_limits, int bands, double *band_energy, double norm); 18 | 19 | int residual_get_N(int M, int min_fft_size, int factor) 20 | { 21 | int def_size = factor * M; 22 | while(def_size < min_fft_size) def_size = ppp2(def_size+1); 23 | return(def_size); 24 | } 25 | 26 | void residual_get_bands(double fft_mag, double *true_bands, int *limits, int bands) 27 | { 28 | int k; 29 | for(k=0; k N/2) 44 | */ 45 | int n; 46 | double sum=0.0; 47 | #ifdef FFTW 48 | for(n=0; nsize; n++) sum += fabs(fft->data[n][0] * fft->data[n][0]); 49 | #else 50 | for(n=0; nsize; n++) sum += fabs(fft->fdr[n] * fft->fdr[n]); 51 | #endif 52 | return(sum); 53 | } 54 | 55 | double residual_get_band_energy(int lo, int hi, ATS_FFT *fft, double norm) 56 | { 57 | /* does 1/N * sum(re^2+im^2) within a band around

58 | from lower bin to upper bin in */ 59 | int k; 60 | double sum = 0.0; 61 | if(lo<0) lo = 0; 62 | if(hi> floor(fft->size * 0.5)) hi = floor(fft->size * 0.5); 63 | for(k = lo ; k < hi ; k++) 64 | #ifdef FFTW 65 | sum += MAG_SQUARED( fft->data[k][0], fft->data[k][1], norm); 66 | #else 67 | sum += MAG_SQUARED( fft->fdr[k], fft->fdi[k], norm); 68 | #endif 69 | return( sum/(double)fft->size ); 70 | } 71 | 72 | void residual_compute_band_energy(ATS_FFT *fft, int *band_limits, int bands, double *band_energy, double norm) 73 | { 74 | /* loop trough bands and evaluate energy 75 | we compute energy of one band as: 76 | (N-1)/2 77 | 1/N * sum(|X(k)|^2) 78 | k=0 79 | N=fft size, K=bins in band */ 80 | int b; 81 | for(b=0; bframe_size; 111 | M = sound->window_size; 112 | N = residual_get_N(M, ATSA_RES_MIN_FFT_SIZE, ATSA_RES_PAD_FACTOR); 113 | bufs = (mus_sample_t **)malloc(2*sizeof(mus_sample_t*)); 114 | bufs[0] = (mus_sample_t *)malloc(sflen * sizeof(mus_sample_t)); 115 | bufs[1] = (mus_sample_t *)malloc(sflen * sizeof(mus_sample_t)); 116 | fft.size = N; 117 | fft.rate = file_sampling_rate; 118 | #ifdef FFTW 119 | fft.data = fftw_malloc(sizeof(fftw_complex) * fft.size); 120 | //fftw_wisdom_file = fopen("fftw-wisdom", "r"); 121 | // fftw_import_wisdom_from_file(fftw_wisdom_file); 122 | plan = fftw_plan_dft_1d(fft.size, fft.data, fft.data, FFTW_FORWARD, FFTW_PATIENT); 123 | // fclose(fftw_wisdom_file); 124 | #else 125 | fft.fdr = (double *)malloc(N * sizeof(double)); 126 | fft.fdi = (double *)malloc(N * sizeof(double)); 127 | #endif 128 | threshold = AMP_DB(ATSA_NOISE_THRESHOLD); 129 | frames = sound->frames; 130 | fft_mag = (double)file_sampling_rate / (double)N; 131 | band_limits = (int *)malloc(sizeof(int)*(ATSA_CRITICAL_BANDS+1)); 132 | residual_get_bands(fft_mag, edges, band_limits, ATSA_CRITICAL_BANDS+1); 133 | band_arr = sound->band_energy; 134 | band_energy = (double *)malloc(ATSA_CRITICAL_BANDS*sizeof(double)); 135 | 136 | M_2 = floor( ((double)M - 1) * 0.5 ); 137 | st_pt = N - M_2; 138 | filptr = M_2 * -1; 139 | /* read sound into memory */ 140 | mus_sound_read(fil, 0, sflen-1, 2, bufs); 141 | 142 | for(frame_n = 0 ; frame_n < frames ; frame_n++){ 143 | for(i=0; i= 0 && filptr < sflen) 152 | #ifdef FFTW 153 | fft.data[(k+st_pt)%N][0] = MUS_SAMPLE_TO_FLOAT(bufs[0][filptr]); 154 | #else 155 | fft.fdr[(k+st_pt)%N] = MUS_SAMPLE_TO_FLOAT(bufs[0][filptr]); 156 | #endif 157 | filptr++; 158 | } 159 | smp = filptr - M_2 - 1; 160 | time_domain_energy = residual_compute_time_domain_energy(&fft); 161 | /* take the fft */ 162 | #ifdef FFTW 163 | fftw_execute(plan); 164 | #else 165 | fft_slow(fft.fdr, fft.fdi, fft.size, 1); 166 | #endif 167 | residual_compute_band_energy(&fft, band_limits, ATSA_CRITICAL_BANDS+1, band_energy, norm); 168 | sum = 0.0; 169 | for(k = 0; k < ATSA_CRITICAL_BANDS; k++){ 170 | sum += band_energy[k]; 171 | } 172 | freq_domain_energy = 2.0 * sum; 173 | for(k = 0; k < ATSA_CRITICAL_BANDS; k++){ 174 | if( band_energy[k] < threshold) { 175 | band_arr[k][frame_n] = 0.0; 176 | } else { 177 | band_arr[k][frame_n] = band_energy[k]; 178 | } 179 | } 180 | filptr = filptr - M + hop; 181 | } 182 | /* save data in sound */ 183 | sound->band_energy = band_arr; 184 | #ifdef FFTW 185 | fftw_destroy_plan(plan); 186 | fftw_free(fft.data); 187 | #else 188 | free(fft.fdr); 189 | free(fft.fdi); 190 | #endif 191 | free(band_energy); 192 | free(band_limits); 193 | free(bufs[0]); 194 | free(bufs[1]); 195 | free(bufs); 196 | } 197 | 198 | /* band_energy_to_res 199 | * ================== 200 | * transfers residual engergy from bands to partials 201 | * sound: sound structure containing data 202 | * frame: frame number 203 | */ 204 | void band_energy_to_res(ATS_SOUND *sound, int frame) 205 | { 206 | int i, j; 207 | double edges[] = ATSA_CRITICAL_BAND_EDGES; 208 | double bandsum[ATSA_CRITICAL_BANDS]; 209 | double partialfreq, partialamp; 210 | double * partialbandamp; /* amplitude of the band that the partial is in */ 211 | int * bandnum; /* the band number that the partial is in */ 212 | 213 | partialbandamp = malloc(sizeof(double) * sound->partials); 214 | bandnum = malloc(sizeof(int) * sound->partials); 215 | if(partialbandamp == NULL || bandnum == NULL) { 216 | fprintf(stderr, "\n%s: malloc() returned NULL\n", __PRETTY_FUNCTION__); 217 | return; 218 | } 219 | /* initialize the sum per band */ 220 | for(i=0; ipartials; i++) { 224 | partialfreq = sound->frq[i][frame]; 225 | partialamp = sound->amp[i][frame]; 226 | for(j = 0; j < 25; j++) { 227 | if( (partialfreq < edges[j+1]) && (partialfreq >= edges[j]) ) { 228 | bandsum[j] += partialamp; 229 | bandnum[i] = j; 230 | partialbandamp[i] = sound->band_energy[j][frame]; 231 | break; 232 | } 233 | } 234 | } 235 | /* compute energy per partial */ 236 | for(i=0; ipartials; i++) { 237 | if(bandsum[bandnum[i]] > 0.0) 238 | sound->res[i][frame] = sound->amp[i][frame] * partialbandamp[i] / bandsum[bandnum[i]]; 239 | else 240 | sound->res[i][frame] = 0.0; 241 | } 242 | free(partialbandamp); 243 | free(bandnum); 244 | } 245 | 246 | /* res_to_band_energy 247 | * ================== 248 | * transfers residual engergy from partials to bands 249 | * sound: sound structure containing data 250 | * frame: frame number 251 | */ 252 | void res_to_band_energy(ATS_SOUND *sound, int frame) 253 | { 254 | int j, par; 255 | double sum; 256 | double edges[ATSA_CRITICAL_BANDS+1] = ATSA_CRITICAL_BAND_EDGES; 257 | par = 0; 258 | for(j=0 ; jfrq[par][frame] >= edges[j] && sound->frq[par][frame] < edges[j+1]) { 261 | sum += sound->res[par][frame]; 262 | par++; 263 | } 264 | sound->band_energy[j][frame] = sum; 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /ats/src/atsh/sel.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ATSH-SEL.C 4 | Oscar Pablo Di Liscia / Juan Pampin 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "atsh.h" 13 | 14 | extern GtkWidget *main_graph; 15 | extern VIEW_PAR h, v; 16 | extern int floaded; 17 | extern SELECTION selection, position; 18 | extern ATS_SOUND *ats_sound; 19 | extern ATS_HEADER atshed; 20 | 21 | GtkWidget *create_label_sel(char *winfo, int p1,int p2,int p3,int p4, GtkWidget *table) 22 | { 23 | GtkWidget *label = gtk_label_new (winfo); 24 | // gtk_label_set_line_wrap(GTK_LABEL (label),TRUE); 25 | gtk_table_attach (GTK_TABLE (table), label, p1, p2, p3, p4, 0, GTK_EXPAND, 0, 0); 26 | gtk_widget_show (label); 27 | return(label); 28 | } 29 | /////////////////////////////////////////////////////// 30 | void set_met(GtkWidget *widget, gpointer data) 31 | { 32 | if (GTK_TOGGLE_BUTTON (widget)->active) { 33 | /*If control reaches here, the toggle button is down */ 34 | sdata->met=TRUE; 35 | gtk_label_set_text(GTK_LABEL(data),"RMS Power"); 36 | } else { 37 | /* If control reaches here, the toggle button is up */ 38 | sdata->met=FALSE; 39 | gtk_label_set_text(GTK_LABEL(data)," Peak "); 40 | } 41 | } 42 | /////////////////////////////////////////////////////// 43 | void get_values(GtkWidget *widget, gpointer data) 44 | { 45 | // int whichparam=GPOINTER_TO_INT(data); 46 | 47 | switch(GPOINTER_TO_INT(data)) { 48 | case 1: 49 | sdata->from=(int)GTK_ADJUSTMENT(widget)->value; 50 | break; 51 | case 2: 52 | sdata->to=(int)GTK_ADJUSTMENT(widget)->value; 53 | break; 54 | case 3: 55 | sdata->step=(int)GTK_ADJUSTMENT(widget)->value; 56 | break; 57 | case 4: 58 | sdata->tres=(float)GTK_ADJUSTMENT(widget)->value; 59 | break; 60 | } 61 | } 62 | 63 | /////////////////////////////////////////////////////// 64 | void do_smartsel (GtkWidget *widget, gpointer data) 65 | { 66 | int i; 67 | float linamp= (float)pow(10., (double)(sdata->tres/20.)); 68 | float amp, ampsum=0., rmspow, max_peak=0.; 69 | int x, temp; 70 | 71 | if(sdata->from > sdata->to) { 72 | SWAP_INT(sdata->from,sdata->to) 73 | } 74 | 75 | set_selection(h.viewstart, h.viewend,0,main_graph->allocation.width, 76 | main_graph->allocation.width); 77 | vertex1=0; vertex2=1; //something IS selected 78 | //set_avec(selection.to - selection.from); 79 | 80 | for(i=0; i<(int)atshed.par; i++) selected[i]=FALSE; //unselect all 81 | 82 | for(i=sdata->from; i < sdata->to+1; i+=sdata->step) { 83 | 84 | if(i >(int)atshed.par-1 || i >(int)sdata->to) break; 85 | 86 | for(x=h.viewstart; x < h.viewend; x++) { //amplitude evaluation 87 | amp =ats_sound->amp[i][x]; 88 | switch(sdata->met) { 89 | case 0: //peak 90 | if(amp > max_peak) max_peak=amp; 91 | break; 92 | case 1: //RMS POW 93 | ampsum+= amp*amp; 94 | break; 95 | } 96 | } 97 | 98 | switch(sdata->met) { 99 | case 0: //peak 100 | if(max_peak >= linamp) selected[i]=TRUE; 101 | break; 102 | case 1: //RMS POW 103 | rmspow= (float)sqrt((double)ampsum / (double)h.diff ); 104 | if(rmspow >= linamp) selected[i]=TRUE; 105 | break; 106 | } 107 | 108 | ampsum=max_peak=0.; 109 | } 110 | 111 | draw_pixm(); 112 | gtk_widget_destroy (GTK_WIDGET (data)); 113 | } 114 | /////////////////////////////////////////////////////// 115 | void destroy_smartsel (GtkWidget *widget, gpointer data) 116 | { 117 | gtk_widget_destroy (GTK_WIDGET (data)); 118 | } 119 | 120 | ////////////////////////////////////////////////////// 121 | GtkObject *create_adj(GtkWidget *window, GtkWidget *table, float min, float max, float value, 122 | int p1, int p2, int p3, int p4, char *ID) 123 | { 124 | GtkObject *adj; 125 | GtkWidget *spin; 126 | char *str; 127 | int flag; 128 | 129 | str=(char*)malloc(32*sizeof(char)); 130 | *str=0; 131 | strcat(str, "spin"); 132 | strcat(str, ID); 133 | flag=atoi(ID); 134 | 135 | adj = gtk_adjustment_new(value, min, max, 1. ,10., 10.); 136 | spin = gtk_spin_button_new(GTK_ADJUSTMENT (adj), 1, 0); 137 | 138 | gtk_widget_ref (spin); 139 | g_object_set_data_full (G_OBJECT (window), "spin", spin, 140 | (GDestroyNotify) gtk_widget_unref); 141 | gtk_widget_show (spin); 142 | gtk_table_attach (GTK_TABLE (table), spin, p1, p2, p3, p4, 143 | (GtkAttachOptions) (0), 144 | (GtkAttachOptions) (0), 0, 0); 145 | gtk_widget_set_size_request (spin, 75, 22); 146 | gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin), TRUE); 147 | 148 | g_signal_connect (G_OBJECT (adj) ,"value_changed", G_CALLBACK(get_values),GINT_TO_POINTER(flag)); 149 | 150 | free(str); 151 | return(adj); 152 | 153 | } 154 | ////////////////////////////////////////////////////// 155 | 156 | void create_sel_dlg (void) 157 | { 158 | GtkWidget *window1, *table1, *lfrom, *lto, *lstep, *ltres, *lmet; 159 | GtkWidget *OK, *cancel, *metb, *hseparator2, *hseparator1, *tlabel; 160 | GtkObject *step_adj, *to_adj, *from_adj, *tres_adj; 161 | 162 | if(floaded) { 163 | window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); 164 | g_object_set_data (G_OBJECT (window1), "window1", window1); 165 | gtk_container_set_border_width (GTK_CONTAINER (window1), 10); 166 | gtk_window_set_title (GTK_WINDOW (window1),("Selection ")); 167 | gtk_window_set_position (GTK_WINDOW (window1), GTK_WIN_POS_CENTER); 168 | gtk_window_set_default_size (GTK_WINDOW (window1), 180, 180); 169 | gtk_window_set_resizable (GTK_WINDOW (window1), FALSE); 170 | g_signal_connect (G_OBJECT (window1), "destroy", 171 | G_CALLBACK (destroy_smartsel),window1); 172 | 173 | table1 = gtk_table_new (7, 2, FALSE); 174 | gtk_widget_ref (table1); 175 | g_object_set_data_full (G_OBJECT (window1), "table1", table1, 176 | (GDestroyNotify) gtk_widget_unref); 177 | gtk_widget_show (table1); 178 | gtk_container_add (GTK_CONTAINER (window1), table1); 179 | gtk_table_set_row_spacings (GTK_TABLE (table1), 5); 180 | 181 | /* LABELS */ 182 | lfrom=create_label_sel("From Partial #", 0,1,0,1,table1); 183 | lto =create_label_sel("To Partial #", 0,1,1,2,table1); 184 | lstep=create_label_sel("Jump by ", 0,1,2,3,table1); 185 | ltres=create_label_sel("Amp. Treshold(dB)", 0,1,3,4,table1); 186 | lmet =create_label_sel("Amp. Evaluation" , 0,1,4,5,table1); 187 | 188 | /* BUTTONS */ 189 | 190 | tlabel = gtk_label_new (""); 191 | gtk_widget_show (tlabel); 192 | 193 | metb= gtk_toggle_button_new(); 194 | gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(metb),sdata->met); 195 | g_signal_connect (G_OBJECT (metb), "toggled", 196 | G_CALLBACK (set_met),tlabel); 197 | gtk_container_add (GTK_CONTAINER (metb), tlabel); 198 | gtk_table_attach (GTK_TABLE (table1), metb, 1, 2, 4, 5, 199 | (GtkAttachOptions) (0), 200 | (GtkAttachOptions) (0), 0, 0); 201 | gtk_widget_set_size_request (metb, 72, 32); 202 | set_met(GTK_WIDGET(metb), tlabel); 203 | gtk_widget_show (metb); 204 | 205 | 206 | OK = gtk_button_new_with_label (("Do It")); 207 | gtk_widget_ref (OK); 208 | g_object_set_data_full (G_OBJECT (window1), "OK", OK, 209 | (GDestroyNotify) gtk_widget_unref); 210 | gtk_widget_show (OK); 211 | gtk_table_attach (GTK_TABLE (table1), OK, 1, 2, 6, 7, 212 | (GtkAttachOptions) (0), 213 | (GtkAttachOptions) (0), 0, 0); 214 | gtk_widget_set_size_request (OK, 72, 32); 215 | 216 | cancel = gtk_button_new_with_label (("Forget It")); 217 | gtk_widget_ref (cancel); 218 | g_object_set_data_full (G_OBJECT (window1), "cancel", cancel, 219 | (GDestroyNotify) gtk_widget_unref); 220 | gtk_widget_show (cancel); 221 | gtk_table_attach (GTK_TABLE (table1), cancel, 0, 1, 6, 7, 222 | (GtkAttachOptions) (0), 223 | (GtkAttachOptions) (0), 0, 0); 224 | gtk_widget_set_size_request (cancel, 72, 32); 225 | 226 | 227 | hseparator2 = gtk_hseparator_new (); 228 | gtk_widget_ref (hseparator2); 229 | g_object_set_data_full (G_OBJECT (window1), "hseparator2", hseparator2, 230 | (GDestroyNotify) gtk_widget_unref); 231 | gtk_widget_show (hseparator2); 232 | gtk_table_attach (GTK_TABLE (table1), hseparator2, 1, 2, 5, 6, 233 | (GtkAttachOptions) (GTK_FILL), 234 | (GtkAttachOptions) (GTK_FILL), 0, 10); 235 | 236 | hseparator1 = gtk_hseparator_new (); 237 | gtk_widget_ref (hseparator1); 238 | g_object_set_data_full (G_OBJECT (window1), "hseparator1", hseparator1, 239 | (GDestroyNotify) gtk_widget_unref); 240 | gtk_widget_show (hseparator1); 241 | gtk_table_attach (GTK_TABLE (table1), hseparator1, 0, 1, 5, 6, 242 | (GtkAttachOptions) (GTK_FILL), 243 | (GtkAttachOptions) (0), 0, 10); 244 | 245 | 246 | //////////////////////////////////////////////////////////////////// 247 | //////////////////////////////////////////////////////////////////// 248 | 249 | 250 | from_adj=create_adj(window1, table1, 1., atshed.par, sdata->from, 1,2,0,1, "1"); 251 | to_adj =create_adj(window1, table1, 1., atshed.par, sdata->to , 1,2,1,2, "2"); 252 | step_adj=create_adj(window1, table1, 1., atshed.par-1,sdata->step, 1,2,2,3, "3"); 253 | tres_adj=create_adj(window1, table1, -120., 0.,sdata->tres, 1,2,3,4, "4"); 254 | 255 | g_signal_connect (G_OBJECT (OK), "clicked",G_CALLBACK (do_smartsel),window1); 256 | g_signal_connect (G_OBJECT (cancel), "clicked",G_CALLBACK (destroy_smartsel),window1); 257 | 258 | gtk_grab_add (window1); 259 | gtk_widget_show (window1); 260 | } 261 | } 262 | 263 | -------------------------------------------------------------------------------- /ats/src/atsh/atsh-sel.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ATSH-SEL.C 4 | Oscar Pablo Di Liscia / Juan Pampin 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "atsh.h" 13 | 14 | extern GtkWidget *main_graph; 15 | extern VIEW_PAR *h, *v; 16 | 17 | /////////////////////////////////////////////////////// 18 | void set_met(GtkWidget *widget, gpointer data) 19 | { 20 | if (GTK_TOGGLE_BUTTON (widget)->active) 21 | {/*If control reaches here, the toggle button is down */ 22 | sdata->met=TRUE; 23 | gtk_label_set_text(GTK_LABEL(data),"RMS Power"); 24 | } 25 | 26 | else {/* If control reaches here, the toggle button is up */ 27 | sdata->met=FALSE; 28 | gtk_label_set_text(GTK_LABEL(data)," Peak "); 29 | } 30 | return; 31 | } 32 | /////////////////////////////////////////////////////// 33 | void get_values(GtkWidget *widget, gpointer data) 34 | { 35 | int whichparam=GPOINTER_TO_INT(data); 36 | 37 | 38 | switch(whichparam) { 39 | case 1: 40 | 41 | sdata->from=(int)GTK_ADJUSTMENT(widget)->value; 42 | break; 43 | case 2: 44 | sdata->to=(int)GTK_ADJUSTMENT(widget)->value; 45 | break; 46 | case 3: 47 | sdata->step=(int)GTK_ADJUSTMENT(widget)->value; 48 | break; 49 | case 4: 50 | sdata->tres=(float)GTK_ADJUSTMENT(widget)->value; 51 | break; 52 | } 53 | 54 | return; 55 | } 56 | 57 | /////////////////////////////////////////////////////// 58 | void do_smartsel (GtkWidget *widget, gpointer data) 59 | { 60 | int i; 61 | float linamp= (float)pow(10., (double)(sdata->tres/20.)); 62 | float amp, ampsum=0., rmspow, max_peak=0.; 63 | int x, temp; 64 | 65 | if(sdata->from > sdata->to) { 66 | SWAP_INT(sdata->from,sdata->to) 67 | } 68 | 69 | set_selection(h->viewstart, h->viewend,0,main_graph->allocation.width, 70 | main_graph->allocation.width); 71 | vertex1=0; vertex2=1; //something IS selected 72 | set_avec(); 73 | 74 | for(i=0; i<(int)atshed->par; i++) { //unselect all 75 | selected[i]=FALSE; 76 | } 77 | 78 | for(i=sdata->from; i < sdata->to+1; i+=sdata->step){ 79 | 80 | if(i >(int)atshed->par-1 || i >(int)sdata->to) break; 81 | 82 | for(x=h->viewstart; x < h->viewend; x++) { //amplitude evaluation 83 | amp =ats_sound->amp[i][x]; 84 | switch(sdata->met) { 85 | case 0: //peak 86 | if(amp > max_peak) { 87 | max_peak=amp; 88 | } 89 | break; 90 | case 1: //RMS POW 91 | ampsum+= amp*amp; 92 | break; 93 | } 94 | } 95 | 96 | switch(sdata->met) { 97 | case 0: //peak 98 | if(max_peak >= linamp) { 99 | selected[i]=TRUE; 100 | } 101 | break; 102 | case 1: //RMS POW 103 | rmspow= (float)sqrt((double)ampsum / (double)h->diff ); 104 | if(rmspow >= linamp) { 105 | selected[i]=TRUE; 106 | } 107 | break; 108 | } 109 | 110 | 111 | ampsum=max_peak=0.; 112 | 113 | } 114 | 115 | draw_pixm(); 116 | gtk_widget_destroy (GTK_WIDGET (data)); 117 | return; 118 | 119 | } 120 | /////////////////////////////////////////////////////// 121 | void destroy_smartsel (GtkWidget *widget, gpointer data) 122 | { 123 | //we do not retrieve any data 124 | 125 | gtk_widget_destroy (GTK_WIDGET (data)); 126 | return; 127 | 128 | } 129 | 130 | ////////////////////////////////////////////////////// 131 | GtkObject *create_adj(GtkWidget *window, GtkWidget *table, float min, float max, float value, 132 | int p1, int p2, int p3, int p4, char *ID) 133 | { 134 | GtkObject *adj; 135 | GtkWidget *spin; 136 | char *str; 137 | int flag; 138 | 139 | str=(char*)malloc(32*sizeof(char)); 140 | *str=0; 141 | strcat(str, "spin"); 142 | strcat(str, ID); 143 | flag=atoi(ID); 144 | 145 | adj = gtk_adjustment_new(value, min, max, 1. ,10., 10.); 146 | spin = gtk_spin_button_new(GTK_ADJUSTMENT (adj), 1, 0); 147 | 148 | gtk_widget_ref (spin); 149 | gtk_object_set_data_full (GTK_OBJECT (window), "spin", spin, 150 | (GtkDestroyNotify) gtk_widget_unref); 151 | gtk_widget_show (spin); 152 | gtk_table_attach (GTK_TABLE (table), spin, p1, p2, p3, p4, 153 | (GtkAttachOptions) (0), 154 | (GtkAttachOptions) (0), 0, 0); 155 | gtk_widget_set_usize (spin, 75, 22); 156 | gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin), TRUE); 157 | 158 | gtk_signal_connect (GTK_OBJECT (adj) ,"value_changed", GTK_SIGNAL_FUNC(get_values),GINT_TO_POINTER(flag)); 159 | 160 | free(str); 161 | return(adj); 162 | 163 | } 164 | ////////////////////////////////////////////////////// 165 | 166 | void create_sel_dlg (void) 167 | { 168 | GtkWidget *window1; 169 | GtkWidget *table1; 170 | 171 | GtkWidget *lfrom; 172 | GtkWidget *lto; 173 | GtkWidget *lstep; 174 | GtkWidget *ltres; 175 | GtkWidget *lmet; 176 | 177 | GtkWidget *OK; 178 | GtkWidget *cancel; 179 | GtkWidget *metb; 180 | 181 | GtkWidget *hseparator2; 182 | GtkWidget *hseparator1; 183 | 184 | GtkObject *step_adj; 185 | GtkObject *to_adj; 186 | GtkObject *from_adj; 187 | GtkObject *tres_adj; 188 | 189 | GtkWidget *tlabel; 190 | 191 | if(floaded==FALSE) {return;} 192 | 193 | window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); 194 | gtk_object_set_data (GTK_OBJECT (window1), "window1", window1); 195 | gtk_container_set_border_width (GTK_CONTAINER (window1), 10); 196 | gtk_window_set_title (GTK_WINDOW (window1),("Selection ")); 197 | gtk_window_set_position (GTK_WINDOW (window1), GTK_WIN_POS_CENTER); 198 | gtk_window_set_default_size (GTK_WINDOW (window1), 180, 180); 199 | gtk_window_set_policy (GTK_WINDOW (window1), FALSE, FALSE, FALSE); 200 | gtk_signal_connect (GTK_OBJECT (window1), "destroy", 201 | GTK_SIGNAL_FUNC (destroy_smartsel),window1); 202 | 203 | table1 = gtk_table_new (7, 2, FALSE); 204 | gtk_widget_ref (table1); 205 | gtk_object_set_data_full (GTK_OBJECT (window1), "table1", table1, 206 | (GtkDestroyNotify) gtk_widget_unref); 207 | gtk_widget_show (table1); 208 | gtk_container_add (GTK_CONTAINER (window1), table1); 209 | gtk_table_set_row_spacings (GTK_TABLE (table1), 5); 210 | 211 | /////////LABELS///////////////////////////////////////////////// 212 | lfrom=create_label("From Partial #", 0,1,0,1, window1 ,table1, "1"); 213 | lto =create_label("To Partial #", 0,1,1,2, window1 ,table1, "2"); 214 | lstep=create_label("Jump by ", 0,1,2,3, window1 ,table1, "3"); 215 | ltres=create_label("Amp. Treshold(dB)", 0,1,3,4, window1 ,table1, "4"); 216 | lmet =create_label("Amp. Evaluation" , 0,1,4,5, window1 ,table1, "5"); 217 | 218 | ///////////////BUTTONS//////////////////// 219 | 220 | tlabel = gtk_label_new (""); 221 | gtk_widget_show (tlabel); 222 | 223 | metb= gtk_toggle_button_new(); 224 | gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(metb),sdata->met); 225 | gtk_signal_connect (GTK_OBJECT (metb), "toggled", 226 | GTK_SIGNAL_FUNC (set_met),tlabel); 227 | gtk_container_add (GTK_CONTAINER (metb), tlabel); 228 | gtk_table_attach (GTK_TABLE (table1), metb, 1, 2, 4, 5, 229 | (GtkAttachOptions) (0), 230 | (GtkAttachOptions) (0), 0, 0); 231 | gtk_widget_set_usize (metb, 72, 32); 232 | set_met(GTK_WIDGET(metb), tlabel); 233 | gtk_widget_show (metb); 234 | 235 | 236 | OK = gtk_button_new_with_label (("Do It")); 237 | gtk_widget_ref (OK); 238 | gtk_object_set_data_full (GTK_OBJECT (window1), "OK", OK, 239 | (GtkDestroyNotify) gtk_widget_unref); 240 | gtk_widget_show (OK); 241 | gtk_table_attach (GTK_TABLE (table1), OK, 1, 2, 6, 7, 242 | (GtkAttachOptions) (0), 243 | (GtkAttachOptions) (0), 0, 0); 244 | gtk_widget_set_usize (OK, 72, 32); 245 | 246 | cancel = gtk_button_new_with_label (("Forget It")); 247 | gtk_widget_ref (cancel); 248 | gtk_object_set_data_full (GTK_OBJECT (window1), "cancel", cancel, 249 | (GtkDestroyNotify) gtk_widget_unref); 250 | gtk_widget_show (cancel); 251 | gtk_table_attach (GTK_TABLE (table1), cancel, 0, 1, 6, 7, 252 | (GtkAttachOptions) (0), 253 | (GtkAttachOptions) (0), 0, 0); 254 | gtk_widget_set_usize (cancel, 72, 32); 255 | 256 | 257 | hseparator2 = gtk_hseparator_new (); 258 | gtk_widget_ref (hseparator2); 259 | gtk_object_set_data_full (GTK_OBJECT (window1), "hseparator2", hseparator2, 260 | (GtkDestroyNotify) gtk_widget_unref); 261 | gtk_widget_show (hseparator2); 262 | gtk_table_attach (GTK_TABLE (table1), hseparator2, 1, 2, 5, 6, 263 | (GtkAttachOptions) (GTK_FILL), 264 | (GtkAttachOptions) (GTK_FILL), 0, 10); 265 | 266 | hseparator1 = gtk_hseparator_new (); 267 | gtk_widget_ref (hseparator1); 268 | gtk_object_set_data_full (GTK_OBJECT (window1), "hseparator1", hseparator1, 269 | (GtkDestroyNotify) gtk_widget_unref); 270 | gtk_widget_show (hseparator1); 271 | gtk_table_attach (GTK_TABLE (table1), hseparator1, 0, 1, 5, 6, 272 | (GtkAttachOptions) (GTK_FILL), 273 | (GtkAttachOptions) (0), 0, 10); 274 | 275 | 276 | //////////////////////////////////////////////////////////////////// 277 | //////////////////////////////////////////////////////////////////// 278 | 279 | 280 | from_adj=create_adj(window1, table1, 1., atshed->par, sdata->from, 1,2,0,1, "1"); 281 | to_adj =create_adj(window1, table1, 1., atshed->par, sdata->to , 1,2,1,2, "2"); 282 | step_adj=create_adj(window1, table1, 1., atshed->par-1,sdata->step, 1,2,2,3, "3"); 283 | tres_adj=create_adj(window1, table1, -120., 0.,sdata->tres, 1,2,3,4, "4"); 284 | 285 | gtk_signal_connect (GTK_OBJECT (OK), "clicked",GTK_SIGNAL_FUNC (do_smartsel),window1); 286 | gtk_signal_connect (GTK_OBJECT (cancel), "clicked",GTK_SIGNAL_FUNC (destroy_smartsel),window1); 287 | 288 | gtk_grab_add (window1); 289 | gtk_widget_show (window1); 290 | 291 | return; 292 | } 293 | 294 | -------------------------------------------------------------------------------- /ats-csound/docs/atsbuffuncs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | atsbufread, atscross, atsinterpread, atspartialtap 4 | 5 | 6 | Signal Generators: STFT Resynthesis (Vocoding) 7 | 8 |
9 | 10 |

atsbufread, atscross, atsinterpread, atspartialtap

11 | 12 |
            atsbufread    ktimepnt, kfmod, iatsfile, ipartials[, ipartialoffset, ipartialincr]
13 |
 ar         atscross      ktimepnt, kfmod, iatsfile, ifn, kmylev, kbuflev, ipartials[, ipartialoffset, ipartialincr]
14 |
 kamp       atsinterpread kfreq
15 |
 kfrq, kamp atspartialtap ipartialnum
16 | 17 |
18 |

Description

19 | 20 |

21 | 22 | atsbufread is based on pvbufread by Richard Karpen. 23 | atscross, atsinterpread and 24 | atspartialtap are all dependent on 25 | atsbufread just as pvcross and pvinterp are on pvbufread. 26 | atsbufread reads data from and ATS data file and stores it in 27 | an internal data table of frequency, amplitude pairs. The data stored by an 28 | atsbufread can only be accessed by other unit generators, and 29 | therefore, due to the architecture of Csound, an atsbufread 30 | must come before (but not necessarily directly) any dependent unit generator. 31 | Besides the fact that atsbufread doesn't output any data 32 | directly, it works almost exactly as atsadd. The ugen uses a time 34 | pointer (ktimepnt) to index the data in time, ipartials, 35 | ipartialoffset and ipartialincr to select which partials to 36 | store in the table and kfmod to scale partials in frequency. 37 | 38 |

39 | 40 |

41 | 42 | atscross uses data from an ATS analysis file (indicated by 43 | iatsfile) and data from an atsbufread to perform 44 | cross synthesis. atscross uses ktimepnt, 45 | kfmod, ipartials, ipartialoffset and 46 | ipartialincr just like 47 | atsadd . atscross synthesizes a 48 | sine-wave for each partial selected by the user and uses the frequency of that 49 | partial (after scaling in frequency by kfmod) to index the table 50 | created by atsbufread. Interpolation is used to get 51 | in-between values. atscross uses the sum of the amplitude 52 | data from its ATS file (scaled by kmylev) and the amplitude data 53 | gained from an atsbufread (scaled by kbuflev) to 54 | scale the amplitude of each partial it synthesizes. Setting kmylev 55 | to one and kbuflev to zero will make atscross act 56 | exactly like atsadd. Setting kmylev to zero and 57 | kbuflev to one will produce a sound that has all the partials 58 | selected by the atscross ugen, but with amplitudes taken from 59 | an atsbufread. The time pointers of the 60 | atsbufread and atscross do not need to be 61 | the same. 62 | 63 |

64 | 65 |

66 | 67 | atsinterpread takes a frequency value (kfreq in Hz). 68 | This frequency is used to index the data of an atsbufread. 69 | The return value is an amplitude gained from the atsbufread 70 | after interpolation. atsinterpread allows a user to 71 | determine the frequency envelope of any atsbufread. This 72 | data could be useful for an number of reasons, one might be performing cross 73 | synthesis of data from an ATS file and non ATS data. 74 | 75 |

76 | 77 |

78 | 79 | atspartialtap takes a partial number and returns a frequency, 80 | amplitude pair. The frequency and amplitude data comes from an 81 | atsbufread opcode. This is more restricted version of atsread, since each 83 | atsread opcode has its own independent time pointer, and 84 | atspartialtap is restricted to the data given by an 85 | atsbufread. Its simplicity is its attractive feature. 86 | 87 |

88 | 89 |

Initialization

90 | 91 |

ktimepnt – a time pointer for reading through the ATS 92 | file

93 | 94 |

kfmod – an input for performing pitch transposition or 95 | frequency modulation on all of the synthesized partials, if no fm or pitch 96 | change is desired then use a 1 for this value

97 | 98 |

iatsfile – integer or character-string denoting a 99 | control-file derived from ATS analysis of an audio signal. An integer denotes 100 | the suffix of a file ATS.m; a character-string (in double quotes) 101 | gives a filename, optionally a full pathname. If not full-path, the file is 102 | sought first in the current directory, then in the one given by the environment 103 | variable SADIR (if defined).

104 | 105 |

ifn – table number of a stored function containing a sine 106 | wave for atsadd and a cosine for atsaddnz (see examples below for more 107 | info)

108 | 109 |

ipartials / ibands – number of partials or noise bands that 110 | will be used in the re-synthesis (the noise has a maximum of 25 bands)

111 | 112 |

ipartialoffset / ibandoffset (optional) – is the first 113 | partial or noise band used (defaults to 0).

114 | 115 |

ipartialincr / ibandincr (optional) – sets an increment by 116 | which these synthesis opcodes counts up from 117 | ipartialoffset/ibandoffset for ibins components in the 118 | re-synthesis (defaults to 1).

119 | 120 |

kmylev scales the atscross component of the frequency spectrum 121 | applied to the partials from the ATS file indicated by the 122 | atscross opcode. The frequency spectrum information comes 123 | from the atscross ATS file. A value of 1 (and 0 for kbuflev) gives the same results as 124 | atsadd.

125 | 126 |

kbuflev scales the atsbufread component of the frequency spectrum 127 | applied to the partials from the ATS file indicated by the 128 | atscross opcode. The frequency spectrum information comes 129 | from the atsbufread ATS file. A value of 1 (and 0 for kmylev) 130 | results in partials that have frequency information from the ATS file given by 131 | the atscross, but amplitudes imposed by data from the ATS file 132 | given by atsbufread

133 | 134 |

kfreq is a frequency value (given in Hertz) used by 135 | atsinterpread as in index into the table produced by an 136 | atsbufread

137 | 138 |

ipartialnum indicates the partial that the 139 | atspartialtap opcode should read from an 140 | atsbufread.

141 | 142 |

Performance

143 |

ktimpnt and kfmod are used in the same way as in 144 | pvoc.

145 | 146 |

Examples

147 | 1. 148 |
  ktime line 0, p3, 2.4
149 |   ktime2 line 0, p3, .5
150 |   kline expseg 0.001, .9, 1, p3-.9, 1
151 |   kline2 expseg .001, p3, 1
152 |   atsbufread  ktime2, 1, "crt.ats", 20
153 |   aout atscross ktime, 1, "cl.ats", 1, kline, .001* (1 - kline2), 42
154 |

155 | This example performs cross synthesis using two ATS files, crt.ats and 156 | cl.ats. The result of this will be a sound that starts out with the shape 157 | (in frequency) of crt.ats, and ends with the shape of cl.ats. All the 158 | sine-wave frequencies come from cl.ats. The kbuflev value is scaled 159 | because the energy produced by applying crt.ats's frequency spectrum to 160 | cl.ats's partials is very large. Notice also that the time pointers of the 161 | atsbufread (crt.ats) and atscross (cl.ats) need not have the same value, this 162 | way you can read through the two ATS files at different rates. 163 |

164 | 165 | 2. 166 |
  ktime  line  0, p3, 2.4
167 |   atsbufread  ktime, 1, "cl.ats", 42
168 |   kamp  atsinterpread p4
169 |   aosc  oscili  kamp, p4, 1
170 |   
171 |

172 | This example shows how to use atsinterpread. Here a frequency is given by 173 | the score (p4) and this frequency is given to an atsinterpread (with a 174 | corresponding atsbufread). The atsinterpread uses this frequency to output a 175 | corresponding amplitude value, based on the atsfile given by the atsbufread 176 | (cl.ats in this case). We then use that amplitude to scale a sine-wave that 177 | is synthesized with the same frequency (p4). You could extend this to 178 | include multiple sine-waves. This way you could synthesize any reasonable 179 | frequency (within the low and high frequencies of the indicated ATS file), 180 | and maintain the shape (in frequency) of the indicated atsfile (given by the 181 | atsbufread). 182 |

183 | 184 | 3. 185 |
  ktime line 0, p3, 2.4
186 |   atsbufread  ktime, 1, "crt.ats", 20
187 |   kfreq1, kamp1 atspartialtap 1
188 |   kfreq2, kamp2 atspartialtap 10
189 |   kfreq3, kamp3 atspartialtap 20
190 |

191 | This example here uses an atspartialtap, and an atsbufread to read partials 192 | 1, 10 and 20 from crt.ats. These amplitudes and frequencies could be used to 193 | re-synthesize those partials, or something all together different. 194 |

195 | 196 | 197 |

Author

198 |

Alex Norman (an edited version of Richard Karpen's pvadd documentation)
199 | Seattle, Wash
200 | 2004
201 | 202 | -------------------------------------------------------------------------------- /icmc-paper/chicago.sty: -------------------------------------------------------------------------------- 1 | % -*- LaTeX -*- 2 | %%% ==================================================================== 3 | %%% @LaTeX-style-file{ 4 | %%% author = "Glenn Paulley", 5 | %%% version = "4", 6 | %%% date = "31 August 1992", 7 | %%% time = "09:42:44 199", 8 | %%% filename = "chicago.sty", 9 | %%% address = "Data Structuring Group 10 | %%% Department of Computer Science 11 | %%% University of Waterloo 12 | %%% Waterloo, Ontario, Canada 13 | %%% N2L 3G1", 14 | %%% telephone = "(519) 885-1211", 15 | %%% FAX = "(519) 885-1208", 16 | %%% checksum = "44674 264 1050 10394", 17 | %%% email = "gnpaulle@bluebox.uwaterloo.ca", 18 | %%% codetable = "ISO/ASCII", 19 | %%% keywords = "", 20 | %%% supported = "yes", 21 | %%% abstract = "Contains the LaTeX style command definitions 22 | %%% for the Chicago BibTeX styles chicago.bst and 23 | %%% chicagoa.bst. For details, see below.", 24 | %%% docstring = "The checksum field above contains a CRC-16 25 | %%% checksum as the first value, followed by the 26 | %%% equivalent of the standard UNIX wc (word 27 | %%% count) utility output of lines, words, and 28 | %%% characters. This is produced by Robert 29 | %%% Solovay's checksum utility.", 30 | %%% } 31 | %%% ==================================================================== 32 | % 33 | % chicago.sty: Style file for use with bibtex style chicago.bst, for 34 | % bibliographies formatted according to the 13th Edition of the Chicago 35 | % Manual of Style. 36 | % 37 | % 'newapa.bst' was made from 'plain.bst', 'named.bst', and 'apalike.bst', 38 | % with lots of tweaking to make it look like APA style, along with tips 39 | % from Young Ryu and Brian Reiser's modifications of 'apalike.bst'. 40 | % newapa.sty formed the basis of this style, chicago.sty. Author-date 41 | % references in newapa.bst formed the basis for chicago.bst. Chicagoa.bst 42 | % supports annotations. 43 | % 44 | % Version 4 (August, 1992): 45 | % - fixed chicago.bst and chicagoa.bst to handle long author lists in 46 | % sorting 47 | % - fixed chicago.bst and chicagoa.bst so that missing page numbers in 48 | % ``article'' entries are handled correctly 49 | % - modified chicago.sty to format entries with 2nd and subsequent lines 50 | % indented. 51 | % 52 | % Citation format: (author-last-name year) 53 | % (author-last-name and author-last-name year) 54 | % (author-last-name et al. year) 55 | % (author-last-name) 56 | % author-last-name 57 | % author-last-name (year) 58 | % (author-last-name and author-last-name) 59 | % (author-last-name et al.) 60 | % (year) or (year,year) 61 | % year or year,year 62 | % 63 | % Reference list ordering: alphabetical by author or whatever passes 64 | % for author in the absence of one. 65 | % 66 | % This BibTeX style has support for abbreviated author lists and for 67 | % year-only citations. This is done by having the citations 68 | % actually look like 69 | % 70 | % \citeauthoryear{full-author-info}{abbrev-author-info}{year} 71 | % 72 | % The LaTeX style has to have the following (or similar) 73 | % 74 | % \let\@internalcite\cite 75 | % \def\fullcite{\def\citeauthoryear##1##2##3{##1, ##3}\@internalcite} 76 | % \def\fullciteA{\def\citeauthoryear##1##2##3{##1}\@internalcite} 77 | % \def\shortcite{\def\citeauthoryear##1##2##3{##2, ##3}\@internalcite} 78 | % \def\shortciteA{\def\citeauthoryear##1##2##3{##2}\@internalcite} 79 | % \def\citeyear{\def\citeauthoryear##1##2##3{##3}\@internalcite} 80 | % 81 | % ------------------------------------------------------------------------- 82 | % This file implements citations for the ``chicago'' bibliography style. 83 | % Place it in a file called chicago.sty in the TeX search path. 84 | %(Placing it in the same directory as the LaTeX document should also work.) 85 | % 86 | % This file is a modification of the ``newapa'' LaTeX style, 87 | % originally adapted by Steven Spencer from the ``apalike'' LaTeX style. 88 | % It was originally modified by Stephen N. Spencer, with further 89 | % modifications by Young U. Ryu. 90 | % 91 | % The ``chicago'' BibTeX bibliography style creates citations with labels: 92 | % \citeauthoryear{author-info}{abbrev. author-info}{year} 93 | % 94 | % These labels are processed by the following LaTeX commands: 95 | % 96 | % \cite{key} 97 | % which produces citations with full author list and year. 98 | % eg. (Brown 1978; Jarke, Turner, Stohl, et al. 1985) 99 | % \citeNP{key} 100 | % which produces citations with full author list and year, but without 101 | % enclosing parentheses: 102 | % eg. Brown 1978; Jarke, Turner and Stohl 1985 103 | % \citeA{key} 104 | % which produces citations with only the full author list. 105 | % eg. (Brown; Jarke, Turner and Stohl) 106 | % \citeANP{key} 107 | % which produces citations with only the full author list, without 108 | % parentheses eg. Brown; Jarke, Turner and Stohl 109 | % \citeN{key} 110 | % which produces citations with the full author list and year, but 111 | % can be used as nouns in a sentence; no parentheses appear around 112 | % the author names, but only around the year. 113 | % eg. Shneiderman (1978) states that...... 114 | % \citeN should only be used for a single citation. 115 | % \shortcite{key} 116 | % which produces citations with abbreviated author list and year. 117 | % \shortciteNP{key} 118 | % which produces citations with abbreviated author list and year. 119 | % \shortciteA{key} 120 | % which produces only the abbreviated author list. 121 | % \shortciteANP{key} 122 | % which produces only the abbreviated author list. 123 | % \shortciteN{key} 124 | % which produces the abbreviated author list and year, with only the 125 | % year in parentheses. Use with only one citation. 126 | % \citeyear{key} 127 | % which produces the year information only, within parentheses. 128 | % \citeyearNP{key} 129 | % which produces the year information only. 130 | % 131 | % Abbreviated author lists use the ``et al.'' construct. 132 | % 133 | % `NP' means `no parentheses'. 134 | % 135 | % This LaTeX style file must be used with the ``chicago'' or ``chicagoa'' 136 | % (annotated chicago style) BibTeX styles. 137 | % 138 | \typeout{Using Chicago Manual of Style bibliography: 31 August 1992} 139 | % 140 | % ------------------------------------------------------------------------- 141 | % 142 | % Citation macros. 143 | % 144 | \let\@internalcite\cite 145 | % 146 | \def\cite{\def\@citeseppen{-1000}% 147 | \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}% 148 | \def\citeauthoryear##1##2##3{##1 ##3}\@internalcite} 149 | \def\citeNP{\def\@citeseppen{-1000}% 150 | \def\@cite##1##2{##1\if@tempswa , ##2\fi}% 151 | \def\citeauthoryear##1##2##3{##1 ##3}\@internalcite} 152 | \def\citeN{\def\@citeseppen{-1000}% 153 | \def\@cite##1##2{##1\if@tempswa , ##2)\else{)}\fi}% 154 | \def\citeauthoryear##1##2##3{##1 (##3}\@citedata} 155 | \def\citeA{\def\@citeseppen{-1000}% 156 | \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}% 157 | \def\citeauthoryear##1##2##3{##1}\@internalcite} 158 | \def\citeANP{\def\@citeseppen{-1000}% 159 | \def\@cite##1##2{##1\if@tempswa , ##2\fi}% 160 | \def\citeauthoryear##1##2##3{##1}\@internalcite} 161 | % 162 | \def\shortcite{\def\@citeseppen{-1000}% 163 | \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}% 164 | \def\citeauthoryear##1##2##3{##2 ##3}\@internalcite} 165 | \def\shortciteNP{\def\@citeseppen{-1000}% 166 | \def\@cite##1##2{##1\if@tempswa , ##2\fi}% 167 | \def\citeauthoryear##1##2##3{##2 ##3}\@internalcite} 168 | \def\shortciteN{\def\@citeseppen{-1000}% 169 | \def\@cite##1##2{##1\if@tempswa , ##2)\else{)}\fi}% 170 | \def\citeauthoryear##1##2##3{##2 (##3}\@citedata} 171 | \def\shortciteA{\def\@citeseppen{-1000}% 172 | \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}% 173 | \def\citeauthoryear##1##2##3{##2}\@internalcite} 174 | \def\shortciteANP{\def\@citeseppen{-1000}% 175 | \def\@cite##1##2{##1\if@tempswa , ##2\fi}% 176 | \def\citeauthoryear##1##2##3{##2}\@internalcite} 177 | % 178 | \def\citeyear{\def\@citeseppen{-1000}% 179 | \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}% 180 | \def\citeauthoryear##1##2##3{##3}\@citedata} 181 | \def\citeyearNP{\def\@citeseppen{-1000}% 182 | \def\@cite##1##2{##1\if@tempswa , ##2\fi}% 183 | \def\citeauthoryear##1##2##3{##3}\@citedata} 184 | 185 | % 186 | % \@citedata and \@citedatax: 187 | % 188 | % Place commas in-between citations in the same \citeyear, \citeyearNP, 189 | % \citeN, or \shortciteN command. 190 | % Use something like \citeN{ref1,ref2,ref3} and \citeN{ref4} for a list. 191 | % 192 | \def\@citedata{% 193 | \@ifnextchar [{\@tempswatrue\@citedatax}% 194 | {\@tempswafalse\@citedatax[]}% 195 | } 196 | 197 | \def\@citedatax[#1]#2{% 198 | \if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi% 199 | \def\@citea{}\@cite{\@for\@citeb:=#2\do% 200 | {\@citea\def\@citea{, }\@ifundefined% by Young 201 | {b@\@citeb}{{\bf ?}% 202 | \@warning{Citation `\@citeb' on page \thepage \space undefined}}% 203 | {\csname b@\@citeb\endcsname}}}{#1}}% 204 | 205 | % don't box citations, separate with ; and a space 206 | % also, make the penalty between citations negative: a good place to break. 207 | % 208 | \def\@citex[#1]#2{% 209 | \if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi% 210 | \def\@citea{}\@cite{\@for\@citeb:=#2\do% 211 | {\@citea\def\@citea{; }\@ifundefined% by Young 212 | {b@\@citeb}{{\bf ?}% 213 | \@warning{Citation `\@citeb' on page \thepage \space undefined}}% 214 | {\csname b@\@citeb\endcsname}}}{#1}}% 215 | 216 | % (from apalike.sty) 217 | % No labels in the bibliography. 218 | % 219 | \def\@biblabel#1{} 220 | 221 | % (from apalike.sty) 222 | % Set length of hanging indentation for bibliography entries. 223 | % 224 | \newlength{\bibhang} 225 | \setlength{\bibhang}{2em} 226 | 227 | % Indent second and subsequent lines of bibliographic entries. Stolen 228 | % from openbib.sty: \newblock is set to {}. 229 | 230 | \newdimen\bibindent 231 | \bibindent=1.5em 232 | \@ifundefined{refname}% 233 | {\@ifundefined{chapter}% 234 | {\newcommand{\refname}{References}}% 235 | {\newcommand{\refname}{Bibliography}}% 236 | }% 237 | {}% 238 | \@ifundefined{chapter}% 239 | {\def\thebibliography#1{\section*{\refname\@mkboth 240 | {\uppercase{\refname}}{\uppercase{\refname}}}\list 241 | {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]} 242 | \leftmargin\labelwidth 243 | \advance\leftmargin\labelsep 244 | \advance\leftmargin\bibindent 245 | \itemindent -\bibindent 246 | \listparindent \itemindent 247 | \parsep \z@ 248 | \usecounter{enumi}} 249 | \def\newblock{} 250 | \sloppy 251 | \sfcode`\.=1000\relax}} 252 | {\def\thebibliography#1{\chapter*{\refname\@mkboth 253 | {\uppercase{\refname}}{\uppercase{\refname}}}\list 254 | {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]} 255 | \leftmargin\labelwidth 256 | \advance\leftmargin\labelsep 257 | \advance\leftmargin\bibindent 258 | \itemindent -\bibindent 259 | \listparindent \itemindent 260 | \parsep \z@ 261 | \usecounter{enumi}} 262 | \def\newblock{} 263 | \sloppy 264 | \sfcode`\.=1000\relax}} 265 | --------------------------------------------------------------------------------