PEBL
2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
portaudio/PlatformAudioOut.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/platforms/sdl/PlatformAudioOut.h
4
// Purpose: Contains platform-specific sound playing routines
5
// Author: Shane T. Mueller, Ph.D.
6
// Copyright: (c) 2003-2026 Shane T. Mueller <smueller@obereed.ned>
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 __PLATFORMAUDIOOUT_H__
28
#define __PLATFORMAUDIOOUT_H__
29
30
#include "../../devices/PAudioOut.h"
31
#include "portaudio.h"
32
33
struct
AudioInfo
{
34
SDL_AudioSpec
spec
;
35
Uint8 *
audio
;
/* Pointer to wave data */
36
Uint32
audiolen
;
/* Length of wave data */
37
int
audiopos
;
/* Current play position */
38
int
volume
;
/* Relative volume. 0-100*/
39
};
40
41
class
PlatformAudioOut
:
public
PAudioOut
42
{
43
public
:
44
PlatformAudioOut
();
45
PlatformAudioOut
(
const
char
* filename);
46
~PlatformAudioOut
();
47
48
bool
LoadSoundFile
(
const
char
* filename);
49
50
bool
CreateSineWave
(
float
freq,
double
length,
int
amplitude);
51
bool
CreateSquareWave
(
float
freq,
double
length,
int
amplitude);
52
bool
CreateSawtoothWave
(
float
freq,
double
length,
int
amplitude);
53
bool
CreateChirp
();
54
55
bool
Play
();
56
bool
PlayForeground
();
57
bool
Stop
();
58
59
60
bool
Initialize
();
61
62
void
AddTrack
(
char
* handle,
AudioInfo
track);
63
void
RemoveTrack
(
char
* handle);
64
65
Uint8 *
MixTracks
();
66
67
68
private
:
69
70
71
friend
void
PlayCallBack
(
void
* dummy, Uint8 * stream,
int
len);
72
73
bool
mLoaded;
//This will be true when a file
74
//has been loaded or a buffer has been
75
//generated.
76
AudioInfo
mWave;
77
};
78
79
80
#endif
PAudioOut
Definition
PAudioOut.h:40
PlatformAudioOut
Definition
PlatformAudio.h:42
PlatformAudioOut::CreateSawtoothWave
bool CreateSawtoothWave(float freq, double length, int amplitude)
PlatformAudioOut::PlayForeground
bool PlayForeground()
PlatformAudioOut::CreateChirp
bool CreateChirp()
PlatformAudioOut::Play
bool Play()
PlatformAudioOut::PlatformAudioOut
PlatformAudioOut(const char *filename)
PlatformAudioOut::AddTrack
void AddTrack(char *handle, AudioInfo track)
PlatformAudioOut::Stop
bool Stop()
PlatformAudioOut::PlatformAudioOut
PlatformAudioOut()
PlatformAudioOut::CreateSineWave
bool CreateSineWave(float freq, double length, int amplitude)
PlatformAudioOut::CreateSquareWave
bool CreateSquareWave(float freq, double length, int amplitude)
PlatformAudioOut::MixTracks
Uint8 * MixTracks()
PlatformAudioOut::LoadSoundFile
bool LoadSoundFile(const char *filename)
PlatformAudioOut::Initialize
bool Initialize()
PlatformAudioOut::PlayCallBack
friend void PlayCallBack(void *dummy, Uint8 *stream, int len)
Definition
portaudio/PlatformAudioOut.cpp:160
PlatformAudioOut::~PlatformAudioOut
~PlatformAudioOut()
PlatformAudioOut::RemoveTrack
void RemoveTrack(char *handle)
AudioInfo
Definition
PlatformAudio.h:33
AudioInfo::audio
Uint8 * audio
Definition
PlatformAudio.h:35
AudioInfo::spec
SDL_AudioSpec spec
Definition
PlatformAudio.h:34
AudioInfo::audiolen
Uint32 audiolen
Definition
PlatformAudio.h:36
AudioInfo::audiopos
int audiopos
Definition
PlatformAudio.h:37
AudioInfo::volume
int volume
Definition
PlatformAudio.h:38
src
platforms
portaudio
PlatformAudioOut.h
Generated by
1.9.8