~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to audiomix.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//=========================================================
2
 
//  MusE
3
 
//  Linux Music Editor
4
 
//  $Id: audiomix.cpp,v 1.1 2002/01/30 14:54:03 muse Exp $
5
 
//
6
 
//  (C) Copyright 2000 Werner Schweer (ws@seh.de)
7
 
//=========================================================
8
 
 
9
 
#include "audiomix.h"
10
 
#include "globals.h"
11
 
#include "xml.h"
12
 
 
13
 
#define MIN(a,b) (a)>(b)?(b):(a)
14
 
 
15
 
//---------------------------------------------------------
16
 
//   AudioFifo
17
 
//---------------------------------------------------------
18
 
 
19
 
void AudioFifo::setup(int buffers, int bsize)
20
 
      {
21
 
      if (data) {
22
 
            for (int i = 0; i < size; ++i)
23
 
                  delete data[i];
24
 
            delete data;
25
 
            }
26
 
      head = tail = used = 0;
27
 
      size = buffers;
28
 
      data = new float*[size];
29
 
      for (int i = 0; i < size; ++i)
30
 
            data[i] = new float[bsize];
31
 
      }
32
 
 
33
 
//---------------------------------------------------------
34
 
//   ~AudioFifo
35
 
//---------------------------------------------------------
36
 
 
37
 
AudioFifo::~AudioFifo()
38
 
      {
39
 
      if (data) {
40
 
            for (int i = 0; i < size; ++i)
41
 
                  delete data[i];
42
 
            delete data;
43
 
            }
44
 
      }
45
 
 
46
 
//---------------------------------------------------------
47
 
//   getFreeBuffer
48
 
//---------------------------------------------------------
49
 
 
50
 
float* AudioFifo::getFreeBuffer()
51
 
      {
52
 
      if (used == size)
53
 
            return 0;
54
 
      return data[tail];
55
 
      }
56
 
 
57
 
//---------------------------------------------------------
58
 
//   writeBuffer
59
 
//---------------------------------------------------------
60
 
 
61
 
void AudioFifo::writeBuffer()
62
 
      {
63
 
      ++tail;
64
 
      tail %= size;
65
 
      ++used;
66
 
      }
67
 
 
68
 
//---------------------------------------------------------
69
 
//   fillBuffer
70
 
//---------------------------------------------------------
71
 
 
72
 
void AudioFifo::getData(float* buffer, int /*idx*/)
73
 
     {
74
 
     int n = sizeof(float) * channels() * segmentSize;
75
 
      if (used == 0) {
76
 
            printf("AudioFifo::getData(): underrun\n");
77
 
            memset(buffer, 0, n);
78
 
            return;
79
 
            }
80
 
      memcpy(buffer, data[head], n);
81
 
      ++head;
82
 
      head %= size;
83
 
      --used;
84
 
      }
85
 
 
86
 
//---------------------------------------------------------
87
 
//   AudioMixer
88
 
//---------------------------------------------------------
89
 
 
90
 
AudioMixer::AudioMixer()
91
 
      {
92
 
      }
93
 
 
94
 
//---------------------------------------------------------
95
 
//   ~AudioMixer
96
 
//---------------------------------------------------------
97
 
 
98
 
AudioMixer::~AudioMixer()
99
 
      {
100
 
      }
101
 
 
102
 
//---------------------------------------------------------
103
 
//   getData
104
 
//    mixing
105
 
//---------------------------------------------------------
106
 
 
107
 
void AudioMixer::getData(float* buffer, int idx)
108
 
      {
109
 
      memset(buffer, 0, channels() * segmentSize * sizeof(float));
110
 
      for (iAudioNode i = inputs.begin(); i != inputs.end(); ++i)
111
 
            (*i)->fillBuffer(channels(), buffer, idx);
112
 
      }
113
 
 
114
 
//---------------------------------------------------------
115
 
//   connect
116
 
//    add audio source to mixer object
117
 
//---------------------------------------------------------
118
 
 
119
 
void AudioMixer::connect(AudioNode* as)
120
 
      {
121
 
      if (as == 0)
122
 
            return;
123
 
      for (iAudioNode src = inputs.begin(); src != inputs.end(); ++src) {
124
 
            if (*src == as)
125
 
                  return;
126
 
            }
127
 
      inputs.push_back(as);
128
 
      }
129
 
 
130
 
//---------------------------------------------------------
131
 
//   removeSource
132
 
//    remove audio source from mixer object
133
 
//---------------------------------------------------------
134
 
 
135
 
void AudioMixer::disconnect(AudioNode* as)
136
 
      {
137
 
      for (iAudioNode src = inputs.begin(); src != inputs.end(); ++src) {
138
 
            if (*src == as) {
139
 
                  inputs.erase(src);
140
 
                  return;
141
 
                  }
142
 
            }
143
 
      printf("AudioMixer::disconnect(): not found\n");
144
 
      }