{
   "name" : "AudioJournal",
   "author" : "Schemawound",
   "description" : "AudioJournal by Jonathan Siemasko\r\n\r\nhttp://www.schemawound.com/\r\n\r\n\r\nInspired by Disquiet Junto project 0051: http://disquiet.com/2012/12/20/disquiet0051-audiojournal/\r\n\r\n\r\nThis code will take 12 files (one representing each month) and make a chronological mix of random sections of each piece.\r\n\r\n\r\nINSTRUCTIONS:\r\n\r\nSet audiojournal to a location on your harddrive containing WAV files with the following 12 names: 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'\r\n\r\nWAV files must be stereo.",
   "ancestor_list" : [],
   "labels" : [
      "disquiet junto",
      "disquiet",
      "junto"
   ],
   "code" : "/*\r\nAudioJournal by Jonathan Siemasko\r\nhttp://www.schemawound.com/\r\n\r\nInspired by Disquiet Junto project 0051: http://disquiet.com/2012/12/20/disquiet0051-audiojournal/\r\n\r\nThis code will take 12 files (one representing each month) and make a chronological mix of random sections of each piece.\r\n\r\nINSTRUCTIONS:\r\nSet audiojournal to a location on your harddrive containing WAV files with the following 12 names: 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'\r\nWAV files must be stereo.\r\n*/\r\n\r\n(\r\n{\r\n\tvar audiojournal =  = 'C:/AudioJournal/';\r\n\tvar fileFormat = 'wav';  //File extension\r\n\tvar seconds = 5; //Seconds each file segment will last\r\n\tvar monthFileNames, monthBuf = Array.newClear(12);\r\n\tvar randSeed = 0; //Modify the random seed to try a different variation.  If you want a random run each time then comment out the line that states: \"thisThread.randSeed = randSeed;\"\r\n\r\n\t//-----SynthDefs-----\r\n\r\n\tSynthDef(\\bufPlay2, {|out = 0, bufnum, gate = 1, rateScale = 1, amp = 1|\r\n\t\tvar buf = PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum) * rateScale);\r\n\t\tvar env = Linen.kr(gate, 0.01, 1, 0.01, doneAction: 2);\r\n\t\tOut.ar(out, buf * amp * env);\r\n\t}).add; //Stereo\r\n\r\n\t//-----Buffers-----\r\n\tmonthFileNames = Array.with('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');\r\n\tmonthFileNames.do{|fileName, i| monthFileNames[i] = audiojournal ++ fileName ++ '.' ++ fileFormat}; //Expand to full filename and path\r\n\tmonthFileNames.do{|fileName, i| monthBuf[i] = Buffer.read(s, monthFileNames[i], 0, -1)}; //Fill buffers so we can get the file sizes\r\n\ts.sync; //Sync to wait for the buffers to fill\r\n\r\n\t//-----Replace With Trimmed Buffers-----\r\n\tthisThread.randSeed = randSeed;\r\n\tmonthBuf.do{|buf, i|\r\n\t\tvar samples = seconds * s.sampleRate;\r\n\t\tvar maxStartFrame = buf.numFrames - samples; //Ensure we do not run past the end of the buffer\r\n\t\tvar newBuf;\r\n\t\t//If the file is smaller then the requested size then just the use the whole file.\r\n\t\tif ((buf.numFrames <= samples),\r\n\t\t\t{newBuf = Buffer.read(s, monthFileNames[i], 0, -1)},\r\n\t\t\t{newBuf = Buffer.read(s, monthFileNames[i], maxStartFrame.rand, samples)}\r\n\t\t);\r\n\t\t//Clear the current buffer and replace with the trimmed buffer\r\n\t\tmonthBuf[i].free;\r\n\t\tmonthBuf[i] = newBuf;\r\n\t}; //Get file sizes and free the buffers\r\n\ts.sync; //Wait for the new buffers to fill\r\n\r\n\t//-----Display-----\r\n\t3.do{''.dopostln};\r\n\t'-----BUFFERS-----'.postln; monthBuf.dopostln;\r\n\r\n\t//-----Play-----\r\n\tPbind(*[instrument: \\bufPlay2, bufnum: Pseq(monthBuf), dur: seconds, sustain: Pkey(\\dur), amp: 1]).trace.play;\r\n\r\n\t//-----Clean Up------\r\n\tCmdPeriod.doOnce{monthBuf.do{|buf, i| buf.free}};\r\n}.fork\r\n)",
   "id" : "1-4S1",
   "is_private" : null
}
