~kulthauskante/nsynth/devel

« back to all changes in this revision

Viewing changes to Base/Metronome/GlobalMetronome.h

  • Committer: Karsten Krispin
  • Date: 2011-04-26 15:34:14 UTC
  • Revision ID: karsten@nonlimited.org-20110426153414-c4bsiry51d0s099n
- added SampleWidget (specialized version for SampleTangible )
- added DurationTab (which lets you select a duration in fractions to the main beat )
- Sequencers Step Duration is now selectable by DurationTab
- Sequencer now heads to the right sink
- replaced QList<qreal> by Delay in Tangible/Trigger History-Buffer (List were causing segfaults sometimes)
- Distorion now does "real" distorion
- Cleaned up TabContainerWidget (some polishing in display as well)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef INCLUDED_SYNTH_METRONOME_H
2
2
#define INCLUDED_SYNTH_METRONOME_H
3
3
 
 
4
/** Beats per cycle */
 
5
#define METRONOME_BPC 96.0
 
6
 
4
7
#include <QtCore/QtCore>
5
8
#include "Helper/Oscillator.h"
6
9
 
28
31
        protected:
29
32
                double __frequencyFromLinear(double lin);
30
33
 
 
34
 
 
35
                /** calculates current given for a beat given by fraction */
 
36
                inline qreal __phase(qreal fraction, int offset)
 
37
                {
 
38
                        /* multiply by 4 because global beat is 4 times slower than actually provided by BPM */
 
39
                        return ((((m_samples-m_offset+offset) % m_samplesPerBeat)/qreal(m_samplesPerBeat))*METRONOME_BPC)/fraction;
 
40
                }
 
41
 
31
42
        public:
32
43
    GlobalMetronome();
33
44
                virtual ~GlobalMetronome();
63
74
                 * @returns phase from 0.0 to 1.0
64
75
                 * @example phase(1.0/3.0) returns phase regarding 1/3 notes
65
76
                 */
66
 
                static qreal phase(qreal fraction = 1.0);
 
77
                static qreal phase(qreal fraction = 1.0, int offset = 0);
 
78
 
 
79
 
 
80
                /** @brief decides whether in current hop the beat leaps
 
81
                 * @param fraction see phase()
 
82
                 * @returns -1 if in current hop no leap of beat will occour, else return the sample in hop.
 
83
                 */
 
84
                static int isBeatLeaping(qreal fraction = 1.0);
67
85
 
68
86
                /** @returns number of overall processed samples */
69
87
                static int samples() { return instance().m_samples; }