[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] DiskOut frame index? (bug in DiskOut?)



On Wednesday 17 June 2009 12:09:29 nescivi wrote:
> On Wednesday 17 June 2009 03:36:27 Dan Stowell wrote:
> > What does it currently output?
>
> Nothing. Just 0.
>
> Loss of potential there :)

I started on a solution for this...

However, it doesn't seem to work yet...

but then I reverted back, and I don't even get anything written with the old 
version, and the standard helpfile example.
Something really strange is going on there!
Any clues what may be going on there?

sincerely,
Marije


> sincerely,
> Marije
>
> > Dan
> >
> > 2009/6/17, nescivi <nescivi@xxxxxxxxx>:
> > > Hiho,
> > >
> > >  would it be terribly hard to add a frame index output to DiskOut?
> > >  just counting up the number of frames written, as the SynthDef if
> > > active? Tha would enable recording that data to sync it up with other
> > > data...
> > >
> > >  sincerely,
> > >  Marije

Index: Source/plugins/DiskIO_UGens.cpp
===================================================================
--- Source/plugins/DiskIO_UGens.cpp	(revision 9209)
+++ Source/plugins/DiskIO_UGens.cpp	(working copy)
@@ -17,8 +17,11 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */
+/*
+  Output of frame index for DiskOut by Marije Baalman (nescivi), 2009
+  VDiskIn by Scott Wilson, 2008
+*/
 
-
 #include "MsgFifo.h"
 #include "SC_SyncCondition.h"
 #include "SC_PlugIn.h"
@@ -55,6 +58,7 @@
 	float m_fbufnum;
 	SndBuf *m_buf;
 	uint32 m_framepos;
+	uint32 m_framewritten;
 };
 
 struct VDiskIn : public Unit
@@ -254,6 +258,7 @@
 	unit->m_fbufnum = -1.f;
 	unit->m_buf = unit->mWorld->mSndBufs;
 	unit->m_framepos = 0;
+	unit->m_framewritten = 0;
 	SETCALC(DiskOut_next);
 }
 
@@ -264,10 +269,20 @@
 
 	if (!bufData || ((bufFrames & ((unit->mWorld->mBufLength<<1) - 1)) != 0)) {
 		unit->m_framepos = 0;
+//		unit->m_framewritten = 0;
+	printf("buffer error?\n");
+	fflush( stdout );
+
 		return;
 	}
 	SETUP_IN(1)
 	
+	float *out = OUT(0);
+	uint32_t framew = unit->m_framewritten;
+
+	printf("Start frames %i %i\n", unit->m_framewritten, framew );
+	fflush( stdout );
+	
 	if (unit->m_framepos >= bufFrames) {
 		unit->m_framepos = 0;
 	}
@@ -279,6 +294,7 @@
 			for (uint32 i=0; i<bufChannels; ++i) {
 				*bufData++ = *in[i]++;
 			}
+			out[j] = framew++;
 		}
 	} else if (bufChannels == 2) {
 		float *in0 = in[0];
@@ -286,15 +302,23 @@
 		for (int j=0; j<inNumSamples; ++j) {
 			*bufData++ = *in0++;
 			*bufData++ = *in1++;
+			out[j] = framew++;
 		}
 	} else {
 		float *in0 = in[0];
 		for (int j=0; j<inNumSamples; ++j) {
 			*bufData++ = *in0++;
+			out[j] = framew++;
 		}
 	}
 	
 	unit->m_framepos += inNumSamples;
+//	unit->m_framewritten += inNumSamples;
+	unit->m_framewritten = framew;
+	
+	printf("frames %i %i\n", unit->m_framewritten, framew );
+	fflush( stdout );
+	
 	uint32 bufFrames2 = bufFrames >> 1;
 	if (unit->m_framepos == bufFrames) {
 		unit->m_framepos = 0;
@@ -318,6 +342,7 @@
 		pgDiskFifoHasData->Signal();
 #endif //#ifndef SC_WIN32
 	}
+	
 }
 
 void DiskIOMsg::Perform()