1
// ------------------------------------------------------------------------
2
// audio-stamp.cpp: Classes for handling audio stamps and their clients
3
// Copyright (C) 2000 Kai Vehmanen
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
// ------------------------------------------------------------------------
20
#include "audio-stamp.h"
22
AUDIO_STAMP::AUDIO_STAMP(void)
26
int AUDIO_STAMP::id(void) const { return(id_rep); }
28
void AUDIO_STAMP::set_id(int n) {
33
void AUDIO_STAMP::store(const SAMPLE_BUFFER* x) {
34
buffer_rep.length_in_samples(x->length_in_samples());
35
buffer_rep.number_of_channels(x->number_of_channels());
39
void AUDIO_STAMP::fetch_stamp(SAMPLE_BUFFER* x) {
40
x->length_in_samples(buffer_rep.length_in_samples());
41
x->number_of_channels(buffer_rep.number_of_channels());
45
void AUDIO_STAMP_SERVER::register_stamp(AUDIO_STAMP* stamp) {
46
stamp_map_rep[stamp->id()] = stamp;
49
void AUDIO_STAMP_SERVER::fetch_stamp(int id, SAMPLE_BUFFER* x) {
50
if (stamp_map_rep.find(id) == stamp_map_rep.end()) {
52
// std::cerr << "(as-server) Making silent!" << std::endl;
55
AUDIO_STAMP* p = stamp_map_rep[id];
57
// cerr << "(as-server) fetch stamp from id " << p->id() << "." << endl;
61
AUDIO_STAMP_CLIENT::AUDIO_STAMP_CLIENT(void)
66
int AUDIO_STAMP_CLIENT::id(void) const { return(id_rep); }
68
void AUDIO_STAMP_CLIENT::set_id(int n) {
73
void AUDIO_STAMP_CLIENT::fetch_stamp(SAMPLE_BUFFER* x) {
74
if (server_repp != 0) {
75
server_repp->fetch_stamp(id(), x);
76
// cerr << "(as-client) fetch stamp id " << id() << "." << endl;
79
// cerr << "(as-client) Making silent!" << endl;
84
void AUDIO_STAMP_CLIENT::register_server(AUDIO_STAMP_SERVER* server) {