~ubuntu-branches/ubuntu/feisty/ecasound2.2/feisty

« back to all changes in this revision

Viewing changes to libecasound/stamp-ctrl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2005-04-14 09:15:48 UTC
  • Revision ID: james.westby@ubuntu.com-20050414091548-o7kgb47z0tcunh0s
Tags: upstream-2.4.1
ImportĀ upstreamĀ versionĀ 2.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ------------------------------------------------------------------------
 
2
// stamp-ctrl.cpp: Controller sources that analyze audio stamps
 
3
//                 and produce control data.
 
4
// Copyright (C) 2000,2001 Kai Vehmanen
 
5
//
 
6
// This program is fre software; you can redistribute it and/or modify
 
7
// it under the terms of the GNU General Public License as published by
 
8
// the Free Software Foundation; either version 2 of the License, or
 
9
// (at your option) any later version.
 
10
// 
 
11
// This program is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
// GNU General Public License for more details.
 
15
// 
 
16
// You should have received a copy of the GNU General Public License
 
17
// along with this program; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 
19
// ------------------------------------------------------------------------
 
20
 
 
21
#include "samplebuffer_functions.h"
 
22
#include "stamp-ctrl.h"
 
23
 
 
24
VOLUME_ANALYZE_CONTROLLER::VOLUME_ANALYZE_CONTROLLER(void)
 
25
{
 
26
}
 
27
 
 
28
CONTROLLER_SOURCE::parameter_t VOLUME_ANALYZE_CONTROLLER::value(void)
 
29
{
 
30
  fetch_stamp(&sbuf_rep);
 
31
  parameter_t v = 0.0f;
 
32
  if (rms_mode_rep != 0) 
 
33
    v = SAMPLE_BUFFER_FUNCTIONS::RMS_volume(sbuf_rep);
 
34
  else
 
35
    v = SAMPLE_BUFFER_FUNCTIONS::average_amplitude(sbuf_rep);
 
36
  if (!(v > 0.0f)) v = 0.0f;
 
37
  // cerr << "(volume-analyze-ctrl) Fetches a sbuf with value " << v  << endl;
 
38
  return(v);
 
39
}
 
40
 
 
41
void VOLUME_ANALYZE_CONTROLLER::init(void)
 
42
{
 
43
}
 
44
 
 
45
void VOLUME_ANALYZE_CONTROLLER::set_parameter(int param, CONTROLLER_SOURCE::parameter_t value)
 
46
{
 
47
  switch (param) {
 
48
  case 1: 
 
49
    set_id(static_cast<int>(value));
 
50
    break;
 
51
 
 
52
  case 2: 
 
53
    rms_mode_rep = static_cast<int>(value);
 
54
    break;
 
55
 
 
56
  }
 
57
}
 
58
 
 
59
CONTROLLER_SOURCE::parameter_t VOLUME_ANALYZE_CONTROLLER::get_parameter(int param) const
 
60
{
 
61
  switch (param) {
 
62
  case 1: 
 
63
    return(static_cast<parameter_t>(id()));
 
64
 
 
65
  case 2: 
 
66
    return(static_cast<parameter_t>(rms_mode_rep));
 
67
  }
 
68
  return(0.0);
 
69
}