PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PAudioOut.h
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/devices/PAudioOut.h
4// Purpose: Controls sound presentation (but not recording).
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003-2026 Shane T. Mueller <smueller@obereed.net>
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#ifndef __PAUDIOOUT_H__
28#define __PAUDIOOUT_H__
29#include "PDevice.h"
30#include <string>
31
32
38
39class PAudioOut: public PDevice
40{
41 public:
42 PAudioOut();
43 PAudioOut(const std::string & filename);
44 virtual ~PAudioOut();
45
46
47 virtual bool LoadSoundFile(const std::string & filename){return false;};
48
49 virtual bool Play(){return false;};
50 virtual bool PlayForeground(){return false;};
51 virtual bool Stop(){return false;};
52 virtual bool SetPanning(const double left,const double right){return false;};
53 //A PAudioOut has a tunable amplitude parameter. Set to 100
54 //to get the 'real' volume of the file; adjust up or down as needed.
55 //Will not avoid clipping.
56
57 //virtual int GetAmplitude(){return 0;};
58 //virtual void SetAmplitude(int ){};
59
60 virtual bool Initialize(){return false;};
61
62 //These are mainly for programatically-generated sound buffers
63 //(see below).
64 // void SetSampleRate(long int);
65 // long int GetSampleRate();
66
67
68
69 //Programatically-generated sound buffers. No file needed.
70 virtual bool CreateSineWave(float freq, long unsigned int length, long double volume){
71 float x = freq;
72 long unsigned int xx = length;
73 long double xxx =volume;return false;};
74 //virtual bool CreateSquareWave(float freq, double length, int amplitude);
75 //virtual bool CreateSawtoothWave(float freq, double length, int amplitude);
76
78
79private:
80
81protected:
82 unsigned int mSampleRate;
83 int mChannel; //index of channel to use--for mixer
84 long double mAmplitudeLeft; //left; between 0 and 1
85 long double mAmplitudeRight; //right; between 0 and 1
86
87 // int mFileName;
88};
89
90
91#endif
PEBL_DEVICE_TYPE
Definition PDevice.h:40
@ PDT_AUDIO_OUT
Definition PDevice.h:51
virtual bool PlayForeground()
Definition PAudioOut.h:50
virtual PEBL_DEVICE_TYPE GetDeviceType()
Definition PAudioOut.h:77
virtual bool CreateSineWave(float freq, long unsigned int length, long double volume)
Definition PAudioOut.h:70
virtual ~PAudioOut()
Definition PAudioOut.cpp:13
virtual bool Stop()
Definition PAudioOut.h:51
virtual bool Play()
Definition PAudioOut.h:49
virtual bool SetPanning(const double left, const double right)
Definition PAudioOut.h:52
virtual bool Initialize()
Definition PAudioOut.h:60
unsigned int mSampleRate
Definition PAudioOut.h:82
long double mAmplitudeRight
Definition PAudioOut.h:85
long double mAmplitudeLeft
Definition PAudioOut.h:84
int mChannel
Definition PAudioOut.h:83
virtual bool LoadSoundFile(const std::string &filename)
Definition PAudioOut.h:47