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

« back to all changes in this revision

Viewing changes to libecasound/generic-linear-envelope.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2007-02-04 11:32:59 UTC
  • mfrom: (2.1.7 feisty)
  • Revision ID: james.westby@ubuntu.com-20070204113259-uthtjkh4t90fyukk
Tags: 2.4.4-6
Bug fix: "libecasound2.2-dev: missing dependency on libasound2-dev",
thanks to Steve Langasek (Closes: #409438).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// ------------------------------------------------------------------------
2
2
// generic-linear-envelope.cpp: Generic linear envelope
3
 
// Copyright (C) 2000-2002 Kai Vehmanen
 
3
// Copyright (C) 2000-2002,2006 Kai Vehmanen
4
4
// Copyright (C) 2001 Arto Hamara
5
5
//
 
6
// Attributes:
 
7
//     eca-style-version: 3
 
8
//
6
9
// This program is fre software; you can redistribute it and/or modify
7
10
// it under the terms of the GNU General Public License as published by
8
11
// the Free Software Foundation; either version 2 of the License, or
37
40
{
38
41
  pos_rep.resize(1);
39
42
  val_rep.resize(1);
40
 
  pos_rep[0] = 1;
 
43
  curstage = -2; /* processing not yet started */
 
44
  pos_rep[0] = 0;
41
45
  val_rep[0] = 0;
42
46
  set_param_count(0);
43
47
49
53
CONTROLLER_SOURCE::parameter_t GENERIC_LINEAR_ENVELOPE::value(void)
50
54
{
51
55
  parameter_t curpos = position_in_seconds_exact();
52
 
  if (curpos < pos_rep[0]) {
 
56
  if (curpos < pos_rep[0] || curstage == -2) {
 
57
    /* not reached the first position yet, or processing not 
 
58
       started yet */
53
59
    curval = val_rep[0];
54
60
  } else if (curstage < static_cast<int>(pos_rep.size())-1) {
55
61
    if (curpos >= pos_rep[curstage+1]) {
76
82
                       << ", curval " << curval
77
83
                       << ", curstage " << curstage << "." << std::endl);
78
84
  
79
 
  return(curval);
 
85
  return curval;
80
86
81
87
 
82
88
void GENERIC_LINEAR_ENVELOPE::init(void)
83
89
{
84
90
  curval = 0.0f;
85
 
  curstage = -1;
 
91
  curstage = -1; /* processing started */
86
92
  
87
 
  ECA_LOG_MSG(ECA_LOGGER::info, "(generic-linear-envelope) Envelope created.");
 
93
  ECA_LOG_MSG(ECA_LOGGER::info, "Envelope created.");
88
94
}
89
95
 
90
96
void GENERIC_LINEAR_ENVELOPE::set_param_count(int params)
91
97
{
92
 
    param_names_rep = "point_count";
93
 
    if (params > 0) {
94
 
        for(int n = 0; n < params; ++n) {
95
 
            param_names_rep += ",pos";
96
 
            param_names_rep += kvu_numtostr(n + 1);
97
 
            param_names_rep += ",val";
98
 
            param_names_rep += kvu_numtostr(n + 1);
99
 
        }
 
98
  param_names_rep = "point_count";
 
99
  if (params > 0) {
 
100
    for(int n = 0; n < params; ++n) {
 
101
      param_names_rep += ",pos";
 
102
      param_names_rep += kvu_numtostr(n + 1);
 
103
      param_names_rep += ",val";
 
104
      param_names_rep += kvu_numtostr(n + 1);
100
105
    }
 
106
  }
101
107
}
102
108
 
103
109
std::string GENERIC_LINEAR_ENVELOPE::parameter_names(void) const 
104
110
{
105
 
    return(param_names_rep);
 
111
  return param_names_rep;
106
112
}
107
113
 
108
114
void GENERIC_LINEAR_ENVELOPE::set_parameter(int param, parameter_t value)
126
132
{
127
133
  switch(param) {
128
134
  case 1:
129
 
    return(static_cast<parameter_t>(pos_rep.size()));
 
135
    return static_cast<parameter_t>(pos_rep.size());
130
136
    break;
131
137
  default:
132
138
    int pointnum = param/2 - 1;