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
|
/*************************************************************************
NoiseGenerator.h - simple noise generator, implemented as SampleSource
-------------------
begin : Sun Oct 07 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 NOISE_GENERATOR_H
#define NOISE_GENERATOR_H
#include "config.h"
#include <QObject>
#include <QRandomGenerator>
#include <QVariant>
#include "libkwave/SampleArray.h"
#include "libkwave/SampleSource.h"
namespace Kwave
{
class NoiseGenerator: public Kwave::SampleSource
{
Q_OBJECT
public:
/** Constructor */
explicit NoiseGenerator(QObject *parent = nullptr);
/** Destructor */
~NoiseGenerator() override;
/**
* produces a block of noise,
* @see Kwave::SampleSource::goOn()
*/
void goOn() override;
signals:
/** emits a block with noise */
void output(Kwave::SampleArray data);
public slots:
/** receives input data */
void input(Kwave::SampleArray data);
/**
* Sets the noise level as a factor [0 .. 1.0]
*/
void setNoiseLevel(const QVariant fc);
private:
/** random generator for the noise */
QRandomGenerator m_random;
/** buffer for input */
Kwave::SampleArray m_buffer;
/** noise level [0 .. 1.0] */
double m_noise_level;
};
}
#endif /* NOISE_GENERATOR_H */
//***************************************************************************
//***************************************************************************
|