1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
// -*-C++-*-
// This file is part of the gmod package
// Copyright (C) 1997 by Andrew J. Robinson
#ifndef SequencerH_
#define SequencerH_
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef USE_X
#include <qapp.h>
#include <qsocknot.h>
#endif
#include "Voice.h"
struct OutBuffer;
class Sample;
struct songInfo;
struct optionsInfo;
template<class T> class deque;
class Sequencer
#ifdef USE_X
: public QObject
#endif
{
#ifdef USE_X
Q_OBJECT
#endif
public:
Sequencer();
~Sequencer();
int bufferSize() const;
void close() const { ::close(seqfd_); };
int doCommand(int, int, int, int, int, songInfo *, optionsInfo *);
int doTick(int chan, int tick, songInfo *s)
{ return voices_[chan].doTick(gusDev_, tick, s); };
void doUpdates(int chan) { voices_[chan].doUpdates(gusDev_); };
void dump();
void force();
int memory() const;
void numVoices(int, int, const Sample *);
int open();
void panFactor(int factor);
int patchLoad(FILE *, int, Sample &, int &, int) const;
int read(char *) const;
void resetSamples() const;
void stopPlayback();
void sync() const;
int write();
// The following functions provide access to the sequencer voices. They
// will be removed once the sequencer does the command processing.
void mainVolume(int vol);
void globalVolSlide(int amt);
void pan(int chan, int amt) { voices_[chan].pan(amt); }
void sample(int chan, Sample *s) { voices_[chan].sample(s); }
void keyOff(int chan) { voices_[chan].keyOff(); }
void note(int chan, int n, int t) { voices_[chan].note(n, t); }
void resetEffects(int chan, int p) { voices_[chan].resetEffects(p); }
// The following function provides access to the sequencer file descriptor.
// It will be removed later.
int seqFd() const { return seqfd_; };
#ifdef USE_X
void readEnabled(bool);
void writeEnabled(bool);
#endif
private:
int gusDev_;
int numVoices_;
int seqfd_;
int songFinished_;
int synthType_;
Voice *voices_;
// bufferList is a pointer so deque.h doesn't need to be included
deque<OutBuffer *> *bufferList;
#ifdef USE_X
QSocketNotifier *writeNotifier_;
QSocketNotifier *readNotifier_;
private slots:
void writeReady();
void readReady();
#endif
};
inline void
Sequencer::globalVolSlide(int amt)
{
for (int i = 0; i < numVoices_; i++)
voices_[i].globalVolSlide(amt);
}
inline void
Sequencer::mainVolume(int vol)
{
for (int i = 0; i < numVoices_; i++)
voices_[i].mainVolume(vol);
}
inline int
Sequencer::memory() const
{
int memory;
memory = gusDev_;
ioctl(seqfd_, SNDCTL_SYNTH_MEMAVL, &memory);
return (memory);
}
inline void
Sequencer::panFactor(int factor)
{
for (int i = 0; i < numVoices_; i++)
voices_[i].panFactor(factor);
}
inline int
Sequencer::read(char *inbuf) const
{
return (::read(seqfd_, inbuf, 4));
}
#ifdef USE_X
inline void
Sequencer::readEnabled(bool status)
{
readNotifier_->setEnabled(status);
}
#endif
inline void
Sequencer::resetSamples() const
{
ioctl(seqfd_, SNDCTL_SEQ_RESETSAMPLES, &gusDev_);
}
inline void
Sequencer::sync() const
{
ioctl(seqfd_, SNDCTL_SEQ_SYNC, 0);
}
#ifdef USE_X
inline void
Sequencer::writeEnabled(bool status)
{
writeNotifier_->setEnabled(status);
}
#endif
#endif
|