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

« back to all changes in this revision

Viewing changes to libecasound/eca-audio-time.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2008-03-23 21:42:49 UTC
  • mfrom: (3.1.6 hardy)
  • Revision ID: james.westby@ubuntu.com-20080323214249-evlfv3y1o8q747la
Tags: 2.4.6.1-2
* Bug fix: "FTBFS with GCC 4.3: missing #includes", thanks to Martin
  Michlmayr (Closes: #454890).
- 13_gcc4: updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// ------------------------------------------------------------------------
2
2
// eca-audio-time.cpp: Generic class for representing time in audio 
3
3
//                     environment.
4
 
// Copyright (C) 2000 Kai Vehmanen
 
4
// Copyright (C) 2000,2007 Kai Vehmanen
 
5
//
 
6
// Attributes:
 
7
//     eca-style-version: 3
5
8
//
6
9
// This program is free software; you can redistribute it and/or modify
7
10
// it under the terms of the GNU General Public License as published by
18
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
19
22
// ------------------------------------------------------------------------
20
23
 
 
24
#include <cstdlib>
21
25
#include <cstdio>
22
26
#include <cmath>
23
27
 
73
77
 *
74
78
 * Note, this can change the value of seconds().
75
79
 */
76
 
void ECA_AUDIO_TIME::set_samples(SAMPLE_SPECS::sample_pos_t samples) { samples_rep = samples; } 
 
80
void ECA_AUDIO_TIME::set_samples(SAMPLE_SPECS::sample_pos_t samples)
 
81
{
 
82
  samples_rep = samples;
 
83
}
77
84
 
78
85
/**
79
86
 * Sets samples per second.
107
114
    {
108
115
    case format_hour_min_sec: 
109
116
      { 
110
 
        return("");
 
117
        return "";
111
118
      }
112
119
    case format_min_sec: 
113
120
      {
114
 
        return("");
 
121
        return "";
115
122
      }
116
123
    case format_seconds: { return(kvu_numtostr(seconds(), 3)); }
117
124
    case format_samples: { return(kvu_numtostr(samples_rep)); }
118
125
 
119
126
    default: { }
120
127
    }
121
 
  return("");
 
128
 
 
129
  return "";
122
130
}
123
131
 
124
132
double ECA_AUDIO_TIME::seconds(void) const
125
133
{
126
 
  return(static_cast<double>(samples_rep) / sample_rate_rep);
127
 
}
128
 
 
129
 
SAMPLE_SPECS::sample_rate_t ECA_AUDIO_TIME::samples_per_second(void) const  { return(sample_rate_rep); }
130
 
SAMPLE_SPECS::sample_pos_t ECA_AUDIO_TIME::samples(void) const { return(samples_rep); }
 
134
  return static_cast<double>(samples_rep) / sample_rate_rep;
 
135
}
 
136
 
 
137
SAMPLE_SPECS::sample_rate_t ECA_AUDIO_TIME::samples_per_second(void) const
 
138
{
 
139
  return sample_rate_rep;
 
140
}
 
141
 
 
142
SAMPLE_SPECS::sample_pos_t ECA_AUDIO_TIME::samples(void) const
 
143
{
 
144
  return samples_rep;
 
145
}