2012-07-04 17:38:18 +00:00
|
|
|
// * This file is part of the COLOBOT source code
|
|
|
|
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
|
|
|
|
// *
|
|
|
|
// * This program is free software: you can redistribute it and/or modify
|
|
|
|
// * it under the terms of the GNU General Public License as published by
|
|
|
|
// * the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// * (at your option) any later version.
|
|
|
|
// *
|
|
|
|
// * This program 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 General Public License for more details.
|
|
|
|
// *
|
|
|
|
// * You should have received a copy of the GNU General Public License
|
|
|
|
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
|
|
|
|
|
// channel.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <deque>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include <AL/al.h>
|
|
|
|
#include <AL/alc.h>
|
|
|
|
|
2012-09-26 20:57:43 +00:00
|
|
|
#include "sound/sound.h"
|
2012-07-04 17:38:18 +00:00
|
|
|
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "check.h"
|
|
|
|
|
|
|
|
struct SoundOper
|
|
|
|
{
|
|
|
|
float finalAmplitude;
|
|
|
|
float finalFrequency;
|
|
|
|
float totalTime;
|
2013-01-09 22:19:10 +00:00
|
|
|
float currentTime;
|
2012-07-04 17:38:18 +00:00
|
|
|
SoundNext nextOper;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Channel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Channel();
|
|
|
|
~Channel();
|
|
|
|
|
|
|
|
bool Play();
|
|
|
|
bool Stop();
|
2013-04-11 23:46:30 +00:00
|
|
|
|
|
|
|
bool SetPan(Math::Vector);
|
|
|
|
void SetPosition(Math::Vector);
|
|
|
|
Math::Vector GetPosition();
|
2012-07-04 17:38:18 +00:00
|
|
|
|
|
|
|
bool SetFrequency(float);
|
|
|
|
float GetFrequency();
|
|
|
|
|
|
|
|
float GetCurrentTime();
|
|
|
|
void SetCurrentTime(float);
|
|
|
|
float GetDuration();
|
|
|
|
|
|
|
|
bool SetVolume(float);
|
|
|
|
float GetVolume();
|
2013-04-11 23:46:30 +00:00
|
|
|
void SetVolumeAtrib(float);
|
|
|
|
float GetVolumeAtrib();
|
|
|
|
|
2012-07-04 17:38:18 +00:00
|
|
|
bool IsPlaying();
|
|
|
|
bool IsReady();
|
2013-01-14 21:55:16 +00:00
|
|
|
bool IsLoaded();
|
2012-07-04 17:38:18 +00:00
|
|
|
|
|
|
|
bool SetBuffer(Buffer *);
|
2013-01-14 21:55:16 +00:00
|
|
|
bool FreeBuffer();
|
|
|
|
|
2012-07-04 17:38:18 +00:00
|
|
|
bool HasEnvelope();
|
|
|
|
SoundOper& GetEnvelope();
|
|
|
|
void PopEnvelope();
|
|
|
|
|
|
|
|
int GetPriority();
|
|
|
|
void SetPriority(int);
|
|
|
|
|
|
|
|
void SetStartAmplitude(float);
|
|
|
|
void SetStartFrequency(float);
|
|
|
|
void SetChangeFrequency(float);
|
|
|
|
|
|
|
|
float GetStartAmplitude();
|
|
|
|
float GetStartFrequency();
|
|
|
|
float GetChangeFrequency();
|
|
|
|
float GetInitFrequency();
|
|
|
|
|
|
|
|
void AddOper(SoundOper);
|
|
|
|
void ResetOper();
|
|
|
|
Sound GetSoundType();
|
2013-01-14 21:55:16 +00:00
|
|
|
void SetLoop(bool);
|
2013-04-09 11:20:31 +00:00
|
|
|
void Mute(bool);
|
|
|
|
bool IsMuted();
|
2012-07-04 17:38:18 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Buffer *mBuffer;
|
|
|
|
ALuint mSource;
|
|
|
|
|
|
|
|
int mPriority;
|
|
|
|
float mStartAmplitude;
|
|
|
|
float mStartFrequency;
|
|
|
|
float mChangeFrequency;
|
|
|
|
float mInitFrequency;
|
2013-04-11 23:46:30 +00:00
|
|
|
float mVolume;
|
2012-07-04 17:38:18 +00:00
|
|
|
std::deque<SoundOper> mOper;
|
|
|
|
bool mReady;
|
2013-01-14 21:55:16 +00:00
|
|
|
bool mLoop;
|
2013-04-09 11:20:31 +00:00
|
|
|
bool mMute;
|
2013-04-11 23:46:30 +00:00
|
|
|
Math::Vector mPosition;
|
2012-07-04 17:38:18 +00:00
|
|
|
};
|