~ubuntu-branches/ubuntu/wily/ecasound/wily-proposed

« back to all changes in this revision

Viewing changes to libecasound/linear-envelope.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghedini
  • Date: 2011-05-12 17:58:03 UTC
  • Revision ID: james.westby@ubuntu.com-20110512175803-zy3lodjecabt9r3v
Tags: upstream-2.8.0
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ------------------------------------------------------------------------
 
2
// linear-envelope.cpp: Linear envelope
 
3
// Copyright (C) 1999-2002,2005,2008 Kai Vehmanen
 
4
//
 
5
// Attributes:
 
6
//     eca-style-version: 3 (see Ecasound Programmer's Guide)
 
7
//
 
8
// This program is fre software; you can redistribute it and/or modify
 
9
// it under the terms of the GNU General Public License as published by
 
10
// the Free Software Foundation; either version 2 of the License, or
 
11
// (at your option) any later version.
 
12
// 
 
13
// This program is distributed in the hope that it will be useful,
 
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
// GNU General Public License for more details.
 
17
// 
 
18
// You should have received a copy of the GNU General Public License
 
19
// along with this program; if not, write to the Free Software
 
20
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 
21
// ------------------------------------------------------------------------
 
22
 
 
23
#include <kvu_dbc.h>
 
24
#include <kvu_numtostr.h>
 
25
#include <kvu_message_item.h>
 
26
 
 
27
#include "linear-envelope.h"
 
28
#include "eca-logger.h"
 
29
 
 
30
LINEAR_ENVELOPE::LINEAR_ENVELOPE(void)
 
31
{
 
32
 
33
 
 
34
LINEAR_ENVELOPE::~LINEAR_ENVELOPE(void)
 
35
{
 
36
}
 
37
 
 
38
CONTROLLER_SOURCE::parameter_t LINEAR_ENVELOPE::value(double pos)
 
39
{
 
40
  parameter_t retval;
 
41
 
 
42
  /* note: position may go beyond stages_len_rep */
 
43
 
 
44
  if (pos < stages_len_rep) {
 
45
    retval = (pos / stages_len_rep);
 
46
  }
 
47
  else 
 
48
    retval = 1.0f;
 
49
 
 
50
  return retval;
 
51
}
 
52
 
 
53
void LINEAR_ENVELOPE::init(void)
 
54
{
 
55
  MESSAGE_ITEM otemp;
 
56
  otemp << "Linear enveloped initialized; length ";
 
57
  otemp.setprecision(3);
 
58
  otemp << stages_len_rep;
 
59
  otemp << " seconds.";
 
60
  ECA_LOG_MSG(ECA_LOGGER::user_objects, otemp.to_string());
 
61
}
 
62
 
 
63
void LINEAR_ENVELOPE::set_parameter(int param, CONTROLLER_SOURCE::parameter_t value)
 
64
{
 
65
  switch (param) {
 
66
  case 1:
 
67
    stages_len_rep = value;
 
68
    break;
 
69
  }
 
70
}
 
71
 
 
72
CONTROLLER_SOURCE::parameter_t LINEAR_ENVELOPE::get_parameter(int param) const
 
73
{
 
74
  switch (param) {
 
75
  case 1:
 
76
    return stages_len_rep;
 
77
  }
 
78
  return 0.0;
 
79
}