1
/***************************************************************************
2
waveinput.cpp - description
5
copyright : (C) 2001 by Volker Schroer
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* based on the work of Moe Wheatly, AE4JY *
16
***************************************************************************/
18
#include "waveinput.h"
20
WaveInput::WaveInput(int ptt = -1): Input(ptt)
23
WaveInput::~WaveInput(){
26
/** Opens the Device for writting, for Wavefiles this means write nothing ! */
27
bool WaveInput::open_Device_write(QString Device)
32
/** puts the Samples onto the Device, for a Wavemode Device nothing happens */
33
int WaveInput::putSamples(double *sample,int anzahl)
39
void WaveInput::PTT(bool mode)
43
bool WaveInput::setParams(QString *errorstring)
48
/** Opens the Device named Device for reading */
50
bool WaveInput::open_Device_read(QString Device)
56
fd = open(Device,O_RDONLY);
60
i =read(fd,&header[0],4*sizeof(header[0]));
64
qWarning("Header mismatch\n");
73
qWarning(Device + " is not a RIFF File\n");
79
i =read(fd,&header[0],4*sizeof(header[0]));
84
qWarning("SubType mismatch\n");
92
qWarning(Device + " is not a WAVE File\n");
97
i=read(fd,&header[0],4*sizeof(header[0]));
101
qWarning("No data found\n");
107
while( ( s != "data" ) && (i > 0) )
110
s.remove(0,1); // remove first character
111
s += c; // append new one
115
offset = lseek(fd,4,SEEK_CUR);
116
lseek(fd,offset,SEEK_SET); //Remove 4 bytes length info
122
qWarning("No data found\n");
128
int WaveInput::getSamples(double *sample,int anzahl)
137
i= read(fd,&c[0],2*sizeof(c[0]));
141
i = c[0]+ c[1]* 256 ;
143
i = ( c[1]- 256) *256 +c[0];
152
lseek(fd,offset,SEEK_SET);