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 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 - 2013 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009 - 2015 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
10 |
* 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 * |
25 |
#ifndef __LS_INSTRUMENTMANAGERBASE_H__ |
#ifndef __LS_INSTRUMENTMANAGERBASE_H__ |
26 |
#define __LS_INSTRUMENTMANAGERBASE_H__ |
#define __LS_INSTRUMENTMANAGERBASE_H__ |
27 |
|
|
28 |
#include "InstrumentManager.h" |
#include "common/AbstractInstrumentManager.h" |
29 |
|
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
30 |
#include "AbstractEngine.h" |
#include "AbstractEngine.h" |
31 |
#include "AbstractEngineChannel.h" |
#include "AbstractEngineChannel.h" |
|
#include "../common/ResourceManager.h" |
|
|
#include "../common/global_private.h" |
|
|
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
|
32 |
|
|
33 |
// We need to know the maximum number of sample points which are going to |
// We need to know the maximum number of sample points which are going to |
34 |
// be processed for each render cycle of the audio output driver, to know |
// be processed for each render cycle of the audio output driver, to know |
40 |
namespace LinuxSampler { |
namespace LinuxSampler { |
41 |
|
|
42 |
template <class F /* Instrument File */, class I /* Instrument */, class R /* Regions */, class S /*Sample */> |
template <class F /* Instrument File */, class I /* Instrument */, class R /* Regions */, class S /*Sample */> |
43 |
class InstrumentManagerBase : public InstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, I> { |
class InstrumentManagerBase : public AbstractInstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, I> { |
44 |
public: |
public: |
45 |
struct region_info_t { |
struct region_info_t { |
46 |
int refCount; |
int refCount; |
54 |
|
|
55 |
typedef ResourceConsumer<I> InstrumentConsumer; |
typedef ResourceConsumer<I> InstrumentConsumer; |
56 |
|
|
57 |
InstrumentManagerBase() { } |
InstrumentManagerBase() : AbstractInstrumentManager() { } |
58 |
virtual ~InstrumentManagerBase() { } |
virtual ~InstrumentManagerBase() { } |
59 |
|
|
60 |
virtual InstrumentEditor* LaunchInstrumentEditor(instrument_id_t ID, void* pUserData = NULL) throw (InstrumentManagerException) OVERRIDE { |
virtual InstrumentEditor* LaunchInstrumentEditor(EngineChannel* pEngineChannel, instrument_id_t ID, void* pUserData = NULL) throw (InstrumentManagerException) OVERRIDE { |
61 |
throw InstrumentManagerException( |
throw InstrumentManagerException( |
62 |
"Instrument editing is not supported for this instrument format" |
"Instrument editing is not supported for this instrument format" |
63 |
); |
); |
212 |
const uint neededSilenceSamples = (maxSamplesPerCycle << CONFIG_MAX_PITCH) + 3; |
const uint neededSilenceSamples = (maxSamplesPerCycle << CONFIG_MAX_PITCH) + 3; |
213 |
const uint currentlyCachedSilenceSamples = pSample->GetCache().NullExtensionSize / pSample->GetFrameSize(); |
const uint currentlyCachedSilenceSamples = pSample->GetCache().NullExtensionSize / pSample->GetFrameSize(); |
214 |
if (currentlyCachedSilenceSamples < neededSilenceSamples) { |
if (currentlyCachedSilenceSamples < neededSilenceSamples) { |
215 |
dmsg(3,("Caching whole sample (sample name: \"%s\", sample size: %d)\n", pSample->GetName().c_str(), pSample->GetTotalFrameCount())); |
dmsg(3,("Caching whole sample (sample name: \"%s\", sample size: %ld)\n", pSample->GetName().c_str(), pSample->GetTotalFrameCount())); |
216 |
typename S::buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(neededSilenceSamples); |
typename S::buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(neededSilenceSamples); |
217 |
dmsg(4,("Cached %d Bytes, %d silence bytes.\n", buf.Size, buf.NullExtensionSize)); |
dmsg(4,("Cached %lu Bytes, %lu silence bytes.\n", buf.Size, buf.NullExtensionSize)); |
218 |
} |
} |
219 |
} |
} |
220 |
else { // we only cache CONFIG_PRELOAD_SAMPLES and stream the other sample points from disk |
else { // we only cache CONFIG_PRELOAD_SAMPLES and stream the other sample points from disk |