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

« back to all changes in this revision

Viewing changes to libecasound/oscillator.h

  • 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
#ifndef INCLUDED_OSCILLATOR_H
 
2
#define INCLUDED_OSCILLATOR_H
 
3
 
 
4
#include <cmath>
 
5
#include <string>
 
6
 
 
7
#include "ctrl-source.h"
 
8
 
 
9
/**
 
10
 * Base class for various oscillators
 
11
 *
 
12
 * Unlike finite controller sources, oscillators
 
13
 * produce new values infinately.
 
14
 */
 
15
class OSCILLATOR : public CONTROLLER_SOURCE {
 
16
 
 
17
 public:
 
18
 
 
19
  virtual void set_initial_value(parameter_t arg) {}
 
20
 
 
21
  /**
 
22
   * Constructor
 
23
   * 
 
24
   * @param freq Oscillator frequency
 
25
   * @param phase Initial phase, multiple of pi
 
26
   */
 
27
  OSCILLATOR(parameter_t freq = 0, parameter_t initial_phase = 0) { 
 
28
    freq_value = freq;
 
29
    phase_value = initial_phase * M_PI;
 
30
  }
 
31
 
 
32
 private:
 
33
  
 
34
  parameter_t freq_value, phase_value;
 
35
 
 
36
 protected:
 
37
 
 
38
  parameter_t phase_offset(void) const { return(phase_value); }  
 
39
  parameter_t frequency(void) const { return(freq_value); }
 
40
 
 
41
  void phase_offset(parameter_t v) { phase_value = v; }
 
42
  void frequency(parameter_t v) { freq_value = v; }
 
43
};
 
44
 
 
45
#endif