1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/***************************************************************************
Osc.h - simple sine oscillator
-------------------
begin : Tue Nov 06 2007
copyright : (C) 2007 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef OSC_H
#define OSC_H
#include "config.h"
#include "libkwave_export.h"
#include <QtGlobal>
#include <QObject>
#include <QVariant>
#include "libkwave/SampleSource.h"
namespace Kwave
{
class LIBKWAVE_EXPORT Osc: public Kwave::SampleSource
{
Q_OBJECT
public:
/** Constructor */
Osc();
/** Destructor */
~Osc() override;
/** does the calculation */
void goOn() override;
signals:
/** emits a block with sine wave data */
void output(Kwave::SampleArray data);
public slots:
/**
* Sets the frequency of the sine wave, normed to the
* sample frequency. You should pass the frequency that
* you want, divided through the sample frequency.
* If you never call this, the frequency will be undefined!
*/
void setFrequency(const QVariant &f);
/**
* Sets the phase of the sine wave in RAD [0...2*Pi].
* The default setting is zero.
*/
void setPhase(const QVariant &p);
/**
* Sets the amplitude of the sine wave, normed to the
* range of [0.0 ... 1.0]. The default is 1.0.
*/
void setAmplitude(const QVariant &a);
private:
/** buffer for output data */
Kwave::SampleArray m_buffer;
/** current time multiplied by 2*Pi*f */
double m_omega_t;
/** frequency [samples/period] */
double m_f;
/** amplitude [0...1] */
double m_a;
};
}
#endif /* OSC_H */
//***************************************************************************
//***************************************************************************
|