744 |
RIFF::List* pParent = pWaveList->GetParent(); |
RIFF::List* pParent = pWaveList->GetParent(); |
745 |
pParent->DeleteSubChunk(pWaveList); |
pParent->DeleteSubChunk(pWaveList); |
746 |
} |
} |
747 |
|
|
748 |
|
/** |
749 |
|
* Make a deep copy of the Sample object given by @a orig (without the |
750 |
|
* actual sample waveform data however) and assign it to this object. |
751 |
|
* |
752 |
|
* This is a special internal variant of CopyAssign() which only copies the |
753 |
|
* most mandatory member variables. It will be called by gig::Sample |
754 |
|
* descendent instead of CopyAssign() since gig::Sample has its own |
755 |
|
* implementation to access and copy the actual sample waveform data. |
756 |
|
* |
757 |
|
* @param orig - original Sample object to be copied from |
758 |
|
*/ |
759 |
|
void Sample::CopyAssignCore(const Sample* orig) { |
760 |
|
// handle base classes |
761 |
|
Resource::CopyAssign(orig); |
762 |
|
// handle actual own attributes of this class |
763 |
|
FormatTag = orig->FormatTag; |
764 |
|
Channels = orig->Channels; |
765 |
|
SamplesPerSecond = orig->SamplesPerSecond; |
766 |
|
AverageBytesPerSecond = orig->AverageBytesPerSecond; |
767 |
|
BlockAlign = orig->BlockAlign; |
768 |
|
BitDepth = orig->BitDepth; |
769 |
|
SamplesTotal = orig->SamplesTotal; |
770 |
|
FrameSize = orig->FrameSize; |
771 |
|
} |
772 |
|
|
773 |
|
/** |
774 |
|
* Make a deep copy of the Sample object given by @a orig and assign it to |
775 |
|
* this object. |
776 |
|
* |
777 |
|
* @param orig - original Sample object to be copied from |
778 |
|
*/ |
779 |
|
void Sample::CopyAssign(const Sample* orig) { |
780 |
|
CopyAssignCore(orig); |
781 |
|
|
782 |
|
// copy sample waveform data (reading directly from disc) |
783 |
|
Resize(orig->GetSize()); |
784 |
|
char* buf = (char*) LoadSampleData(); |
785 |
|
Sample* pOrig = (Sample*) orig; //HACK: circumventing the constness here for now |
786 |
|
const unsigned long restorePos = pOrig->pCkData->GetPos(); |
787 |
|
pOrig->SetPos(0); |
788 |
|
for (unsigned long todo = pOrig->GetSize(), i = 0; todo; ) { |
789 |
|
const int iReadAtOnce = 64*1024; |
790 |
|
unsigned long n = (iReadAtOnce < todo) ? iReadAtOnce : todo; |
791 |
|
n = pOrig->Read(&buf[i], n); |
792 |
|
if (!n) break; |
793 |
|
todo -= n; |
794 |
|
i += (n * pOrig->FrameSize); |
795 |
|
} |
796 |
|
pOrig->pCkData->SetPos(restorePos); |
797 |
|
} |
798 |
|
|
799 |
/** @brief Load sample data into RAM. |
/** @brief Load sample data into RAM. |
800 |
* |
* |
845 |
* @returns number of sample points or 0 if FormatTag != DLS_WAVE_FORMAT_PCM |
* @returns number of sample points or 0 if FormatTag != DLS_WAVE_FORMAT_PCM |
846 |
* @see FrameSize, FormatTag |
* @see FrameSize, FormatTag |
847 |
*/ |
*/ |
848 |
unsigned long Sample::GetSize() { |
unsigned long Sample::GetSize() const { |
849 |
if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0; |
if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0; |
850 |
return (pCkData) ? pCkData->GetSize() / FrameSize : 0; |
return (pCkData) ? pCkData->GetSize() / FrameSize : 0; |
851 |
} |
} |
1173 |
PhaseGroup = orig->PhaseGroup; |
PhaseGroup = orig->PhaseGroup; |
1174 |
MultiChannel = orig->MultiChannel; |
MultiChannel = orig->MultiChannel; |
1175 |
Channel = orig->Channel; |
Channel = orig->Channel; |
1176 |
WavePoolTableIndex = orig->WavePoolTableIndex; |
// only take the raw sample reference if the two Region objects are |
1177 |
pSample = orig->pSample; |
// part of the same file |
1178 |
|
if (GetParent()->GetParent() == orig->GetParent()->GetParent()) { |
1179 |
|
WavePoolTableIndex = orig->WavePoolTableIndex; |
1180 |
|
pSample = orig->pSample; |
1181 |
|
} else { |
1182 |
|
WavePoolTableIndex = -1; |
1183 |
|
pSample = NULL; |
1184 |
|
} |
1185 |
FormatOptionFlags = orig->FormatOptionFlags; |
FormatOptionFlags = orig->FormatOptionFlags; |
1186 |
WaveLinkOptionFlags = orig->WaveLinkOptionFlags; |
WaveLinkOptionFlags = orig->WaveLinkOptionFlags; |
1187 |
// handle the last, a bit sensible attribute |
// handle the last, a bit sensible attribute |
1657 |
String File::GetFileName() { |
String File::GetFileName() { |
1658 |
return pRIFF->GetFileName(); |
return pRIFF->GetFileName(); |
1659 |
} |
} |
1660 |
|
|
1661 |
|
/** |
1662 |
|
* You may call this method store a future file name, so you don't have to |
1663 |
|
* to pass it to the Save() call later on. |
1664 |
|
*/ |
1665 |
|
void File::SetFileName(const String& name) { |
1666 |
|
pRIFF->SetFileName(name); |
1667 |
|
} |
1668 |
|
|
1669 |
/** |
/** |
1670 |
* Apply all the DLS file's current instruments, samples and settings to |
* Apply all the DLS file's current instruments, samples and settings to |