From: Martin R. <ru...@us...> - 2004-07-31 07:00:19
|
Update of /cvsroot/foo/foo/libfoo/tests/foosine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3836/foosine Added Files: Makefile.am foosine.m Log Message: add tests directory with foosine test --- NEW FILE: Makefile.am --- # foo/libfoo/tests/foosine/Makefile.am # 2004 rumori # $Id: Makefile.am,v 1.1 2004/07/31 07:00:10 rumori Exp $ NULL = bin_PROGRAMS = foosine foosine_SOURCES = \ foosine.m \ $(NULL) FOO_CFLAGS = @FOO_CFLAGS@ FOO_OBJCFLAGS = @FOO_OBJCFLAGS@ FOO_LDFLAGS = @FOO_LDFLAGS@ FOO_LIBS = @FOO_LIBS@ if USE_GS_BASE include @GNUSTEP_MAKEFILES@/library-combo.make include @GNUSTEP_MAKEFILES@/common.make include @GNUSTEP_MAKEFILES@/Additional/base.make endif foosine_CFLAGS = $(FOO_CFLAGS) foosine_OBJCFLAGS = $(FOO_OBJCFLAGS) \ $(GNUSTEP_HEADERS_FLAGS) \ $(FND_DEFINE) \ $(AUXILIARY_OBJCFLAGS) \ -I../../modules foosine_LDFLAGS = $(FOO_LDFLAGS) \ $(GNUSTEP_LIBRARIES_FLAGS) foosine_LDADD = $(FND_LIBS) \ -lobjc \ ../../src/libfoo.la --- NEW FILE: foosine.m --- /* * foosine.m * * test libfoo by creating a sinewave * */ /* * foo sound synthesis system * * (C)1993-2004 Gerhard Eckel, Ramon Gonzalez-Arroyo, IRCAM, ZKM * (C)2003-2004 Martin Rumori */ /* * This file is part of foo. * * foo free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * foo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with foo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef GNUSTEP_BASE_LIBRARY #include <GSConfig.h> #endif #include <limits.h> #include <string.h> #include <sndfile.h> #import <Foundation/NSAutoreleasePool.h> #include <FOOGlobal.h> #include <FOOContext.h> #include <FOOOutput.h> #include <orthodox/FOOMOscillator.h> #include <orthodox/FOOMConstant.h> #define FOOSINE_BLOCKSIZE 1024 #define FOOSINE_SAMPLERATE 48000 #define FOOSINE_BLOCKS 64 static FOOContext *_context; /* this is a hack to allow for using libfoo without elkfoo * should be better soon... */ id getCurrentContext () { return _context; } // getCurrentContext int main (int argc, char **argv) { FOOOutput *output; FOOMOscillator *osc; FOOMConstant *freq; sample_t *buf; SNDFILE *file; SF_INFO sfinfo; // autorelease pool [[NSAutoreleasePool alloc] init]; // create context _context = [[FOOContext alloc] initWithChans: 1]; [_context setTime: 0]; AUTORELEASE(_context); // create and init modules output = (FOOOutput *)[[FOOOutput alloc] initWithContext: _context]; [output initWithChannel: 1]; osc = [[[FOOMOscillator alloc] init] initializePhase: 0]; freq = [[[FOOMConstant alloc] init] setValue: 440.0f]; // connect modules [osc connectInput: 0 to: freq]; [output connect: osc]; // create soundfile memset (&sfinfo, 0, sizeof(sfinfo)); sfinfo.samplerate = FOOSINE_SAMPLERATE; sfinfo.channels = 1; sfinfo.format = (SF_FORMAT_AIFF | SF_FORMAT_PCM_16); if (! (file = sf_open("foosine.aiff", SFM_WRITE, &sfinfo))) { fprintf(stderr, "error : Not able to open output file.\n"); exit(EXIT_FAILURE); } sf_close(file); // do task's work (this should get into libfoo once) if (! (buf = malloc(FOOSINE_BLOCKSIZE * sizeof(sample_t)))) { fprintf(stderr, "malloc failed. desperating...\n"); exit(EXIT_FAILURE); } [_context setSamplingRate: FOOSINE_SAMPLERATE]; [_context setBufferSize: FOOSINE_BLOCKSIZE]; [_context setSampleTime: 0.]; [_context compile]; [_context openOutput: @"foosine.aiff" addin: NO at: 0.]; [_context run: FOOSINE_BLOCKS * FOOSINE_BLOCKSIZE factor: .5]; [_context closeOutput]; return 0; } // main |