queryfunc

Within this function more or less everything happens - from retrieving eBay-data to generation of the track.

queryfunc = { |who, recipient, loops, endfunc, restart|
    var temp, buflength;
 
    // hand-picked harmonics - a selections of harmonics out of a tonality-diamond (http://en.wikipedia.org/wiki/Tonality_diamond)
    harms = [[1/2, 2/3, 3/4, 5/6, 4/3, 3/2, 1/1, 5/3, 2/1, 8/3, 3/1, 10/3, 4/1, 5/1, 16/3, 6/1], [8/15, 2/3, 4/5, 8/9, 16/15, 6/5, 4/3, 8/5, 16/15, 32/15, 4/3, 16/9, 12/5, 8/3, 64/15, 32/9, 24/5, 16/3, 32/5, 64/9], [4/7, 5/7, 9/16, 15/16, 11/13, 15/13, 16/11, 8/7, 10/7, 9/8, 22/13, 16/17, 9/4,  20/7, 44/13, 15/4, 60/13, 32/7, 64/11, 9/2, 15/2], [8/13, 11/12, 12/13, 13/14, 14/13, 16/13, 14/9, 16/13, 11/6, 24/13, 13/7, 28/13, 28/9, 32/13, 11/3, 48/13, 26/7, 56/13, 56/9, 64/13], [8/11, 10/11, 12/11, 14/11, 11/9, 11/15, 16/11, 20/11, 22/15, 22/9, 24/11, 28/11, 32/11, 40/11, 44/15, 44/9, 48/11, 56/11, 64/11], [3/5, 3/4, 8/9, 7/8, 16/15, 16/9, 4/3, 6/5, 3/2, 8/3, 32/15, 32/9, 12/5, 3/1, 64/15, 16/3, 64/9], [9/14, 11/12, 12/11, 8/5, 4/5, 13/16, 9/7, 11/6, 24/11, 13/8, 16/5, 18/7, 11/3, 13/4, 48/11, 32/5], [9/13, 12/13, 15/13, 7/5, 15/16, 4/7, 8/7, 18/13, 24/13, 14/5, 30/13, 15/4, 16/7, 36/13, 48/13, 28/5, 15/2, 60/13], [9/11, 12/11, 15/11, 11/9, 8/15, 11/16, 13/16, 16/15, 11/8, 13/8, 32/15, 18/11, 24/11, 30/11, 11/4, 13/4, 64/15, 36/11, 48/11, 60/11], [5/6, 7/5, 15/6, 5/8, 10/9, 5/3, 5/4, 15/8, 20/9, 14/5, 10/3, 15/4, 5/2, 28/5, 40/9, 5/1, 15/2], [5/8, 11/14, 13/11, 5/4, 5/3, 14/9, 10/9, 11/7, 26/11, 5/2, 28/9, 10/3, 22/7, 52/11, 5/1, 56/9, 20/3]]; 
 
    // remove last generated Score
    temp = "~/Music/SuperCollider/ebay_generator/temp/score.txt".standardizePath;    ("rm "++temp).unixCmd;
 
//////////////////////////////////////////////////////////////////
//    part 1: reading in values from ebay.com, sampling comments;///
//////////////////////////////////////////////////////////////////
    endfunc.stop.reset;
    "request is not nil".postln;
    date = Date.getDate;
    ~gmt = Date.getDate.gmtime;
    ~dif = date.hourStamp.asInteger-~gmt.hourStamp.asInteger;    
 
    ~date = ""++date.year++"-"++date.month++"-"++date.day+date.hourStamp;
    ~timestamp = date.stamp;
 
    who = who.asString;
    [who, who.class].postln;
    a = Ebay.read(who, "http://sound-of-ebay.com/your-data-processor.php");
 
    if(a['feedbacks'][0]['feedback'].asString.size > 0, { // do we have at least 1 comment?
        ("userfeedbacks:"+a['feedbacks'][0]['feedback'].class).postln;
        ~restart = false; // ok, we don't want to restart now ...
        ~userSign = Array();
        who.hash.abs.asString.do({ |i| 
            i.digit.postln; 
            ~userSign = ~userSign.add(i.digit**3) 
        });
        ("userSign:"+~userSign).postln;
 
        ~ratings = List();
        ~u_fbs = List();
 
        if(Speech.initialized.not, { Speech.init(16) }); // we have to initialise Apple-Speech. Fortunately we don't need more than 16 channels 
 
        if(~buffer.isNil, { ~buffer = Buffer.alloc(s, 65536, 1) }, { ~buffer.updateInfo; ~buffer.free; ~buffer = Buffer.alloc(s, 65536, 1) }); // buffer-allocation for the comments which will be read by Apple-Speech and sampled for later use. Important!! The speech-voices are provided by the operating system, not SuperCollider, so we have to use Jackd to route them from the OS to SC -> route SuperCollider out 1+2 to SuperCollider in 1+2 - strange, but that's how it works. Jackd has to be running before SC is started. Routing can be done in JackPilot or QJackCtl after the SC-server has been started!
 
        ~doers = Array();
        ~doersnames = Array();
        ~comments = Array();
 
        i = 0;
        l = 0;
 
        block { |break| // even if we have some comments it may happen, that none of them contains any 7 bit ascii signs. For convenience we test up to 499 comments - if no valid comment is detected break out of the loop and notify the requestant  
            while({i < loops and:{l < 500}}, {
                j = (a['feedbacks'].size).rand;
                comment = a['feedbacks'][j]['comment'].asString;
                temp = a['feedbacks'][j]['user_name'].asString;
                if("[a-z]|&|%".matchRegexp(comment) == true, { // we need 7 bit ascii only - other characters can't be interpreted by Apple Speech
                    ~comments = ~comments.add(a['feedbacks'][j]['comment']);
                    ~doers = ~doers.add(j);
                    ~doersnames = ~doersnames.add(temp);
                    i = i+1;
                });
                if(l > 499, {
                    break.value(
                        ("curl -d \"error=noascii\" -d \"uid="++who++"\" -d \"recipient="++recipient.asString++"\" http://sound-of-ebay.com/your-notifier-script.php").unixCmd;
                        "keine verwertbaren kommentare gefunden".postln;
                        request = nil;
                        ~restart = true;
                        neu = true; 
                        restart.play(AppClock, true); // we have no valid comments. So we procede to the next request resp. restart the query-process
                    );
                }, {
                    l = l+1;
                });
            });
        };
 
        ~doershashes = Array();
 
        ~begin = Main.elapsedTime;
 
        // we don't only consider the current request resp. its comments and users. We write add any new request to the history and with each new request we also consider all previous requests for the next generation
        if(File.exists("~/Music/SuperCollider/ebay_generator/hashesdb.txt".standardizePath), { // if no history exists we initialize a new one
            f = File("~/Music/SuperCollider/ebay_generator/hashesdb.txt".standardizePath, "r");
            history = f.readAllString;
            history = history.interpret;
            f.close;
            ("old history:"+history).postln;
        }, {
            history = Dictionary();
        });
 
        a['feedbacks'].pop; // delete the last, empty slot (as far as I can remember)
        a['feedbacks'].size.do({ |i|
            temp = a['feedbacks'][i]['user_name'].asSymbol;
 
            if(history.matchAt(temp).class == Integer, { // is the current user (comment-author) already contained in our history?
                history[temp] = history[temp] + 1; // increase the number of occurrencies by 1
            },{
                history.add(temp -> 1);    // add a new user to the history if (s)he doesn't already exist
            });
            ~doershashes = ~doershashes.add(temp.hash.abs.asFloat); // in order to work with usernames (string) we convert them to a hashsum (integer values)
        });
 
        if(history.matchAt(who.asSymbol).class == Integer, {
            ["found", history[who.asSymbol]].postln;
            history[who.asSymbol] = history[who.asSymbol] + 1;
            ~coin = 1/history[who.asSymbol];
        },{
            ["not found", history[who.asSymbol]].postln;
            history.add(who.asSymbol -> 1);
            ~coin = 1.0;
        });
 
        ~singeroccurrences = Array();
        ~doersnames.do({ |i| // occurrences of a specific username in all generations - frequent usernames are weighed more important
            if(history.matchAt(i.asSymbol).class == Integer, {
                ~singeroccurrences = ~singeroccurrences.add(history[i.asSymbol] + 1);
            }, {
                ~singeroccurrences = ~singeroccurrences.add(1);
            });
        });
 
        ~numharms = Array();
        ~doersnames.do({ |i|
            ~numharms = ~numharms.add(
                Ebay.divFunc(i.hash.abs.sqrt.asInteger, nil, 75, 100, 2); // from each "doer" (16 randomly selected users who left a comment) we want an array with at least 2 values between 75 and 100 -> in this case divFunc divides a given integer form 75 to hundred. Whenever the result is a whole-numbered value it's added to the array (for convenience we operate on the squareroot of the username-hashsum because this process is extremely intensive on CPU). result-example: [[78, 87], [82, 95, 98], ... [79, 92, 99]]
            );
        });
 
        ~numharms = (~numharms / ~singeroccurrences).ceil.asInteger;
 
        ("new history:"+history).postln;
 
        ~whohash = who.hash.abs.asFloat;
        ~doershash = (~doershashes.sum/~doershashes.size).asInteger;
        ("doershash:"+~doershash).postln;
 
        ~doersnames.do({ |i|
            temp = (i.hash.abs*~doershash).postln;
            ~teethlevels = ~teethlevels.add(Ebay.divFunc(temp.abs.sqrt.asInteger, nil, 15, 20, 4));
            ~phases = ~phases.add(Ebay.divFunc(temp.abs.sqrt.asInteger, nil, 1, 4, 4) - 1 / 10 * pi);
            ~spectimes = ~spectimes.add(Ebay.divFunc(temp.abs.sqrt.asInteger, nil, 1, 6, 1)/2);
        });
 
        d = history.getPairs.clump(2); // history is a Dictionary - an array of key-value pairs. You cannot rely on the order in a Dictionary, so we convert it into an ordinary 2-dimensional array.
 
        temp = Array();
        c = 0;
        d.do({ |i|
            temp = temp.add(i[0].hash.abs.asFloat * i[1]);
            c = c+i[1];
        });
        temp.postln;
        ~historyhash = (temp.sum.asFloat/c).asInteger;
        ("historyhash:"+~historyhash).postln;
        ~historySign = Array();
        ~historyhash.asString.do({ |i|
            ~historySign = ~historySign.add(i.digit.cubed);
        });
        ("historySign:"+~historySign).postln;
 
        temp = (Ebay.lcmFunc(~historySign).sum/Ebay.lcmFunc(~historySign).size).asInteger;
        temp = Ebay.divFunc(temp, nil, 7, 16, 4);
        temp = Ebay.harmSeries(temp); // create the harmonic scales out of the given 
        ~historyScales = Ebay.harmScales(temp, harms);
 
        ~blipFreqs = Array();        
        ~doersnames.do({ |i|
            ~blipFreqs = ~blipFreqs.add(Ebay.divFunc(i.hash.abs.sqrt.asInteger, nil, 33, 81, 2));
        });    
        ("blipFreqs:"+~blipFreqs).postln;
 
        f = File("~/Music/SuperCollider/ebay_generator/hashesdb.txt".standardizePath, "w");
        f.write(history.asCompileString);
        f.close;
        ~end = Main.elapsedTime;
        ("berechnung der history in"+(~end-~begin)+"sekunden ("++history.size+"user)").postln;
 
        ~elapsed = Array(loops);
 
        voices = [6,20,21,22];
 
        Speech.doneAction_({
            end = Main.elapsedTime;
            ~record.free.postln;
            ~buffer.close;
            if(count.notNil and:{ count == (loops-1) }, { ~buffer.updateInfo; ~buffer.free });
            if(count.isNil, { count = 1 },{ count = count+1});
            Speech.channels[0].stop(\immediate);    
            if(count < loops, {
                ~buffer.write("~/Music/SuperCollider/ebay_generator/temp/".standardizePath++"comment"++count++".aif", "aiff", "int16", 0, 0, true);
                ~record = Synth(\sampleIn1, [\bufnum, ~buffer]).postln;
                voice = voices.choose;
                ~voiceVols = ~voiceVols.add(voice);
                Speech.setSpeechVoice(count, voice);
                ("voice:"+voice).postln;
                a['feedbacks'][~doers[count]]['comment'].asString.postln;
                if(voice == 22, { 
                    Speech.channels[count].volume_(-8.dbamp).speak(a['feedbacks'][~doers[count]]['comment'].asString) 
                }, {
                    Speech.channels[count].speak(a['feedbacks'][~doers[count]]['comment'].asString) 
                });
                if(a['feedbacks'][~doers[count]]['feedback'] == 'Pos', { ~ratings.add(1) });
                if(a['feedbacks'][~doers[count]]['feedback'] == 'Neu', { ~ratings.add(0) });
                if(a['feedbacks'][~doers[count]]['feedback'] == 'Neg', { ~ratings.add(-1) });
                ~u_fbs.add(a['feedbacks'][~doers[count]]['user_feedbacks'].asInteger);
                dur = end-start;
                ~elapsed.add(dur);
            }, {
                dur = end-start;
                ~elapsed.add(dur);
                ~durations = Array(~elapsed.size);
                ~durations.add(~elapsed[0]);
                ~elapsed.do({ |i, j| 
                    var temp; 
                    ~elapsed[j+1].notNil.if{temp = (i-~elapsed[j+1]).abs;                      ~durations.add(temp)}
                });
                ~durations.postln;
 
                itemSign = List();
                ~durDict = Dictionary();
                ~doers.do({ |i, j| 
                    var temp, sign;
                    sign = String();
                    ~durDict.add(i->~durations[j]); 
                    temp = a['feedbacks'][~doers[j]]['item'].asString;
                    temp.do{ |i| i.isDecDigit.if{ sign = sign ++ i}};
                    itemSign.add(sign); 
                    tempList = List();
                    itemSign.collect({ |i| tempList.add(i.asList) });
                    ~sums = Array(tempList.size);
                    tempList.do({ |i| 
                        var temp = 0;
                        i.size.do({ |j| temp = temp + i[j].ascii.asInteger });
                        ~sums.add(temp.sqrt.asInteger);
                    });    
                });
                ~average = ~sums.sum/~sums.size;
                temp = Ebay.lcmFunc(~userSign);
                ~user = temp.sum/temp.size;
                temp = (~user*100).asInteger;
                ~steps1 = Ebay.divFunc(temp, nil, 7, 16, 4);
                ~durarr = Ebay.gcdFunc(~durations);
                ~harms = Ebay.harmSeries(~steps1.sort);
                ~harmScales = Ebay.harmScales(~harms, harms);
                ~activity = a['feedbacks'].size.asInteger;
                lyrics = File("~/Music/SuperCollider/ebay_generator/recordings/".standardizePath++~timestamp++"_"++who++".txt", "w");
                temp = who++"\n"++a['feedbacks'].size.asString++"\n"++a['positive_feedback']++"\n";
                lyrics.write(temp);
                ~doers.do({ |num|
                    temp = a['feedbacks'][num]['date'].asString++":::"++a['feedbacks'][num]['item'].asString++":::"++a['feedbacks'][num]['comment'].asString++"\n";
                    lyrics.write(temp);
                });
                lyrics.close;
                starter = true;
                ("starter:"+starter).postln;
                count = nil;
 
    ////////////////////////////////////////////////
    //            part 2: songgeneration    
    ////////////////////////////////////////////////
 
                t = TempoClock.default;
 
                o = ServerOptions.new.numOutputBusChannels_(2);
 
                ~b = Array(loops);
                loops.do({ |i|
                    s.sendMsg(\b_allocRead, temp = s.bufferAllocator.alloc(1), ("~/Music/SuperCollider/ebay_generator/temp/comment"++i++".aif").standardizePath);
                    ~b.add(temp);
                });
                s.sendMsg(\b_alloc, ~delbuf = s.bufferAllocator.alloc(1), 44100);
                s.sendMsg(\b_alloc, ~vocBufA = s.bufferAllocator.alloc(1), 1024);
                s.sendMsg(\b_alloc, ~vocBufB = s.bufferAllocator.alloc(1), 1024);
                s.sendMsg(\b_alloc, ~freezeBuf = s.bufferAllocator.alloc(1), 1024);
                s.sendMsg(\b_alloc, ~specbuf = s.bufferAllocator.alloc(1), 1024);
                s.sendMsg(\b_alloc, ~vocDelBuf = s.bufferAllocator.alloc(1), 44100);
                s.sendMsg(\b_alloc, ~vocPingPongDel = s.bufferAllocator.alloc(1), 44100 * 2, 2);
 
                buflength = Array();
                loops.do({ |i|
                    temp = SoundFile.openRead(("~/Music/SuperCollider/ebay_generator/temp/comment"++i++".aif").standardizePath);
                    if(7.div(temp.duration) > 0, {
                        buflength = buflength.add(temp.duration * 7.div(temp.duration));
                    }, {
                        buflength = buflength.add(temp.duration);
                    });
                    temp.close;
                });
 
                ~durabs = [5];    
                ~durations[0..(~durations.size-2)].do({ |i, j| i.postln; ~durabs = ~durabs.add((~durabs[j]+i.ceil+5).asInteger) });
 
                ~startpos = Array();
                ~durations.do({ |i|
                    temp = Array();
                    (i.div(1/8)).do({ |j|
                        temp = temp.add(1/8 * j);
                    });
                    temp = temp.normalizeSum;
                    ~startpos = ~startpos.add(temp.normalize(0, 1));
                });
 
                //////////////////////////////////////////
                ~songlength = (buflength.sum*2).asInteger + 13;
                //////////////////////////////////////////
 
                ~historyScales.takeThese({ |i| i.isEmpty });
 
                ~singerTones = Array();
                ~historyScales.do({ |i|
                    ~singerTones = ~singerTones.add(Pshuf(i, inf));
                });
 
                ~psychoDurs = Array();
                ~psychoFreqs = Array();
                ~psychoAmps = Array();
                ~historyScales.do({ |i|
                    temp = Array();
                    i.size.do({ |k|
                        temp = temp.add(~coin.coin);
                    });
                    ~psychoDurs = ~psychoDurs.add(
                        Pseq(Array.fill(
                            i.size, { |j| if(temp[j], { 
                                1/i.size * i[j]
                            }, { 
                                1/i.size 
                            })
                        }), 1);
                    );
                    tempList = Array.fill(
                        i.size, { |j| if(temp[j], {
                            // max possible in harms as division -> value should never be less then 0
                            1/i.size / i[j].squared / 4 * (0.18.reciprocal)
                        }, {
                            1/i.size*(0.18.reciprocal)
                        })
                    });
                    tempList = tempList.normalize(tempList.minItem, 1) * 0.45;
                    ~psychoAmps = ~psychoAmps.add(
                        Pseq(tempList, 1);
                    );
                });
                ~historyScales.do({ |i, j|
                    ~psychoFreqs = ~psychoFreqs.add(
                        Prand([Pxrand(i, 1), Pseq(i, 1), Pshuf(i, 1)], inf);
                    );
                });
 
                ~singers = Array.newClear(~songlength);
                ~blipPats = Array.newClear(~songlength);
 
                ~psyCount = 0;
                ~delCount = 0;
                k = 0;
                ~songlength.do({ |i|
                    ~blipPats.put(
                        if(k < loops, { temp = k }, { temp = loops-1 });
                        i, Pn(
                            Pseq([
                                Pbind(
                                    \instrument, \blipBase,
                                    \freq, ~psychoFreqs[~psyCount],
                                    \a, ~blipFreqs[temp][0],
                                    \b, ~blipFreqs[temp][1],
                                    \length, Pseq(~psychoDurs, 1),
                                    \dur, Pwrand([
                                        Pseq([1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8], 1),
                                        Prand([1/4, 1/2, 1/8, 1/8], 1)
                                    ], [5, 1, 1].normalizeSum, 1),
                                    \amp, Pn(Pseq(~psychoAmps, inf), 1),
                                    \n1, ~numharms[temp][0], 
                                    \n2, ~numharms[temp][1] 
                                )
                            ], 1),
                        1)
                    );
                    if(k >= (~psychoFreqs.size-1), { ~psyCount = 0 }, { ~psyCount = ~psyCount + 1 });
 
                    if(~durabs.includes(i) and:{k < loops} ,{
                        ~singers.put(
                            i, Pbus(
                                Pfpar([
                                    Pbind(*[
                                        instrument: \sampleOutMono,
                                        bufnum: ~b[k],
                                        startpos: 0,
                                        duration: Pn(buflength[k], 1),
                                        dur: buflength[k],
                                        amp: 0.5,
                                        addAction: 0,
                                    ]),
                                    Pmono(\vocodeIt, *[ 
                                        bufnumA: ~vocBufA, 
                                        bufnumB: ~vocBufB,
                                        note: ~singerTones.choose, 
                                        dur: 0.25,
                                        addAction: 1,
                                    ]),
                                    Pmono(\pingPong, *[
                                        bufnum: ~vocPingPongDel,
                                        xout: Pfunc({ 1.0.rand }),
                                        dur: 1,
                                        addAction: 1,
                                    ]),
                                    Pmono(\specReduktor, *[
                                        bufnum: ~specbuf,
                                        numTeeth: Pxrand(~teethlevels[k], inf),
                                        phase: Pxrand(~phases[k], inf),
                                        dur: Prand(~spectimes[k], inf),
                                        amp: 1.0,
                                        addAction: 1,
                                    ]),
 
                                ])
                            )
                        );
                        k = k+1;
                    }, {
                        ~singers.put(
                            i, Pbind(
                                \freq, Pn(\rest, 1)
                            )
                        );
                    });
                });
 
                p = Pn(Pseq([
                    Pfindur(~songlength-13, 
                        Ppar([
                            Pn(Pseq(~singers, 1), 1),
                                Pbind(
                                \instrument, \bd,
                                \dur, Pseq(([0.5, 0.5, 0.4, 0.1, 0.5].normalizeSum*2), inf),
                                \decay, 0.4,
                                \amp, 0.5
                            ),
                            Pbind(
                                \instrument, \sd,
                                \dur, Pwrand([Pseq([1.0, 1.0], 1), Pseq([5/9, 1/9, 1/9, 1/3, 8/9], 1),Pseq([5/8, 1/8, 1/8, 1/4, 7/8], 1)], [14, 1, 1].normalizeSum, inf),
                                \amp, 0.3
                            ),
                            Pbind(
                                \instrument, \hat,
                                \dur, Pseq([1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8], inf),
                                \ts, Pshuf([5, 10, 5, 7, 5], inf),
                                \amp, 0.3
                            ),
                            Pseq(~blipPats, inf)
                        ])
                    ),
                    PfadeOut(
                        Ppar([
                                Pbind(
                                \instrument, \bd,
                                \dur, Pseq(([0.5, 0.5, 0.4, 0.1, 0.5].normalizeSum*2), inf),
                                \amp, 0.1,
                                \decay, 0.4,
                                \amp, 0.5
                            ),
                            Pbind(
                                \instrument, \sd,
                                \dur, Pwrand([Pseq([1.0, 1.0], 1), Pseq([5/9, 1/9, 1/9, 1/3, 8/9], 1),Pseq([5/8, 1/8, 1/8, 1/4, 7/8], 1)], [14, 1, 1].normalizeSum, inf),
                                \amp, 0.3
                            ),
                            Pbind(
                                \instrument, \hat,
                                \dur, Pseq([1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8, 1/8], 10),
                                \ts, Pshuf([5, 10, 5, 7, 5], inf),
                                \amp, 0.3
                            ),
                            Pseq(~blipPats, inf)
                        ]), 10
                    ) 
                ], 1), 1).asScore(~songlength, timeOffset:0.05);
 
                ~b.do({ |i|
                    s.sendMsg(\b_free, i)
                });    
                s.sendMsg(\b_free, ~delbuf);
                s.sendMsg(\b_free, ~vocBufA);
                s.sendMsg(\b_free, ~vocBufB);
                s.sendMsg(\b_free, ~vocDelBuf);
                s.sendMsg(\b_free, ~freezeBuf);
                s.sendMsg(\b_free, ~specbuf);
                s.sendMsg(\b_free, ~vocPingPongDel);
 
                loops.do({ |i|
                    p.add([0.0, [\b_allocRead, ~b[i], ("~/Music/SuperCollider/ebay_generator/temp/comment"++i++".aif").standardizePath]]);
                });
                p.add([0.0, [\b_alloc, ~delbuf, 44100]]);
                p.add([0.0, [\b_alloc, ~vocBufA, 1024]]);
                p.add([0.0, [\b_alloc, ~vocBufB, 1024]]);
                p.add([0.0, [\b_alloc, ~vocDelBuf, 44100]]);
                p.add([0.0, [\b_alloc, ~specbuf, 2048]]);
                p.add([0.0, [\b_alloc, ~vocPingPongDel, 44100 * 2, 2]]);
 
                p.sort;
                p.saveToFile("~/Music/SuperCollider/ebay_generator/temp/score.txt".standardizePath);
 
                f = File("~/Music/SuperCollider/ebay_generator/temp/score.txt".standardizePath, "r");
                g = f.readAllString;
                f.close;
 
                g = g.reject({ |char| "[]\',\\\"".indexOf(char).notNil });
 
                ~sampleOuts = g.split($\n);
                ~sampleOuts.takeThese({ |i| i.contains("sampleOutMono").not });
                ~sampleOuts = ~sampleOuts.reverse;
 
                temp = String();
                ~sampleOuts.do({ |i|
                    temptemp = i.asString.split($ );
                    temp = temp ++ temptemp[1].asString ++"\n";
                });
                end = Main.elapsedTime;
 
                start = Main.elapsedTime;
                g = g.split($\n);
                g = g.reject({ |string| "Users".matchRegexp(string) });
                g = g.join($\n);
                end = Main.elapsedTime;
                ("Score String berechnet in:"+(end-start)+"Sekunden").postln;
 
                g = temp++g;
 
                f = File(("~/Music/SuperCollider/ebay_generator/recordings/"++~timestamp++"_"++who++"_score.txt").standardizePath, "w");
                f.write(g);
                f.close;
 
                if(~dif.abs < 10, { temp = "0"++~dif.abs.asString });
                if(~dif.isNegative, { temp = "-"++temp }, { temp = "+"++temp });
 
                ~author = recipient.asString.split($@);
                ~description = "Generated by the eBay-Generator on "++date+"GMT"++
                ~dif++"00.\n\n";
                ~comments.do({ |i|
                    ~description = ~description ++ i ++ "\n";
                });
 
                p.recordNRTThen("/tmp/trashme", "~/Music/SuperCollider/ebay_generator/recordings/".standardizePath++~timestamp++"_"++who++".aif", options:o, completionString: "; rm /tmp/trashme", action:{ endfunc.value(~timestamp, who, recipient, base, ~description, ~author[0]++"@sound-of-ebay.com", EbayHelpers.duration("~/Music/SuperCollider/ebay_generator/recordings/".standardizePath++~timestamp++"_"++who++".aif"), ~date, ""++~timestamp++"_"++who)});
            });
        });
        start = Main.elapsedTime;
        if(a['feedbacks'][~doers[0]]['feedback'].notNil, {
            ~buffer.write("~/Music/SuperCollider/ebay_generator/temp/".standardizePath++"comment0.aif", "aiff", "int16", 0, 0, leaveOpen:true);
            ~record = Synth(\sampleIn1, [\bufnum, ~buffer]);
            voice = voices.choose;
            ~voiceVols = Array();
            ~voiceVols = ~voiceVols.add(voice);
            Speech.setSpeechVoice(0, voice);
            if(voice == 22, {
                Speech.channels[0].volume_(-20.dbamp).speak(a['feedbacks'][~doers[0]]['comment'].asString)
            }, {
                Speech.channels[0].speak(a['feedbacks'][~doers[0]]['comment'].asString)
            });
            if(a['feedbacks'][~doers[0]]['feedback'] == 'Pos', { ~ratings.add(1) });
            if(a['feedbacks'][~doers[0]]['feedback'] == 'Neu', { ~ratings.add(0) });
            if(a['feedbacks'][~doers[0]]['feedback'] == 'Neg', { ~ratings.add(-1) });
            ~u_fbs.add(a['feedbacks'][~doers[0]]['user_feedbacks'].asInteger);
        });
    }, {
        ~restart = true;
        request = nil;
        ("curl -d \"error=nouser\" -d \"uid="++who++"\" -d \"recipient="++recipient.asString++"\" http://sound-of-ebay.com/your-notifier-script.php").unixCmd;
        "user nicht vorhanden".postln;
        neu = true;
    });
};
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.