int START::init(double p[], int n_args) { float outskip = p[0]; float dur = p[1]; float pitch = p[2]; float fdecay = p[3]; float nydecay = p[4]; float amp = p[5]; int squish = (int)p[6]; spread = p[7]; deleteflag = (int)p[8]; if (rtsetoutput(outskip, dur, this) == -1) return DONT_SCHEDULE; strumq1 = new strumq; curstrumq[0] = strumq1; float freq = cpspch(pitch); sset(SR, freq, fdecay, nydecay, strumq1); randfill(amp, squish, strumq1); amptable = floc(1); if (amptable) { int amplen = fsize(1); tableset(SR, dur, amplen, amptabs); } else { rtcmix_advise("START", "Setting phrase curve to all 1's."); aamp = 1.0; } skip = (int)(SR / (float)resetval); return nSamps(); }
int main(int argc, char *argv[]) { if (argc != 4) { printf("usage: bigdemo -create|-check count filename\n"); return 0; } int count = strtol(argv[2], NULL, 0); const char *filename = argv[3]; // Access the file, declare the layout and open a view c4_Storage storage(filename, true); c4_View vRoot = storage.GetAs("items[_B[name:S,data:B]]"); // Open the blocked version of this base view. c4_View vStuff = vRoot.Blocked(); // Declare our property accessors. c4_StringProp rName("name"); c4_BytesProp rData("data"); if (strcmp("-create", argv[1]) == 0) { // Create some data to pad out the file. char name[34]; char garbage[1024]; randfill(garbage, sizeof(garbage)); c4_Bytes data(garbage, sizeof(garbage)); // Pre-size the view to speed up the creation vStuff.SetSize(count); for (int n = 0; n < count; ++n) { sprintf_s(name, sizeof(name), "item%d", n); c4_RowRef row = vStuff[n]; rData(row) = data; rName(row) = name; } // Finally actually write this to a file. storage.Commit(); } else { char name[34]; sprintf_s(name, sizeof(name), "item%d", count); int row = vStuff.Find(rName[name]); printf("looking for '%s' returned row %d\n", name, row); if (row == -1) printf("error\n"); else printf("found '%s'\n", (const char *)rName(vStuff[row])); } return 0; }
Ostrum::Ostrum(float srate, float freq, int squish, float fundDecayTime, float nyquistDecayTime) : _srate(srate), _funddcy(fundDecayTime), _nyqdcy(nyquistDecayTime), _dcz1(0.0f) { // Size strum array so that it will work with freqs as low as kMinFreq. -JGG _dlen = int((1.0 / kMinFreq * _srate) + 0.5); _d = new float [_dlen]; _maxfreq = _srate * 0.333333f; // Prevent _d underflow. -JGG sset(freq, fundDecayTime, nyquistDecayTime); // Init this outside of sset, which may be called to change freq. -JGG _p = _n; randfill(); squisher(squish); }
int VSTART1::init(double p[], int n_args) { // p0 = start; p1 = dur; p2 = pitch (oct.pc); p3 = fundamental decay time // p4 = nyquist decay time; p5 = distortion gain; p6 = feedback gain // p7 = feedback pitch (oct.pc); p8 = clean signal level // p9 = distortion signal level; p10 = amp; p11 = squish // p12 = low vibrato freq range; p13 = hi vibrato freq range // p14 = vibrato freq depth (expressed in cps); p15 = random seed value // p16 = pitch update (default 200/sec) // p17 = stereo spread [optional] // p18 = flag for deleting pluck arrays (used by FRET, BEND, etc.) [optional] // assumes makegen 1 is the amplitude envelope, makegen 2 is the vibrato // function, and makegen 3 is the vibrato amplitude envelope if (rtsetoutput(p[0], p[1], this) == -1) return DONT_SCHEDULE; strumq1 = new StrumQueue; strumq1->ref(); curstrumq[0] = strumq1; freq = cpspch(p[2]); tf0 = p[3]; tfN = p[4]; sset(SR, freq, tf0, tfN, strumq1); randfill(1.0, (int)p[11], strumq1); dq = new DelayQueue; dq->ref(); curdelayq = dq; delayset(SR, cpspch(p[7]), dq); delayclean(dq); amp = p[10]; amptable = floc(1); if (amptable) { int amplen = fsize(1); tableset(SR, p[1], amplen, amptabs); } else { rtcmix_advise("VSTART1", "Setting phrase curve to all 1's."); aamp = amp; } vloc = floc(2); if (vloc == NULL) return die("VSTART1", "You need to store a vibrato function in gen num. 2."); vlen = fsize(2); vsibot = p[12] * (float)vlen/SR; vsidiff = vsibot - (p[13] * (float)vlen/SR); srrand((int)p[15]); vsi = ((rrand()+1.0)/2.0) * vsidiff; vsi += vsibot; vphase = 0.0; eloc = floc(3); if (eloc == NULL) return die("VSTART1", "You need to store a vibrato amp. envelope in gen num. 3."); int elen = fsize(3); tableset(SR, p[1], elen, tab); dgain = p[5]; fbgain = p[6]/dgain; cleanlevel = p[8]; distlevel = p[9]; vdepth = p[14]; reset = (int)p[16]; if (reset == 0) reset = 200; spread = p[17]; deleteflag = (int)p[18]; d = 0.0; return nSamps(); }