1
/***************************************************************************
2
textinput.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
***************************************************************************/
17
#include "textinput.h"
20
#include "parameter.h"
22
extern Parameter settings;
25
TextInput::TextInput(int ptt = -1):Input(ptt)
28
TextInput::~TextInput()
32
/** Opens the Device for writting, for Textfiles this means write nothing ! */
33
bool TextInput::open_Device_write(QString *errorstring)
36
const char name[]="Demo.out";
37
fd=open(name,O_RDWR|O_CREAT|O_TRUNC,S_IRWXU);
42
*errorstring= QString(QObject::tr("Could not open Demo.out"));
47
/** gets the samples from the device */
48
int TextInput::getSamples(double *sample,int anzahl)
60
i= read(fd,&Buf[pos],sizeof(Buf[0]));
61
while ( (i == 1) && (Buf[pos++] != '\n') && (pos <128) );
65
qWarning("Input file has strange lines\n");
82
/** puts the Samples onto the Device, for a Textmode Device nothing happens */
83
int TextInput::putSamples(double *sample,int anzahl)
91
s.setNum(sample[i],'f',6);
92
write(fd,s.latin1(),s.length());
100
void TextInput::PTT(bool )
104
bool TextInput::open_Device_read(QString *errorstring)
106
*errorstring=QString("");
107
if (settings.inputFilename == "" )
109
*errorstring= QString(QObject::tr("Error, no Demofile selected"));
112
fd = open(settings.inputFilename,O_RDONLY);
117
*errorstring= QString(QObject::tr("Error, Could not open Demofile "));
122
bool TextInput::close_Device()