PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
AudioOutTest.cpp
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: AudioOutTest.cpp
4// Purpose: Tests the PAudioOut and PlatformAudioOut Classes
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003 Shane T. Mueller <smueller@umich.edu>
7// License: GPL 2
8//
9//
10//
11// This file is part of the PEBL project.
12//
13// PEBL is free software; you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation; either version 2 of the License, or
16// (at your option) any later version.
17//
18// PEBL is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with PEBL; if not, write to the Free Software
25// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27#include "../devices/PAudioOut.h"
28#include "../platforms/sdl/PlatformAudioOut.h"
29#include "../base/Loader.h"
30#include "../base/PComplexData.h"
31#include "../base/PList.h"
32#include "../base/FunctionMap.h"
33#include "../base/VariableMap.h"
34#include "../base/Variant.h"
35#include "../base/Evaluator.h"
36#include "../devices/PEventLoop.h"
37
38#include "SDL/SDL.h"
39
40#include <iostream>
41
42using std::cout;
43using std::endl;
44using std::flush;
45
52
53//The following is the entry point for the command-line version
54
55int main(int argc, char *argv[])
56{
57
58 cout << "\n\n\n==========================================================\n";
59 cout << "Testing the PAudioOut class\n";
60 cout << "==========================================================\n";
61
62 //Set up the search path.
63 std::list<char*> tmp;
64 tmp.push_back("./");
66
67 /* Load the SDL library */
68 if ( SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0 ) {
69 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
70 exit(1);
71 }
72
73 atexit(SDL_Quit);
74
75 cout << "Audio Initialized: " << SDL_WasInit(SDL_INIT_AUDIO) << "--" << SDL_INIT_AUDIO << endl;
76
77
78 cout << "Constructing Audio\n";
79 PlatformAudioOut * myAudioOut = new PlatformAudioOut();
80 PlatformAudioOut * myAudioOut2 = new PlatformAudioOut();
81
82 myAudioOut->LoadSoundFile("buzz500ms.wav");
83
84
85 myAudioOut->PlayForeground();
86 cout << "Playing\n";
87 SDL_Delay(500);
88 myAudioOut->PlayForeground();
89 cout << "Playing\n";
90
91
92 char name[32];
93 printf("Using audio driver: %s\n", SDL_AudioDriverName(name, 32));
94
95
96
97
98
99
100
101 cout << "Finished" << endl;
102 return 0;
103}
104
int main(int argc, char *argv[])
#define NULL
Definition BinReloc.cpp:317
static const PNode * gEvalNode
static PEBLPath gPath
static PEventLoop * mEventLoop
static VariableMap gGlobalVariableMap
static FunctionMap mFunctionMap
Initiate some static member data.
void Initialize(std::list< std::string >)
Definition PEBLPath.cpp:60
Definition PNode.h:45
bool LoadSoundFile(const char *filename)