-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalsasoundcard.h
69 lines (64 loc) · 1.89 KB
/
alsasoundcard.h
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
/** ===========================================================
* @file
*
* This file is a part of pcro project
* <a href="https://github.com/maheshmhegade/pcro">https://github.com/maheshmhegade/pcro</a>
*
* @date 2010-03-03
* @brief pcro using pc as signal generator.
* @section DESCRIPTION
*
* Using ALSA to output digital data as analogue sound which is standard a mathematical function.
*
* @author Copyright (C) 2012-2013 by Mahesh Hegde
* <a href="mailto:maheshmhegade at gmail dot com">maheshmhegade at gmail dot com</a>
*
* @section LICENSE
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include <QVector>
#ifndef ALSASOUNDCARD_H
#define ALSASOUNDCARD_H
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <alsa/asoundlib.h>
using namespace std;
class outputWave {
public:
outputWave()
{
}
QVector<double> waveSamples;
int samplingFrequency;
int waveFrequency;
int waveDuration;
int waveAmplitude;
~outputWave();
};
class alsaSoundcard
{
public:
snd_pcm_t *playback_handle;
alsaSoundcard();
int initSoundcard();
void generateSin(outputWave *wave);
void generateCos(outputWave *wave);
void generateTriangular(outputWave *wave);
void generateRamp(outputWave *wave);
void generateSquare(outputWave *wave);
void playBack(outputWave *wave);
};
#endif // ALSASOUNDCARD_H