From: Anders B. <vr-...@us...> - 2004-11-11 07:58:09
|
Update of /cvsroot/alpp/openalpp/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31707/tests Modified Files: Makefile.am README moving.cpp simple.cpp testfstream.cpp testmic.cpp testsend.cpp teststream.cpp Added Files: a.wav high-e.wav low-e.wav multiple.cpp Removed Files: moving.dsp simple.dsp testmic.dsp testsend.dsp teststream.dsp Log Message: Adapted smart (reference) pointers from the OpenSceneGraph library. Used with permission of Robert Osfield. Cleans up the new/delete responsibility. All objects must be created on the heap from now on. Fixed small bugin in Streaming classes. --- NEW FILE: a.wav --- (This appears to be a binary file; contents omitted.) --- teststream.dsp DELETED --- Index: teststream.cpp =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/teststream.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** teststream.cpp 7 Mar 2003 20:26:24 -0000 1.9 --- teststream.cpp 11 Nov 2004 07:57:58 -0000 1.10 *************** *** 1,63 **** ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * CommonC++ (http://cplusplus.sourceforge.net/) ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example where a soundfile is loaded using alutLoadWav and streamed over a UDP socket ! * to a receiver that will read the datastream and play it. ! * A sound Source is created and connected to the UDP stream of data ! */ ! #include <cc++/socket.h> ! #include <cc++/thread.h> ! #include <openalpp/alpp.h> ! ! using namespace openalpp; ! ! int main(int argc,char **argv) { ! // Buffersize in #samples. <-- This has changed from earlier releases! ! unsigned int buffersize=4096; ! if(argc>1) ! buffersize=atoi(argv[1]); ! ! try { ! // Create a socket and listen for streamed data ! ost::UDPSocket socket(ost::InetAddress("127.0.0.1"),33333); ! ! // Create a soundstream that will read its data from the socket ! // Unless you want to send lots of data, it's a good idea to go for a ! // low rate and/or small sample format. ! NetStream stream(&socket,Mono16,44100,buffersize); ! ! // Create a soundsource that uses the net-streamed soundstream. ! Source source(stream); ! ! source.SetAmbient(); ! source.Play(); ! std::cout << "Press return to continue\n"; ! std::cin.get(); ! source.Stop(); ! } catch(openalpp::Error e) { ! std::cerr << e << "\n"; ! } catch(...) { ! std::cerr << "Unknown error!\n"; ! } ! return 0; ! } --- 1,63 ---- ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * CommonC++ (http://cplusplus.sourceforge.net/) ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example where a soundfile is loaded using alutLoadWav and streamed over a UDP socket ! * to a receiver that will read the datastream and play it. ! * A sound Source is created and connected to the UDP stream of data ! */ ! #include <cc++/socket.h> ! #include <cc++/thread.h> ! #include <openalpp/alpp.h> ! ! using namespace openalpp; ! ! int main(int argc,char **argv) { ! // Buffersize in #samples. <-- This has changed from earlier releases! ! unsigned int buffersize=4096; ! if(argc>1) ! buffersize=atoi(argv[1]); ! ! try { ! // Create a socket and listen for streamed data ! ost::UDPSocket socket(ost::InetAddress("127.0.0.1"),33333); ! ! // Create a soundstream that will read its data from the socket ! // Unless you want to send lots of data, it's a good idea to go for a ! // low rate and/or small sample format. ! NetStream stream(&socket,Mono16,44100,buffersize); ! ! // Create a soundsource that uses the net-streamed soundstream. ! Source source(stream); ! ! source.SetAmbient(); ! source.Play(); ! std::cout << "Press return to continue\n"; ! std::cin.get(); ! source.Stop(); ! } catch(openalpp::Error e) { ! std::cerr << e << "\n"; ! } catch(...) { ! std::cerr << "Unknown error!\n"; ! } ! return 0; ! } --- NEW FILE: low-e.wav --- (This appears to be a binary file; contents omitted.) --- NEW FILE: multiple.cpp --- (This appears to be a binary file; contents omitted.) Index: testmic.cpp =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/testmic.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** testmic.cpp 2 Mar 2004 07:50:27 -0000 1.12 --- testmic.cpp 11 Nov 2004 07:57:58 -0000 1.13 *************** *** 1,96 **** ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example where sound is streamed from a microphone. ! */ ! #include "openalpp/alpp.h" ! #include <iostream> ! ! using namespace openalpp; ! ! #ifndef M_PI ! #define M_PI 3.14159265358979323846 ! #endif ! ! int main() { ! ! #ifdef ALPP_USE_PORTAUDIO ! ! ! try { ! InputDevice mic; ! ! Source source(mic); ! source.setGain(2); ! //source.SetLooping(); ! source.play(); ! usleep(3000*1000); ! ! float limits[2] = {0.5,-0.5}; ! //float delay=10; ! //float time=0,angle=0; ! ! source.setPosition(limits[0],0.0,0.0); ! source.play(); ! ! //const int no_laps=5; ! ! std::cerr << "Moving sound 5 times..." << std::endl; ! ! // Do a cheat time loop. ! #if 0 ! while(angle<(M_PI*no_laps)) { ! usleep(delay*1000); // Wait for delay milliseconds ! ! time +=delay/1000; // Calculate the time in the loop ! angle=M_PI *time; // What is the resulting angle ! ! // Calculate a new position ! std::cerr << cos(angle) << ", " << sin(angle) << std::endl; ! source.setPosition(limits[0]*cos(0),0.0,limits[1]*sin(0)); ! } ! #else ! std::cerr << "Moved to the left" << std::endl; ! source.setPosition(-0.5,0.0,0); ! usleep(3000*1000); ! std::cerr << "Moved to the right" << std::endl; ! source.setPosition(+0.5,0.0,0); ! usleep(3000*1000); ! #endif ! } catch(Error e) { ! std::cerr << e << "\n"; ! return -1; ! } ! ! ! std::cerr << "Press return to continue\n"; ! ! std::cin.get(); ! #else ! std::cerr << "Use of portaudio is not compiled to the project" << std::endl; ! std::cerr << "Look into the config.h and modify that if you inted to use PortAudio" << std::endl; ! #endif ! ! return 0; ! ! } ! --- 1,96 ---- ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example where sound is streamed from a microphone. ! */ ! #include "openalpp/alpp.h" ! #include <iostream> ! ! using namespace openalpp; ! ! #ifndef M_PI ! #define M_PI 3.14159265358979323846 ! #endif ! ! int main() { ! ! #ifdef ALPP_USE_PORTAUDIO ! ! ! try { ! InputDevice mic; ! ! Source source(mic); ! source.setGain(2); ! //source.SetLooping(); ! source.play(); ! usleep(3000*1000); ! ! float limits[2] = {0.5,-0.5}; ! //float delay=10; ! //float time=0,angle=0; ! ! source.setPosition(limits[0],0.0,0.0); ! source.play(); ! ! //const int no_laps=5; ! ! std::cerr << "Moving sound 5 times..." << std::endl; ! ! // Do a cheat time loop. ! #if 0 ! while(angle<(M_PI*no_laps)) { ! usleep(delay*1000); // Wait for delay milliseconds ! ! time +=delay/1000; // Calculate the time in the loop ! angle=M_PI *time; // What is the resulting angle ! ! // Calculate a new position ! std::cerr << cos(angle) << ", " << sin(angle) << std::endl; ! source.setPosition(limits[0]*cos(0),0.0,limits[1]*sin(0)); ! } ! #else ! std::cerr << "Moved to the left" << std::endl; ! source.setPosition(-0.5,0.0,0); ! usleep(3000*1000); ! std::cerr << "Moved to the right" << std::endl; ! source.setPosition(+0.5,0.0,0); ! usleep(3000*1000); ! #endif ! } catch(Error e) { ! std::cerr << e << "\n"; ! return -1; ! } ! ! ! std::cerr << "Press return to continue\n"; ! ! std::cin.get(); ! #else ! std::cerr << "Use of portaudio is not compiled to the project" << std::endl; ! std::cerr << "Look into the config.h and modify that if you inted to use PortAudio" << std::endl; ! #endif ! ! return 0; ! ! } ! Index: moving.cpp =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/moving.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** moving.cpp 23 Sep 2004 06:37:57 -0000 1.13 --- moving.cpp 11 Nov 2004 07:57:58 -0000 1.14 *************** *** 1,71 **** ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * ! * Simple example for using OpenAL++. ! * Plays a file bee.wav and moves it left right. ! */ ! #include <openalpp/alpp.h> ! #include <iostream> ! ! ! using namespace openalpp; ! ! #ifndef M_PI ! #define M_PI 3.14159265358979323846 ! #endif ! ! ! int main() { ! try { ! Source beesound("bee.wav"); ! beesound.setGain(1); ! beesound.setLooping(); ! ! float limits[2] = {5,-15}; ! float delay=10; ! float time=0,angle=0; ! ! beesound.setPosition(limits[0],0.0,0.0); ! beesound.play(); ! ! const int no_laps=5; ! ! std::cerr << "Moving sound 5 laps..." << std::endl; ! ! // Do a cheat time loop. ! while(angle<(M_PI*2.0*no_laps)) { ! usleep(delay*1000); // Wait for delay milliseconds ! ! time +=delay/1000; // Calculate the time in the loop ! angle=M_PI *time; // What is the resulting angle ! ! // Calculate a new position ! beesound.setPosition(limits[0]*cos(angle),0.0,limits[1]*sin(angle)); ! } ! } catch(Error e) { ! std::cerr << e << "\n"; ! return -1; ! } ! return 0; ! } ! --- 1,71 ---- ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * ! * Simple example for using OpenAL++. ! * Plays a file bee.wav and moves it left right. ! */ ! #include <openalpp/alpp.h> ! #include <iostream> ! ! ! using namespace openalpp; ! ! #ifndef M_PI ! #define M_PI 3.14159265358979323846 ! #endif ! ! ! int main() { ! try { ! openalpp::ref_ptr<Source> beesound = new Source("bee.wav"); ! beesound->setGain(1); ! beesound->setLooping(); ! ! float limits[2] = {5,-15}; ! float delay=10; ! float time=0,angle=0; ! ! beesound->setPosition(limits[0],0.0,0.0); ! beesound->play(); ! ! const int no_laps=5; ! ! std::cerr << "Moving sound 5 laps..." << std::endl; ! ! // Do a cheat time loop. ! while(angle<(M_PI*2.0*no_laps)) { ! usleep(delay*1000); // Wait for delay milliseconds ! ! time +=delay/1000; // Calculate the time in the loop ! angle=M_PI *time; // What is the resulting angle ! ! // Calculate a new position ! beesound->setPosition(limits[0]*cos(angle),0.0,limits[1]*sin(angle)); ! } ! } catch(Error e) { ! std::cerr << e << "\n"; ! return -1; ! } ! return 0; ! } ! --- testsend.dsp DELETED --- Index: testsend.cpp =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/testsend.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** testsend.cpp 7 Mar 2003 20:26:24 -0000 1.8 --- testsend.cpp 11 Nov 2004 07:57:58 -0000 1.9 *************** *** 1,99 **** ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * CommonC++ (http://cplusplus.sourceforge.net/) ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example where a soundfile is loaded using alutLoadWav and streamed over a ! * UDP socket to a receiver that will read the datastream and play it. ! * ! * Note about selecting rate, format and sending rate: ! * Rate is given in samples per second, and format gives the size of one ! * sample. This means that, for example: ! * If the format is Mono16, we have one channel with 16 bit per channel, i.e. ! * 16 bit or 2 bytes per sample. ! * Say we have a frequency of 44100 samples per second. 2 byte samples will ! * mean that we need to stream 88200 bytes per second. ! * If we can send (and receive) ten packets per second, each packet should be ! * at least 8820 bytes. ! * If we instead had a frequency of 11025, then it would be enough with 2205 ! * bytes per packet. ! * Of course it's a good idea to add a few hundred bytes to those numbers ;) ! */ ! ! #include <cc++/thread.h> ! #include <cc++/socket.h> ! #include <iostream> ! #include <stdlib.h> ! #include <AL/al.h> ! #include <AL/alut.h> ! #include "openalpp/windowsstuff.h" ! ! using namespace ost; ! ! int main(int argc,char **argv) { ! ALvoid *data; ! ALsizei bits,freq,size; ! ALenum format; ! ALboolean success; ! // Default packet size (in bytes) ! // Note that this doesn't necessarily have to have anything to do with the ! // buffer size of the receiver. Just set it to something appropriate ! // (depending on the connection), and the receiver will take care of the ! // playing the sound correctly... ! unsigned int packetsize=10000; ! const char defaultfile[]="bee.wav"; ! const char *filename; ! ! if(argc>1) ! filename=argv[1]; ! else ! filename=defaultfile; ! if(argc>2) ! packetsize=atoi(argv[2]); ! ! try { ! success=alutLoadWAV(filename,&data,&format,&size,&bits,&freq); ! std::cerr << "Bits: " << bits << " Freq: " << freq << std::endl; ! ! if(success==AL_FALSE) { ! std::cerr << "Error loading " << filename << "\n"; ! exit(1); ! } ! ! UDPSocket socket; ! socket.setPeer(InetHostAddress("127.0.0.1"),33333); ! ! int totalsent=0; ! while(totalsent<size) { ! // Send data in packets with a 60 ms delay between packets ! if((totalsent+packetsize)>size) ! packetsize=size-totalsent; ! totalsent+=socket.send((char *)data+totalsent,packetsize); ! ost::Thread::sleep(60); ! } ! ! free(data); ! } catch(...) { ! std::cerr << "Error caught!\n"; ! } ! ! return 0; ! } --- 1,99 ---- ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * CommonC++ (http://cplusplus.sourceforge.net/) ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example where a soundfile is loaded using alutLoadWav and streamed over a ! * UDP socket to a receiver that will read the datastream and play it. ! * ! * Note about selecting rate, format and sending rate: ! * Rate is given in samples per second, and format gives the size of one ! * sample. This means that, for example: ! * If the format is Mono16, we have one channel with 16 bit per channel, i.e. ! * 16 bit or 2 bytes per sample. ! * Say we have a frequency of 44100 samples per second. 2 byte samples will ! * mean that we need to stream 88200 bytes per second. ! * If we can send (and receive) ten packets per second, each packet should be ! * at least 8820 bytes. ! * If we instead had a frequency of 11025, then it would be enough with 2205 ! * bytes per packet. ! * Of course it's a good idea to add a few hundred bytes to those numbers ;) ! */ ! ! #include <cc++/thread.h> ! #include <cc++/socket.h> ! #include <iostream> ! #include <stdlib.h> ! #include <AL/al.h> ! #include <AL/alut.h> ! #include "openalpp/windowsstuff.h" ! ! using namespace ost; ! ! int main(int argc,char **argv) { ! ALvoid *data; ! ALsizei bits,freq,size; ! ALenum format; ! ALboolean success; ! // Default packet size (in bytes) ! // Note that this doesn't necessarily have to have anything to do with the ! // buffer size of the receiver. Just set it to something appropriate ! // (depending on the connection), and the receiver will take care of the ! // playing the sound correctly... ! unsigned int packetsize=10000; ! const char defaultfile[]="bee.wav"; ! const char *filename; ! ! if(argc>1) ! filename=argv[1]; ! else ! filename=defaultfile; ! if(argc>2) ! packetsize=atoi(argv[2]); ! ! try { ! success=alutLoadWAV(filename,&data,&format,&size,&bits,&freq); ! std::cerr << "Bits: " << bits << " Freq: " << freq << std::endl; ! ! if(success==AL_FALSE) { ! std::cerr << "Error loading " << filename << "\n"; ! exit(1); ! } ! ! UDPSocket socket; ! socket.setPeer(InetHostAddress("127.0.0.1"),33333); ! ! int totalsent=0; ! while(totalsent<size) { ! // Send data in packets with a 60 ms delay between packets ! if((totalsent+packetsize)>size) ! packetsize=size-totalsent; ! totalsent+=socket.send((char *)data+totalsent,packetsize); ! ost::Thread::sleep(60); ! } ! ! free(data); ! } catch(...) { ! std::cerr << "Error caught!\n"; ! } ! ! return 0; ! } Index: simple.cpp =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/simple.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** simple.cpp 23 Sep 2004 06:37:57 -0000 1.13 --- simple.cpp 11 Nov 2004 07:57:58 -0000 1.14 *************** *** 1,60 **** ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Simple example for using OpenAL++. ! * Plays a file bee.wav in the background. ! */ ! #include <openalpp/alpp.h> ! #include <iostream> ! ! using namespace openalpp; ! ! ! int main(int argc,char **argv) { ! ! std::string file; ! file = "bee.wav"; ! ! if (argc > 1) ! file = argv[1]; ! ! std::cout << "Playing " << file << "\n"; ! ! try { ! Source bgsound(file); // Create source and load sound ! bgsound.setGain(0.6f); // Lower gain (volume) ! bgsound.setLooping(); ! bgsound.setAmbient(); // Make sound ambient (i.e. not attenuated) ! bgsound.play(); // Start playing ! ! ! std::cerr << "playing bee.wav for 3 seconds: " << std::endl; ! usleep(3000*1000); // Sleep for a while ! std::cerr << "Done " << std::endl; ! bgsound.stop(); ! ! } catch(Error e) { ! std::cerr << e << "\n"; ! return -1; ! } ! return 0; ! } --- 1,65 ---- ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Simple example for using OpenAL++. ! * Plays a file bee.wav in the background. ! */ ! #include <openalpp/alpp.h> ! #include <iostream> ! ! using namespace openalpp; ! ! ! int main(int argc,char **argv) { ! ! std::string file; ! file = "bee.wav"; ! ! if (argc > 1) ! file = argv[1]; ! ! std::cout << "Playing " << file << "\n"; ! ! try { ! openalpp::ref_ptr<Source> bgsound = new Source; //(file); // Create source and load sound ! openalpp::ref_ptr<Sample> sample = new Sample(file); ! bgsound->setSound(sample.get()); ! bgsound->setGain(0.6f); // Lower gain (volume) ! bgsound->setLooping(); ! bgsound->setAmbient(); // Make sound ambient (i.e. not attenuated) ! bgsound->play(); // Start playing ! ! ! std::cerr << "Press return to stop: " << std::endl; ! //usleep(3000*1000); // Sleep for a while ! std::string str; ! std::getline(std::cin, str); ! bgsound->stop(); ! std::cerr << "Done " << std::endl; ! usleep(3000*1000); ! ! } catch(Error e) { ! std::cerr << e << "\n"; ! return -1; ! } ! return 0; ! } Index: Makefile.am =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.am 2 Mar 2004 07:50:27 -0000 1.6 --- Makefile.am 11 Nov 2004 07:57:58 -0000 1.7 *************** *** 15,19 **** LDADD = ../src/libopenalpp.la $(ccgnulibs) -lopenal $(portaudiolibs) $(ogglibs) -lOpenThreads ! bin_PROGRAMS = testfstream testmic simple moving #testsend teststream #teststream_SOURCES = teststream.cpp --- 15,19 ---- LDADD = ../src/libopenalpp.la $(ccgnulibs) -lopenal $(portaudiolibs) $(ogglibs) -lOpenThreads ! bin_PROGRAMS = testfstream multiple testmic simple moving #testsend teststream #teststream_SOURCES = teststream.cpp *************** *** 27,30 **** --- 27,32 ---- moving_SOURCES = moving.cpp + testfstream_SOURCES = testfstream.cpp + multiple_SOURCES = multiple.cpp --- NEW FILE: high-e.wav --- (This appears to be a binary file; contents omitted.) --- testmic.dsp DELETED --- Index: README =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/README,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README 19 Feb 2002 09:44:46 -0000 1.3 --- README 11 Nov 2004 07:57:58 -0000 1.4 *************** *** 9,17 **** testsend - Load a file (gamebeginning.wav - not included) and send it through a socket, in packets of 1024 bytes. To be used in conjunction with teststream. teststream - Connect a socket to a source and play it. Run testsend directly after running this. More tests might be added in the future. The stranger tests that I used while developing have been removed as they would ! probably not be very interesting. For more examples, check the tutorials on the homepage. ! /Tomas Hämälä, VRlab, 2002 --- 9,21 ---- testsend - Load a file (gamebeginning.wav - not included) and send it through a socket, in packets of 1024 bytes. To be used in conjunction with teststream. + multiple - Loads and plays and deletes several wav files. Tests the reference pointer deallocation + teststream - Connect a socket to a source and play it. Run testsend directly after running this. + More tests might be added in the future. The stranger tests that I used while developing have been removed as they would ! probably not be very interesting. ! /Anders Backman, VRlab, 2004 ! Tomas Hämälä, VRlab, 2002 --- simple.dsp DELETED --- Index: testfstream.cpp =================================================================== RCS file: /cvsroot/alpp/openalpp/tests/testfstream.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** testfstream.cpp 2 Mar 2004 07:50:27 -0000 1.6 --- testfstream.cpp 11 Nov 2004 07:57:58 -0000 1.7 *************** *** 1,58 **** ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example of streaming from a file. Only ogg files are supported at the ! * moment (2003-02-15). The program takes one argument; the name of the file ! * to stream data from. ! */ ! ! #include <openalpp/alpp.h> ! #include <iostream> ! ! using namespace openalpp; ! ! int main(int argc,char **argv) { ! if(argc<=1) { ! std::cerr << "Syntax:\n " << argv[0] << " <audiofile>\n"; ! return 1; ! } ! ! std::cout << argv[1] << "\n"; ! ! try { ! FileStream stream(argv[1]); ! stream.setLooping(); // Remove this to play file once only. ! ! Source source(stream); ! ! source.setAmbient(); ! source.play(); ! std::cerr << "Press return to continue\n"; ! std::cin.get(); ! source.stop(); ! } catch(openalpp::Error e) { ! std::cerr << e << "\n"; ! //} catch(...) { ! // std::cerr << "Unknown error!\n"; ! } ! return 0; ! } --- 1,72 ---- ! /** ! * OpenAL++ - an object oriented toolkit for spatial sound ! * Copyright (C) 2002 VRlab, Umeå University ! * ! * OpenAL++ was created using the libraries: ! * OpenAL (http://www.openal.org), ! * PortAudio (http://www.portaudio.com/), and ! * ! * This library is 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. ! * ! * This library 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 this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! * ! * Example of streaming from a file. Only ogg files are supported at the ! * moment (2003-02-15). The program takes one argument; the name of the file ! * to stream data from. ! */ ! ! #include <openalpp/alpp.h> ! #include <iostream> ! ! using namespace openalpp; ! ! int main(int argc,char **argv) { ! if(argc<=1) { ! std::cerr << "Syntax:\n " << argv[0] << " <audiofile>\n"; ! return 1; ! } ! ! std::cout << argv[1] << "\n"; ! ! try { ! ! std::vector<openalpp::ref_ptr<Source> > vec; ! std::vector<openalpp::ref_ptr<FileStream> > fstream_vec; ! ! for(int i=0; i < 1; i++) { ! ! openalpp::ref_ptr<FileStream> stream = new FileStream(argv[1]); ! fstream_vec.push_back(stream); ! stream->setLooping(); // Remove this to play file once only. ! ! ! Source *source = new Source(*stream.get()); ! vec.push_back(source); ! source->setAmbient(); ! source->play(); ! ! } ! std::cerr << "Press return to stop " << std::endl; ! std::cin.get(); ! ! for(unsigned int i=0; i < vec.size(); i++) ! vec[i]->stop(); ! usleep(1000*1000); ! ! } catch(openalpp::Error e) { ! std::cerr << e << "\n"; ! } catch(...) { ! std::cerr << "Unknown error!\n"; ! } ! return 0; ! } --- moving.dsp DELETED --- |