diff data/fileio/WavFileWriter.cpp @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents 59e7fe1b1003
children a1cd5abcb38b
line wrap: on
line diff
--- a/data/fileio/WavFileWriter.cpp	Tue Mar 03 09:33:59 2015 +0000
+++ b/data/fileio/WavFileWriter.cpp	Tue Mar 03 15:18:24 2015 +0000
@@ -120,7 +120,7 @@
         ownSelection = true;
     }
 
-    int bs = 2048;
+    sv_frame_t bs = 2048;
     float *ub = new float[bs]; // uninterleaved buffer (one channel)
     float *ib = new float[bs * m_channels]; // interleaved buffer
 
@@ -128,11 +128,11 @@
 	     selection->getSelections().begin();
 	 i != selection->getSelections().end(); ++i) {
 	
-	int f0(i->getStartFrame()), f1(i->getEndFrame());
+	sv_frame_t f0(i->getStartFrame()), f1(i->getEndFrame());
 
-	for (int f = f0; f < f1; f += bs) {
+	for (sv_frame_t f = f0; f < f1; f += bs) {
 	    
-	    int n = std::min(bs, f1 - f);
+	    sv_frame_t n = std::min(bs, f1 - f);
 
 	    for (int c = 0; c < int(m_channels); ++c) {
 		source->getData(c, f, n, ub);
@@ -159,7 +159,7 @@
 }
 	
 bool
-WavFileWriter::writeSamples(float **samples, int count)
+WavFileWriter::writeSamples(float **samples, sv_frame_t count)
 {
     if (!m_file) {
         m_error = QString("Failed to write model to audio file '%1': File not open")
@@ -168,17 +168,17 @@
     }
 
     float *b = new float[count * m_channels];
-    for (int i = 0; i < int(count); ++i) {
+    for (sv_frame_t i = 0; i < count; ++i) {
         for (int c = 0; c < int(m_channels); ++c) {
             b[i * m_channels + c] = samples[c][i];
         }
     }
 
-    sf_count_t written = sf_writef_float(m_file, b, count);
+    sv_frame_t written = sf_writef_float(m_file, b, count);
 
     delete[] b;
 
-    if (written < int(count)) {
+    if (written < count) {
         m_error = QString("Only wrote %1 of %2 frames")
             .arg(written).arg(count);
     }