38 #include "../Audacity.h"
42 #include <wx/filefn.h>
47 #include "../DirManager.h"
50 #include "../FileFormats.h"
58 unsigned char *p_in = (
unsigned char *) ∈
59 unsigned char *p_out = (
unsigned char *) &out;
81 (baseFileName.SetExt(wxT(
"au")), std::move(baseFileName)),
87 bool bSuccess = WriteSimpleBlockFile(sampleData, sampleLen,
format, NULL);
98 float min,
float max,
float rms):
99 BlockFile{ std::move(existingFile), len }
119 wxFFile file(mFileName.GetFullPath(), wxT(
"wb"));
120 if( !file.IsOpened() ){
132 header.
magic = 0x2e736e64;
164 summaryData = CalcSummary(sampleData, sampleLen,
format, cleanup);
167 size_t nBytesToWrite =
sizeof(header);
168 size_t nBytesWritten = file.Write(&header, nBytesToWrite);
169 if (nBytesWritten != nBytesToWrite)
171 wxLogDebug(wxT(
"Wrote %lld bytes, expected %lld."), (
long long) nBytesWritten, (
long long) nBytesToWrite);
175 nBytesToWrite = mSummaryInfo.totalSummaryBytes;
176 nBytesWritten = file.Write(summaryData, nBytesToWrite);
177 if (nBytesWritten != nBytesToWrite)
179 wxLogDebug(wxT(
"Wrote %lld bytes, expected %lld."), (
long long) nBytesWritten, (
long long) nBytesToWrite);
188 int *int24sampleData = (
int*)sampleData;
190 for(
size_t i = 0; i < sampleLen; i++ )
194 #if wxBYTE_ORDER == wxBIG_ENDIAN
195 file.Write((
char*)&int24sampleData[i] + 1, nBytesToWrite);
197 file.Write((
char*)&int24sampleData[i], nBytesToWrite);
199 if (nBytesWritten != nBytesToWrite)
201 wxLogDebug(wxT(
"Wrote %lld bytes, expected %lld."), (
long long) nBytesWritten, (
long long) nBytesToWrite);
211 nBytesWritten = file.Write(sampleData, nBytesToWrite);
212 if (nBytesWritten != nBytesToWrite)
214 wxLogDebug(wxT(
"Wrote %lld bytes, expected %lld."), (
long long) nBytesWritten, (
long long) nBytesToWrite);
228 data.
reinit( mSummaryInfo.totalSummaryBytes );
231 wxFFile file(mFileName.GetFullPath(), wxT(
"rb"));
239 if (!file.IsOpened()){
240 memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
249 file.Read(data.get(), mSummaryInfo.totalSummaryBytes) !=
250 mSummaryInfo.totalSummaryBytes ) {
251 memset(data.get(), 0, mSummaryInfo.totalSummaryBytes);
255 FixSummary(data.get());
268 size_t start,
size_t len,
bool mayThrow)
const
270 return CommonReadData( mayThrow,
271 mFileName, mSilentLog,
nullptr, 0, 0, data,
format, start, len);
277 xmlFile.
StartTag(wxT(
"simpleblockfile"));
279 xmlFile.
WriteAttr(wxT(
"filename"), mFileName.GetFullName());
285 xmlFile.
EndTag(wxT(
"simpleblockfile"));
295 float min = 0.0f, max = 0.0f, rms = 0.0f;
302 const wxChar *attr = *attrs++;
303 const wxChar *value = *attrs++;
307 const wxString strValue = value;
308 if (!wxStricmp(attr, wxT(
"filename")) &&
313 if (!dm.AssignFile(fileName, strValue,
false))
317 else if (!wxStrcmp(attr, wxT(
"len")) &&
323 if (!wxStricmp(attr, wxT(
"min")))
325 else if (!wxStricmp(attr, wxT(
"max")))
327 else if (!wxStricmp(attr, wxT(
"rms")) && (dblValue >= 0.0))
332 return make_blockfile<SimpleBlockFile>
333 (std::move(fileName), len,
min, max, rms);
341 auto newBlockFile = make_blockfile<SimpleBlockFile>
342 (std::move(newFileName), mLen, mMin, mMax, mRMS);
353 wxFFile file(mFileName.GetFullPath(), wxT(
"rb"));
354 if (!file.IsOpened())
361 if (file.Read(&header,
sizeof(header)) !=
sizeof(header))
369 if (header.
magic == 0x2e736e64)
393 mSummaryInfo.totalSummaryBytes +
399 wxFFile file(mFileName.GetFullPath(), wxT(
"wb"));
401 if( !file.IsOpened() ){
407 header.
magic = 0x2e736e64;
415 file.Write(&header,
sizeof(header));
417 for(decltype(mSummaryInfo.totalSummaryBytes) i = 0;
418 i < mSummaryInfo.totalSummaryBytes; i++)
419 file.Write(wxT(
"\0"),1);
421 for(decltype(mLen) i = 0; i < mLen * 2; i++)
422 file.Write(wxT(
"\0"),1);
428 []( DirManager &dm,
const wxChar **attrs ){