[13fb08]: libkwave / ArtsSampleSource_impl.cpp Maximize Restore History

Download this file

ArtsSampleSource_impl.cpp    62 lines (51 with data), 2.5 kB

 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
/***************************************************************************
ArtsSampleSource_impl.cpp - adapter for converting from Kwave to aRts
-------------------
begin : Nov 13 2001
copyright : (C) 2001 by Thomas Eschenbacher
email : Thomas Eschenbacher <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. *
* *
***************************************************************************/
#include "Sample.h"
#include "SampleReader.h"
#include "ArtsSampleSource_impl.h"
#include <arts/connect.h>
#include <arts/objectmanager.h>
#include <arts/flowsystem.h>
#include <arts/stdsynthmodule.h>
//***************************************************************************
ArtsSampleSource_impl::ArtsSampleSource_impl()
:ArtsSampleSource_skel(), Arts::StdSynthModule(), m_reader(0)
{
}
//***************************************************************************
ArtsSampleSource_impl::ArtsSampleSource_impl(SampleReader *rdr)
:ArtsSampleSource_skel(), Arts::StdSynthModule(), m_reader(rdr)
{
}
//***************************************************************************
void ArtsSampleSource_impl::calculateBlock(unsigned long samples)
{
unsigned long i = 0;
if (m_reader && !(m_reader->eof()) && samples) {
// fill the buffer with samples
QMemArray<sample_t> buffer(samples);
*m_reader >> buffer;
unsigned int read_samples = buffer.size();
for (i=0; i < read_samples; i++)
source[i] = sample2float(buffer[i]);
}
// pad the rest with zeroes
while (i < samples) source[i++] = 0.0;
}
//***************************************************************************
REGISTER_IMPLEMENTATION(ArtsSampleSource_impl);
//***************************************************************************
//***************************************************************************