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

[sc-dev] RecordBuf and PlayBuf doneAction



Hi -

See recent discussion on sc-users, Till amongst others discussing why
RecordBuf and PlayBuf don't have a doneAction. I also find this
frustrating and often use the Line.kr(1,1,dur,doneAction:whatever)
kludge.

The following patch adds doneAction to RecordBuf (it's only ever
triggered if "loop" is off). Any objections?

I want to do the same to PlayBuf but it's less obvious where to put it
in the code, but will have a look if I can.

Dan



Index: build/SCClassLibrary/Common/Audio/BufIO.sc
===================================================================
--- build/SCClassLibrary/Common/Audio/BufIO.sc	(revision 8078)
+++ build/SCClassLibrary/Common/Audio/BufIO.sc	(working copy)
@@ -93,16 +93,16 @@

 RecordBuf : UGen {	
 	*ar { arg inputArray, bufnum=0, offset=0.0, recLevel=1.0, preLevel=0.0,
-			run=1.0, loop=1.0, trigger=1.0;
+			run=1.0, loop=1.0, trigger=1.0, doneAction=0;
 		^this.multiNewList(
-			['audio', bufnum, offset, recLevel, preLevel, run, loop, trigger ]
+			['audio', bufnum, offset, recLevel, preLevel, run, loop, trigger,
doneAction ]
 			++ inputArray.asArray
 		)
 	}
 	*kr { arg inputArray, bufnum=0, offset=0.0, recLevel=1.0, preLevel=0.0,
-			run=1.0, loop=1.0, trigger=1.0;
+			run=1.0, loop=1.0, trigger=1.0, doneAction=0;
 		^this.multiNewList(
-			['control', bufnum, offset, recLevel, preLevel, run, loop, trigger ]
+			['control', bufnum, offset, recLevel, preLevel, run, loop,
trigger, doneAction ]
 			++ inputArray.asArray
 		)
 	}
Index: Source/plugins/DelayUGens.cpp
===================================================================
--- Source/plugins/DelayUGens.cpp	(revision 8078)
+++ Source/plugins/DelayUGens.cpp	(working copy)
@@ -1231,7 +1231,7 @@
 	//printf("RecordBuf_next\n");
 	GET_BUF
 	CHECK_BUF
-	SETUP_IN(7)
+	SETUP_IN(8)

 	float recLevel = ZIN0(2);
 	float preLevel = ZIN0(3);
@@ -1405,7 +1405,10 @@
 				}
 			}
 		}
-		if (writepos >= (int32)bufSamples) unit->mDone = true;
+		if (writepos >= (int32)bufSamples){
+			unit->mDone = true;
+			DoneAction(IN0(7), unit);
+		}
 	}
 	unit->m_prevtrig = trig;
 	unit->m_writepos = writepos;
@@ -1418,7 +1421,7 @@
 	// printf("RecordBuf_next_10\n");
 	GET_BUF
 	CHECK_BUF
-	SETUP_IN(7)
+	SETUP_IN(8)

 	float run      = ZIN0(4);
 	int32 loop     = (int32)ZIN0(5);
@@ -1549,7 +1552,10 @@
 				}
 			}
 		}
-		if (writepos >= (int32)bufSamples) unit->mDone = true;
+		if (writepos >= (int32)bufSamples){
+			unit->mDone = true;
+			DoneAction(IN0(7), unit);
+		}
 	}
 	unit->m_prevtrig = trig;
 	unit->m_writepos = writepos;


-- 
http://www.mcld.co.uk

Attachment: PlayBuf_doneAction.diff
Description: Binary data