3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
42 |
|
|
43 |
// refill the disk stream buffer |
// refill the disk stream buffer |
44 |
if (this->DoLoop) { // honor looping |
if (this->DoLoop) { // honor looping |
45 |
total_readsamples = pSample->ReadAndLoop(pBuf, samplestoread, &this->PlaybackState); |
total_readsamples = pSample->ReadAndLoop(pBuf, samplestoread, &this->PlaybackState, pDecompressionBuffer); |
46 |
endofsamplereached = (this->PlaybackState.position >= pSample->SamplesTotal); |
endofsamplereached = (this->PlaybackState.position >= pSample->SamplesTotal); |
47 |
dmsg(5,("Refilled stream %d with %d (SamplePos: %d)", this->hThis, total_readsamples, this->PlaybackState.position)); |
dmsg(5,("Refilled stream %d with %d (SamplePos: %d)", this->hThis, total_readsamples, this->PlaybackState.position)); |
48 |
} |
} |
51 |
pSample->SetPos(this->SampleOffset); // recover old position |
pSample->SetPos(this->SampleOffset); // recover old position |
52 |
|
|
53 |
do { |
do { |
54 |
readsamples = pSample->Read(&pBuf[total_readsamples * pSample->Channels], samplestoread); |
readsamples = pSample->Read(&pBuf[total_readsamples * pSample->Channels], samplestoread, pDecompressionBuffer); |
55 |
samplestoread -= readsamples; |
samplestoread -= readsamples; |
56 |
total_readsamples += readsamples; |
total_readsamples += readsamples; |
57 |
} while (samplestoread && readsamples > 0); |
} while (samplestoread && readsamples > 0); |
79 |
pRingBuffer->increment_write_ptr_with_wrap(SilenceSampleWords); |
pRingBuffer->increment_write_ptr_with_wrap(SilenceSampleWords); |
80 |
} |
} |
81 |
|
|
82 |
Stream::Stream(uint BufferSize, uint BufferWrapElements) { |
Stream::Stream( ::gig::buffer_t* pDecompressionBuffer, uint BufferSize, uint BufferWrapElements) { |
83 |
this->pExportReference = NULL; |
this->pExportReference = NULL; |
84 |
this->State = state_unused; |
this->State = state_unused; |
85 |
this->hThis = 0; |
this->hThis = 0; |
86 |
this->pSample = NULL; |
this->pSample = NULL; |
87 |
this->SampleOffset = 0; |
this->SampleOffset = 0; |
88 |
this->PlaybackState.position = 0; |
this->PlaybackState.position = 0; |
89 |
this->PlaybackState.reverse = false; |
this->PlaybackState.reverse = false; |
90 |
this->pRingBuffer = new RingBuffer<sample_t>(BufferSize, BufferWrapElements); |
this->pRingBuffer = new RingBuffer<sample_t>(BufferSize, BufferWrapElements); |
91 |
|
this->pDecompressionBuffer = pDecompressionBuffer; |
92 |
UnusedStreams++; |
UnusedStreams++; |
93 |
TotalStreams++; |
TotalStreams++; |
94 |
} |
} |