00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <math.h>
00017 #include <time.h>
00018
00019 #include <UT/UT_Math.h>
00020 #include <UT/UT_Floor.h>
00021 #include <OP/OP_Operator.h>
00022 #include <CH/CH_LocalVariable.h>
00023 #include <OP/OP_Node.h>
00024 #include <OP/OP_Network.h>
00025 #include <OP/OP_Director.h>
00026 #include <OP/OP_NodeFlags.h>
00027 #include <PRM/PRM_Include.h>
00028
00029 #include <CHOP/CHOP_Node.h>
00030 #include <CHOP/CHOP_Handle.h>
00031 #include <CHOP/PRM_ChopShared.h>
00032
00033 #include <OP/OP_OperatorTable.h>
00034 #include <UT/UT_DSOVersion.h>
00035
00036 #ifndef MAKING_DSO
00037 #define MAKING_DSO
00038 #endif
00039 #ifdef MAKING_DSO
00040
00041 #include "CHOP_csound_score.h"
00042
00043 #define DEBUG 0
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 OP_TemplatePair CHOP_csound_score::myTemplatePair(
00056 CHOP_csound_score::myTemplateList, &CHOP_Node::myTemplatePair);
00057
00058 OP_VariablePair CHOP_csound_score::myVariablePair(
00059 CHOP_csound_score::myVariableList, &CHOP_Node::myVariablePair);
00060
00061 enum
00062 {
00063 VAR_C = 000,
00064 VAR_NC = 001,
00065 VAR_INST_NUM = 003,
00066 VAR_DUR = 004
00067 };
00068
00069 CH_LocalVariable
00070 CHOP_csound_score::myVariableList[] = {
00071 { "C", VAR_C },
00072 { "NC", VAR_NC },
00073 { "INST_NUM", VAR_INST_NUM },
00074 { "DUR", VAR_DUR },
00075 { 0 }
00076 };
00077
00078 CHOP_SWITCHER5(14, "Setup", 15, "f-table #1", 15, "f-table #2",
00079 8, "f-table #3", 8, "f-table #4");
00080
00081
00082 static PRM_Name names[] =
00083 {
00084
00085 PRM_Name("score_fname", "Score Filename"),
00086 PRM_Name("inst", "Instrument Number"),
00087 PRM_Name("inst_name", "Instrument Name"),
00088 PRM_Name("use_inst_input", "Use instrument input"),
00089 PRM_Name("duration_override", "Override default note duration (1 second/sample rate)"),
00090 PRM_Name("duration", "Event Duration", 1),
00091 PRM_Name("use_event_gate", "Use event gate input"),
00092 PRM_Name("include_tog", "Use score include file"),
00093 PRM_Name("include_fname", "Include Score Filename"),
00094 PRM_Name("time_mode", "Add offset to note start time"),
00095 PRM_Name("time_offset", "Offset (Frames)"),
00096 PRM_Name("console_out", "Echo score to console"),
00097 PRM_Name("comment", "Comments"),
00098 PRM_Name("write_file", "Write CSound Score File"),
00099
00100
00101 PRM_Name("ftable_1_on", "Generate f-table #1"),
00102 PRM_Name("gen_num_1", "GEN Table Type"),
00103 PRM_Name("snd_fname_1", "Audio Filename"),
00104 PRM_Name("ftable_1", "f-table #"),
00105 PRM_Name("ftable_1_init", "f-table Init Time"),
00106 PRM_Name("ftable_1_len", "f-table Length"),
00107 PRM_Name("ftable_1_grd_pt", "Guard Point"),
00108 PRM_Name("ftable_1_gen_param_1", "GEN p5"),
00109 PRM_Name("ftable_1_gen_param_2", "GEN p6"),
00110 PRM_Name("ftable_1_gen_param_3", "GEN p7"),
00111 PRM_Name("ftable_1_gen_param_4", "GEN p8"),
00112 PRM_Name("ftable_1_gen_param_5", "GEN p9"),
00113 PRM_Name("ftable_1_gen_param_6", "GEN p10"),
00114 PRM_Name("ftable_1_gen_param_7", "GEN p11"),
00115 PRM_Name("ftable_1_gen_param_8", "GEN p12"),
00116
00117
00118 PRM_Name("ftable_2_on", "Generate f-table #2"),
00119 PRM_Name("gen_num_2", "GEN Table Type"),
00120 PRM_Name("snd_fname_2", "Audio Filename"),
00121 PRM_Name("ftable_2", "f-table #"),
00122 PRM_Name("ftable_2_init", "f-table Init Time"),
00123 PRM_Name("ftable_2_len", "f-table Length"),
00124 PRM_Name("ftable_2_grd_pt", "Guard Point"),
00125 PRM_Name("ftable_2_gen_param_1", "GEN p5"),
00126 PRM_Name("ftable_2_gen_param_2", "GEN p6"),
00127 PRM_Name("ftable_2_gen_param_3", "GEN p7"),
00128 PRM_Name("ftable_2_gen_param_4", "GEN p8"),
00129 PRM_Name("ftable_2_gen_param_5", "GEN p9"),
00130 PRM_Name("ftable_2_gen_param_6", "GEN p10"),
00131 PRM_Name("ftable_2_gen_param_7", "GEN p11"),
00132 PRM_Name("ftable_2_gen_param_8", "GEN p12"),
00133
00134
00135 PRM_Name("ftable_3_on", "Generate f-table #3"),
00136 PRM_Name("gen_num_3", "GEN Table Type"),
00137 PRM_Name("snd_fname_3", "Audio Filename"),
00138 PRM_Name("ftable_3", "f-table #"),
00139 PRM_Name("ftable_3_init", "f-table Init Time"),
00140 PRM_Name("ftable_3_len", "f-table Length"),
00141 PRM_Name("ftable_3_grd_pt", "Guard Point"),
00142
00143 PRM_Name("ftable_3_gen_param", "GEN parameters"),
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 PRM_Name("ftable_4_on", "Generate f-table #4"),
00156 PRM_Name("gen_num_4", "GEN Table Type"),
00157 PRM_Name("snd_fname_4", "Audio Filename"),
00158 PRM_Name("ftable_4", "f-table #"),
00159 PRM_Name("ftable_4_init", "f-table Init Time"),
00160 PRM_Name("ftable_4_len", "f-table Length"),
00161 PRM_Name("ftable_4_grd_pt", "Guard Point"),
00162
00163 PRM_Name("ftable_4_gen_param", "GEN parameters"),
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 };
00175
00176
00177 static PRM_Name CHOP_inst_nameMenu[] = {
00178 PRM_Name("000", "Other"),
00179 PRM_Name("001", "AcousticGrandPiano"),
00180 PRM_Name("002", "BrightAcousticPiano"),
00181 PRM_Name("003", "ElectricGrandPiano"),
00182 PRM_Name("004", "Honky-tonkPiano"),
00183 PRM_Name("005", "ElectricPiano1"),
00184 PRM_Name("006", "ElectricPiano2"),
00185 PRM_Name("007", "Harpsichord"),
00186 PRM_Name("008", "Clavi"),
00187 PRM_Name("009", "Celesta"),
00188 PRM_Name("010", "Glockenspiel"),
00189 PRM_Name("011", "MusicBox"),
00190 PRM_Name("012", "Vibraphone"),
00191 PRM_Name("013", "Marimba"),
00192 PRM_Name("014", "Xylophone"),
00193 PRM_Name("015", "TubularBells"),
00194 PRM_Name("016", "Dulcimer"),
00195 PRM_Name("017", "DrawbarOrgan"),
00196 PRM_Name("018", "PercussiveOrgan"),
00197 PRM_Name("019", "RockOrgan"),
00198 PRM_Name("020", "ChurchOrgan"),
00199 PRM_Name("021", "ReedOrgan"),
00200 PRM_Name("022", "Accordion"),
00201 PRM_Name("023", "Harmonica"),
00202 PRM_Name("024", "TangoAccordion"),
00203 PRM_Name("025", "AcousticGuitarNylon"),
00204 PRM_Name("026", "AcousticGuitarSteel"),
00205 PRM_Name("027", "ElectricGuitarJazz"),
00206 PRM_Name("028", "ElectricGuitarClean"),
00207 PRM_Name("029", "ElectricGuitarMuted"),
00208 PRM_Name("030", "OverdrivenGuitar"),
00209 PRM_Name("031", "DistortionGuitar"),
00210 PRM_Name("032", "GuitarHarmonics"),
00211 PRM_Name("033", "AcousticBass"),
00212 PRM_Name("034", "ElectricBassFinger"),
00213 PRM_Name("035", "ElectricBassPick"),
00214 PRM_Name("036", "FretlessBass"),
00215 PRM_Name("037", "SlapBass1"),
00216 PRM_Name("038", "SlapBass2"),
00217 PRM_Name("039", "SynthBass1"),
00218 PRM_Name("040", "SynthBass2"),
00219 PRM_Name("041", "Violin"),
00220 PRM_Name("042", "Viola"),
00221 PRM_Name("043", "Cello"),
00222 PRM_Name("044", "Contrabass"),
00223 PRM_Name("045", "TremoloStrings"),
00224 PRM_Name("046", "PizzicatoStrings"),
00225 PRM_Name("047", "OrchestralHarp"),
00226 PRM_Name("048", "Timpani"),
00227 PRM_Name("049", "StringEnsemble1"),
00228 PRM_Name("050", "StringEnsemble2"),
00229 PRM_Name("051", "SynthStrings1"),
00230 PRM_Name("052", "SynthStrings2"),
00231 PRM_Name("053", "ChoirAhhs"),
00232 PRM_Name("054", "VoiceOohs"),
00233 PRM_Name("055", "SynthVoice"),
00234 PRM_Name("056", "OrchestraHit"),
00235 PRM_Name("057", "Trumpet"),
00236 PRM_Name("058", "Trombone"),
00237 PRM_Name("059", "Tuba"),
00238 PRM_Name("060", "MutedTrumpet"),
00239 PRM_Name("061", "FrenchHorn"),
00240 PRM_Name("062", "BrassSection"),
00241 PRM_Name("063", "SynthBrass1"),
00242 PRM_Name("064", "SynthBrass2"),
00243 PRM_Name("065", "SopranoSax"),
00244 PRM_Name("066", "AltoSax"),
00245 PRM_Name("067", "TenorSax"),
00246 PRM_Name("068", "BaritoneSax"),
00247 PRM_Name("069", "Oboe"),
00248 PRM_Name("070", "EnglishHorn"),
00249 PRM_Name("071", "Bassoon"),
00250 PRM_Name("072", "Clarinet"),
00251 PRM_Name("073", "Piccolo"),
00252 PRM_Name("074", "Flute"),
00253 PRM_Name("075", "Recorder"),
00254 PRM_Name("076", "PanFlute"),
00255 PRM_Name("077", "BlownBottle"),
00256 PRM_Name("078", "Shakuhachi"),
00257 PRM_Name("079", "Whistle"),
00258 PRM_Name("080", "Ocarina"),
00259 PRM_Name("081", "Lead1Square"),
00260 PRM_Name("082", "Lead2SawTooth"),
00261 PRM_Name("083", "Lead3Calliope"),
00262 PRM_Name("084", "Lead4Chiff"),
00263 PRM_Name("085", "Lead5Charang"),
00264 PRM_Name("086", "Lead6Voice"),
00265 PRM_Name("087", "Lead7Fifths"),
00266 PRM_Name("088", "Lead8Bass+Lead"),
00267 PRM_Name("089", "Pad1NewAge"),
00268 PRM_Name("090", "Pad2Warm"),
00269 PRM_Name("091", "Pad3PolySynth"),
00270 PRM_Name("092", "Pad4Choir"),
00271 PRM_Name("093", "Pad5Bowed"),
00272 PRM_Name("094", "Pad6Metallic"),
00273 PRM_Name("095", "Pad7Halo"),
00274 PRM_Name("096", "Pad8Sweep"),
00275 PRM_Name("097", "FX1Rain"),
00276 PRM_Name("098", "FX2Soundtrack"),
00277 PRM_Name("099", "FX3Crystal"),
00278 PRM_Name("100", "FX4Atmosphere"),
00279 PRM_Name("101", "FX5Brightness"),
00280 PRM_Name("102", "FX6Goblins"),
00281 PRM_Name("103", "FX7Echoes"),
00282 PRM_Name("104", "FX8Sci-Fi"),
00283 PRM_Name("105", "Sitar"),
00284 PRM_Name("106", "Banjo"),
00285 PRM_Name("107", "Shamisen"),
00286 PRM_Name("108", "Koto"),
00287 PRM_Name("109", "Kalimba"),
00288 PRM_Name("110", "Bagpipe"),
00289 PRM_Name("111", "Fiddle"),
00290 PRM_Name("112", "Shanai"),
00291 PRM_Name("113", "TinkleBell"),
00292 PRM_Name("114", "Agogo"),
00293 PRM_Name("115", "SteelDrums"),
00294 PRM_Name("116", "Woodblock"),
00295 PRM_Name("117", "TaikoDrum"),
00296 PRM_Name("118", "MelodicTom"),
00297 PRM_Name("119", "SynthDrum"),
00298 PRM_Name("120", "ReverseCymbal"),
00299 PRM_Name("121", "GuitarFretNoise"),
00300 PRM_Name("122", "BreathNoise"),
00301 PRM_Name("123", "Seashore"),
00302 PRM_Name("124", "BirdTweet"),
00303 PRM_Name("125", "TelephoneRing"),
00304 PRM_Name("126", "Helicopter"),
00305 PRM_Name("127", "Applause"),
00306
00307 PRM_Name(0),
00308 };
00309
00310
00311 static PRM_Name CHOP_GEN_type_Menu[] = {
00312 PRM_Name("001", "1-Soundfile"),
00313 PRM_Name("002", "2-Numeric Value Access"),
00314 PRM_Name("003", "3-Waveshaping Polynomials"),
00315 PRM_Name("004", "4-Amplitude Normalization"),
00316 PRM_Name("005", "5-Exponential Segment"),
00317 PRM_Name("006", "6-Cubic Segment"),
00318 PRM_Name("007", "7-Line Segment"),
00319 PRM_Name("008", "8-Spline Segment"),
00320 PRM_Name("009", "9-Sine"),
00321 PRM_Name("010", "10-Sine"),
00322 PRM_Name("011", "11-Cosine"),
00323 PRM_Name("012", "12-Amplitude Normalization"),
00324 PRM_Name("013", "13-Waveshaping-Chebyshev first order"),
00325 PRM_Name("014", "14-Waveshaping-Chebyshev second order"),
00326 PRM_Name("015", "15-Waveshaping-phase-quadrature"),
00327 PRM_Name("017", "17-Numeric Value Access"),
00328 PRM_Name("019", "19-Sine"),
00329 PRM_Name("020", "20-Window Function"),
00330 PRM_Name("021", "21-Random Function"),
00331 PRM_Name("023", "23-External File"),
00332 PRM_Name("025", "25-Line/Exponential Segment"),
00333 PRM_Name("027", "27-Line/Exponential Segment"),
00334
00335 PRM_Name(0),
00336 };
00337
00338
00339 static PRM_Name CHOP_f_table_len_Menu[] = {
00340 PRM_Name("128", "128"),
00341 PRM_Name("256", "256"),
00342 PRM_Name("512", "512"),
00343 PRM_Name("1024", "1024"),
00344 PRM_Name("2048", "2048"),
00345 PRM_Name("4096", "4096"),
00346 PRM_Name("8192", "8192"),
00347 PRM_Name("16384", "16384"),
00348 PRM_Name("32768", "32768"),
00349 PRM_Name("65536", "65536"),
00350
00351 PRM_Name(0),
00352 };
00353
00354 static PRM_ChoiceList inst_nameMenu((PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE | PRM_CHOICELIST_REPLACE), CHOP_inst_nameMenu);
00355 static PRM_ChoiceList GEN_type_Menu((PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE | PRM_CHOICELIST_REPLACE), CHOP_GEN_type_Menu);
00356 static PRM_ChoiceList f_table_len_Menu((PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE | PRM_CHOICELIST_REPLACE), CHOP_f_table_len_Menu);
00357
00358 static PRM_Range offsetRange(PRM_RANGE_RESTRICTED, -65535, PRM_RANGE_UI, 65536);
00359
00360
00361 static PRM_Default Default_score_fname(0,"untitled.sco");
00362 static PRM_Default Default_include_fname(0, "csound_header.h");
00363 static PRM_Default Default_comment(0,"Comments");
00364
00365
00366 static PRM_Default Default_snd_fname_1(0,"untitled.aiff");
00367 static PRM_Default Default_ftable_1_len(0,"1024");
00368
00369
00370 static PRM_Default Default_snd_fname_2(0,"untitled.aiff");
00371 static PRM_Default Default_ftable_2_len(0,"1024");
00372
00373
00374 static PRM_Default Default_snd_fname_3(0,"untitled.aiff");
00375 static PRM_Default Default_ftable_3_len(0,"1024");
00376 static PRM_Default Default_ftable_3_gen_parm(0,"0 1 0 1 0 1 0 1 0 1");
00377
00378
00379 static PRM_Default Default_snd_fname_4(0,"untitled.aiff");
00380 static PRM_Default Default_ftable_4_len(0,"1024");
00381 static PRM_Default Default_ftable_4_gen_parm(0,"0 1 0 1 0 1 0 1 0 1");
00382
00383 PRM_Template
00384 CHOP_csound_score::myTemplateList[] =
00385 {
00386 PRM_Template(PRM_SWITCHER, 6, &PRMswitcherName, switcher),
00387
00388
00389
00390
00391 PRM_Template(PRM_FILE, 1, &names[0], &Default_score_fname, 0),
00392
00393
00394 PRM_Template(PRM_INT_J, 1, &names[1], PRMzeroDefaults, 0),
00395
00396
00397 PRM_Template(PRM_ORD, 1, &names[2], PRMzeroDefaults, &inst_nameMenu),
00398
00399
00400 PRM_Template(PRM_TOGGLE, 1, &names[3], PRMzeroDefaults, 0),
00401
00402
00403 PRM_Template(PRM_TOGGLE, 1, &names[4], PRMzeroDefaults, 0),
00404
00405
00406 PRM_Template(PRM_FLT_J, 1, &names[5], PRMoneDefaults, 0),
00407
00408
00409 PRM_Template(PRM_TOGGLE, 1, &names[6], PRMzeroDefaults, 0),
00410
00411
00412 PRM_Template(PRM_TOGGLE, 1, &names[7], PRMzeroDefaults, 0),
00413
00414
00415 PRM_Template(PRM_FILE, 1, &names[8], &Default_include_fname, 0),
00416
00417
00418 PRM_Template(PRM_TOGGLE, 1, &names[9], PRMoneDefaults, 0),
00419
00420
00421 PRM_Template(PRM_FLT_J, 1, &names[10], PRMzeroDefaults, 0, &offsetRange),
00422
00423
00424 PRM_Template(PRM_TOGGLE, 1, &names[11], PRMzeroDefaults, 0),
00425
00426
00427 PRM_Template(PRM_STRING, 1, &names[12], &Default_comment, 0),
00428
00429 PRM_Template(PRM_CALLBACK, 1, &names[13], 0, 0, 0,
00430 CHOP_csound_score::writeTheFile),
00431
00432
00433
00434
00435
00436 PRM_Template(PRM_TOGGLE, 1, &names[parm_setup_offset + 0],
00437 PRMzeroDefaults, 0),
00438
00439 PRM_Template(PRM_ORD, 1, &names[parm_setup_offset + 1],
00440 PRMzeroDefaults,
00441 &GEN_type_Menu),
00442
00443 PRM_Template(PRM_FILE, 1, &names[parm_setup_offset + 2],
00444 &Default_snd_fname_1, 0),
00445
00446 PRM_Template(PRM_INT_J, 1, &names[parm_setup_offset + 3],
00447 PRMzeroDefaults, 0),
00448
00449 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 4],
00450 PRMzeroDefaults, 0),
00451
00452 PRM_Template(PRM_ORD, 1, &names[parm_setup_offset + 5],
00453 &Default_ftable_1_len,
00454 &f_table_len_Menu),
00455
00456 PRM_Template(PRM_TOGGLE, 1, &names[parm_setup_offset + 6],
00457 PRMzeroDefaults, 0),
00458
00459 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 7],
00460 PRMzeroDefaults, 0),
00461
00462 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 8],
00463 PRMzeroDefaults, 0),
00464
00465 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 9],
00466 PRMzeroDefaults, 0),
00467
00468 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 10],
00469 PRMzeroDefaults, 0),
00470
00471 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 11],
00472 PRMzeroDefaults, 0),
00473
00474 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 12],
00475 PRMzeroDefaults, 0),
00476
00477 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 13],
00478 PRMzeroDefaults, 0),
00479
00480 PRM_Template(PRM_FLT_J, 1, &names[parm_setup_offset + 14],
00481 PRMzeroDefaults, 0),
00482
00483
00484
00485
00486 PRM_Template(PRM_TOGGLE, 1, &names[parm_f1_offset + 0],
00487 PRMzeroDefaults, 0),
00488
00489 PRM_Template(PRM_ORD, 1, &names[parm_f1_offset + 1],
00490 PRMzeroDefaults,
00491 &GEN_type_Menu),
00492
00493 PRM_Template(PRM_FILE, 1, &names[parm_f1_offset + 2],
00494 &Default_snd_fname_2, 0),
00495
00496 PRM_Template(PRM_INT_J, 1, &names[parm_f1_offset + 3],
00497 PRMzeroDefaults, 0),
00498
00499 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 4],
00500 PRMzeroDefaults, 0),
00501
00502 PRM_Template(PRM_ORD, 1, &names[parm_f1_offset + 5],
00503 &Default_ftable_2_len,
00504 &f_table_len_Menu),
00505
00506 PRM_Template(PRM_TOGGLE, 1, &names[parm_f1_offset + 6],
00507 PRMzeroDefaults, 0),
00508
00509 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 7],
00510 PRMzeroDefaults, 0),
00511
00512 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 8],
00513 PRMzeroDefaults, 0),
00514
00515 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 9],
00516 PRMzeroDefaults, 0),
00517
00518 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 10],
00519 PRMzeroDefaults, 0),
00520
00521 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 11],
00522 PRMzeroDefaults, 0),
00523
00524 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 12],
00525 PRMzeroDefaults, 0),
00526
00527 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 13],
00528 PRMzeroDefaults, 0),
00529
00530 PRM_Template(PRM_FLT_J, 1, &names[parm_f1_offset + 14],
00531 PRMzeroDefaults, 0),
00532
00533
00534
00535
00536 PRM_Template(PRM_TOGGLE, 1, &names[parm_f2_offset + 0],
00537 PRMzeroDefaults, 0),
00538
00539 PRM_Template(PRM_ORD, 1, &names[parm_f2_offset + 1],
00540 PRMzeroDefaults,
00541 &GEN_type_Menu),
00542
00543 PRM_Template(PRM_FILE, 1, &names[parm_f2_offset + 2],
00544 &Default_snd_fname_3, 0),
00545
00546 PRM_Template(PRM_INT_J, 1, &names[parm_f2_offset + 3],
00547 PRMzeroDefaults, 0),
00548
00549 PRM_Template(PRM_FLT_J, 1, &names[parm_f2_offset + 4],
00550 PRMzeroDefaults, 0),
00551
00552 PRM_Template(PRM_ORD, 1, &names[parm_f2_offset + 5],
00553 &Default_ftable_3_len,
00554 &f_table_len_Menu),
00555
00556 PRM_Template(PRM_TOGGLE, 1, &names[parm_f2_offset + 6],
00557 PRMzeroDefaults, 0),
00558
00559 PRM_Template(PRM_STRING, 1, &names[parm_f2_offset + 7],
00560 &Default_ftable_3_gen_parm, 0),
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592 PRM_Template(PRM_TOGGLE, 1, &names[parm_f3_offset + 0],
00593 PRMzeroDefaults, 0),
00594
00595 PRM_Template(PRM_ORD, 1, &names[parm_f3_offset + 1],
00596 PRMzeroDefaults,
00597 &GEN_type_Menu),
00598
00599 PRM_Template(PRM_FILE, 1, &names[parm_f3_offset + 2],
00600 &Default_snd_fname_4, 0),
00601
00602 PRM_Template(PRM_INT_J, 1, &names[parm_f3_offset + 3],
00603 PRMzeroDefaults, 0),
00604
00605 PRM_Template(PRM_FLT_J, 1, &names[parm_f3_offset + 4],
00606 PRMzeroDefaults, 0),
00607
00608 PRM_Template(PRM_ORD, 1, &names[parm_f3_offset + 5],
00609 &Default_ftable_4_len,
00610 &f_table_len_Menu),
00611
00612 PRM_Template(PRM_TOGGLE, 1, &names[parm_f3_offset + 6],
00613 PRMzeroDefaults, 0),
00614
00615 PRM_Template(PRM_STRING, 1, &names[parm_f3_offset + 7],
00616 &Default_ftable_4_gen_parm, 0),
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645 PRM_Template(),
00646 };
00647
00648 OP_Node *
00649 CHOP_csound_score::myConstructor(OP_Network *net,
00650 const char *name,
00651 OP_Operator *op)
00652 {
00653 return new CHOP_csound_score(net, name, op);
00654 }
00655
00656
00657
00658 void
00659 newChopOperator(OP_OperatorTable *table)
00660 {
00661 table->addOperator(
00662 new OP_Operator("csound_score",
00663 "CSound Score Generator",
00664 CHOP_csound_score::myConstructor,
00665 &CHOP_csound_score::myTemplatePair,
00666 1,
00667 3,
00668 &CHOP_csound_score::myVariablePair)
00669 );
00670 }
00671
00672 #endif
00673
00674
00675
00676 CHOP_csound_score::CHOP_csound_score( OP_Network *net,
00677 const char *name,
00678 OP_Operator *op)
00679 : CHOP_Node(net, name, op),
00680 myExpandArray()
00681 {
00682 myParmBase = getParmList()->getParmIndex( names[0].getToken() );
00683
00684
00685 my_C = 0;
00686 my_NC = 0;
00687 my_INST_NUM = 0;
00688 my_DUR = 0;
00689
00690
00691 score_fname = "untitled.sco";
00692 inst = 101;
00693 inst_name = 0;
00694 use_inst_in = 0;
00695 dur_override = 0;
00696 duration = 0.033333333;
00697 use_event_gate = 0;
00698 inc_tog = 0;
00699 inc_fname = "csound_header.h";
00700 console_out = 0;
00701 comment = "Comments";
00702
00703
00704 snd_fname_1 = "";
00705 ftable_1_on = 0;
00706 ftable_1 = 1;
00707 gen_num_1 = 0;
00708 ftable_1_init = 0;
00709 ftable_1_len = 0;
00710 ftable_1_grd_pt = 0;
00711 ftable_1_gen_param_1 = 0;
00712 ftable_1_gen_param_2 = 0;
00713 ftable_1_gen_param_3 = 0;
00714 ftable_1_gen_param_4 = 0;
00715 ftable_1_gen_param_5 = 0;
00716 ftable_1_gen_param_6 = 0;
00717 ftable_1_gen_param_7 = 0;
00718 ftable_1_gen_param_8 = 0;
00719
00720
00721 snd_fname_2 = "";
00722 ftable_2_on = 0;
00723 ftable_2 = 2;
00724 gen_num_2 = 0;
00725 ftable_2_init = 0;
00726 ftable_2_len = 0;
00727 ftable_2_grd_pt = 0;
00728 ftable_2_gen_param_1 = 0;
00729 ftable_2_gen_param_2 = 0;
00730 ftable_2_gen_param_3 = 0;
00731 ftable_2_gen_param_4 = 0;
00732 ftable_2_gen_param_5 = 0;
00733 ftable_2_gen_param_6 = 0;
00734 ftable_2_gen_param_7 = 0;
00735 ftable_2_gen_param_8 = 0;
00736
00737
00738 snd_fname_3 = "";
00739 ftable_3_on = 0;
00740 ftable_3 = 3;
00741 gen_num_3 = 0;
00742 ftable_3_init = 0;
00743 ftable_3_len = 0;
00744 ftable_3_grd_pt = 0;
00745 ftable_3_gen_param = "";
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759 snd_fname_4 = "";
00760 ftable_4_on = 0;
00761 ftable_4 = 4;
00762 gen_num_4 = 0;
00763 ftable_4_init = 0;
00764 ftable_4_len = 0;
00765 ftable_4_grd_pt = 0;
00766 ftable_4_gen_param = "";
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788 if(DEBUG > 0) {
00789 printf("\n**** CHOP CSound Score DSO ****\n");
00790 printf("**** CONSTRUCTOR ****\n\n");
00791
00792 printf("score fname: %s\n", (const char *)score_fname);
00793 printf("inst: %d\n", inst);
00794 printf("inst_name: %d\n", inst_name);
00795 printf("use_inst_in: %d\n", use_inst_in);
00796 printf("duration override: %d\n", dur_override);
00797 printf("event duration: %f\n", duration);
00798 printf("use_event_gate: %d\n", use_event_gate);
00799 printf("include toggle: %d\n", inc_tog);
00800 printf("include fname: %s\n", (const char *)inc_fname);
00801 printf("console out: %d\n", console_out);
00802 printf("comment: %s\n", (const char *)comment);
00803
00804 }
00805
00806 }
00807
00808 CHOP_csound_score::~CHOP_csound_score()
00809 {
00810 if(DEBUG > 0) {
00811 printf("\n**** CHOP CSound Score DSO ****\n");
00812 printf("**** DESTRUCTOR ****\n\n");
00813 }
00814 }
00815
00816 unsigned
00817 CHOP_csound_score::disableParms()
00818 {
00819 unsigned changes = CHOP_Node::disableParms();
00820
00821 return changes;
00822 }
00823
00824
00825
00826
00827 bool
00828 CHOP_csound_score::writeHeader(FILE *fp)
00829 {
00830 struct tm *time_ptr;
00831 time_t create_time;
00832 FILE *inc_fp;
00833
00834
00835 create_time = time(NULL);
00836 time_ptr = localtime(&create_time);
00837 char str[255];
00838 char ftable_1_str[255] = "";
00839 char ftable_2_str[255] = "";
00840 char ftable_3_str[255] = "";
00841 char ftable_4_str[255] = "";
00842
00843
00844 if(ftable_1_on) {
00845 if((gen_num_1 == 1) || (gen_num_1 == 23)) {
00846 sprintf(ftable_1_str, "f%d\t%f\t%d\t%s\n",
00847 ftable_1, ftable_1_init,
00848 gen_num_1, (const char *)snd_fname_1);
00849 }
00850 else {
00851 sprintf(ftable_1_str,
00852 "f%d\t%f\t%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n",
00853 ftable_1, ftable_1_init, ftable_1_len, gen_num_1,
00854 ftable_1_gen_param_1, ftable_1_gen_param_2,
00855 ftable_1_gen_param_3, ftable_1_gen_param_4,
00856 ftable_1_gen_param_5, ftable_1_gen_param_6,
00857 ftable_1_gen_param_7, ftable_1_gen_param_8);
00858 }
00859 }
00860
00861 if(ftable_2_on) {
00862 if((gen_num_2 == 1) || (gen_num_2 == 23)) {
00863 sprintf(ftable_2_str, "f%d\t%f\t%d\t%s\n",
00864 ftable_2, ftable_2_init,
00865 gen_num_2, (const char *)snd_fname_2);
00866 }
00867 else {
00868 sprintf(ftable_2_str,
00869 "f%d\t%f\t%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n",
00870 ftable_2, ftable_2_init, ftable_2_len, gen_num_2,
00871 ftable_2_gen_param_1, ftable_2_gen_param_2,
00872 ftable_2_gen_param_3, ftable_2_gen_param_4,
00873 ftable_2_gen_param_5, ftable_2_gen_param_6,
00874 ftable_2_gen_param_7, ftable_2_gen_param_8);
00875 }
00876 }
00877
00878 if(ftable_3_on) {
00879 if((gen_num_3 == 1) || (gen_num_3 == 23)) {
00880 sprintf(ftable_3_str, "f%d\t%f\t%d\t%s\n",
00881 ftable_3, ftable_3_init,
00882 gen_num_3, (const char *)snd_fname_3);
00883 }
00884 else {
00885 sprintf(ftable_3_str,
00886
00887 "f%d\t%f\t%d\t%d\t%s\n",
00888 ftable_3, ftable_3_init, ftable_3_len, gen_num_3,
00889 (const char *)ftable_3_gen_param);
00890
00891
00892
00893
00894
00895
00896
00897 }
00898 }
00899
00900 if(ftable_4_on) {
00901 if((gen_num_4 == 1) || (gen_num_4 == 23)) {
00902 sprintf(ftable_4_str, "f%d\t%f\t%d\t%s\n",
00903 ftable_4, ftable_4_init,
00904 gen_num_4, (const char *)snd_fname_4);
00905 }
00906 else {
00907 sprintf(ftable_4_str,
00908
00909 "f%d\t%f\t%d\t%d\t%s\n",
00910 ftable_4, ftable_4_init, ftable_4_len, gen_num_4,
00911 (const char *)ftable_4_gen_param);
00912
00913
00914
00915
00916
00917
00918
00919 }
00920 }
00921
00922
00923 if((DEBUG > 0) || console_out) {
00924 printf("; CSound Score generated by DCA CSound Score Generator CHOP \n");
00925 printf("; %s\n", asctime(time_ptr));
00926 printf("; %s\n\n", (const char *)comment);
00927
00928 printf("%s%s%s%s\n",
00929 ftable_1_str, ftable_2_str, ftable_3_str, ftable_4_str);
00930 }
00931
00932 fprintf(fp, "; CSound Score generated by DCA CSound Score Generator CHOP\n");
00933 fprintf(fp, "; %s\n", asctime(time_ptr));
00934 fprintf(fp, "; %s\n", (const char *)comment);
00935 fprintf(fp, "%s%s%s%s\n",
00936 ftable_1_str, ftable_2_str, ftable_3_str, ftable_4_str);
00937
00938
00939 if(inc_tog) {
00940 fprintf(fp, "; CSound score include file: %s\n\n",
00941 (const char *)inc_fname);
00942
00943 if((DEBUG > 0) || console_out) {
00944 printf("; CSound score include file: %s\n\n",
00945 (const char *)inc_fname);
00946 }
00947
00948
00949 if((inc_fp=fopen(inc_fname,"r")) == NULL) {
00950 cout.setf(ios::unitbuf);
00951 cout << "Cannot open score include file for reading\n";
00952 addError(CHOP_ERROR_MESSAGE);
00953 return false;
00954 }
00955
00956 while(!feof(inc_fp)) {
00957 if(fgets(str, 255, inc_fp))
00958 if((DEBUG > 0) || console_out) { printf("%s", str); }
00959 fprintf(fp, str);
00960 }
00961 fclose(inc_fp);
00962 }
00963
00964 fflush(fp);
00965 return true;
00966 }
00967
00968
00969
00970 void
00971 CHOP_csound_score::getUIParms(OP_Context &context)
00972 {
00973 UT_String menu_str = "";
00974
00975
00976 SCORE_FNAME(score_fname, context.myTime);
00977 inst = INST(context.myTime);
00978 inst_name = INST_NAME(context.myTime);
00979
00980 if(inst_name != 0) {
00981 inst = inst_name;
00982 SET_INST(context.myTime, inst_name);
00983 }
00984
00985
00986 use_inst_in = USE_INST_IN(context.myTime);
00987 dur_override = DUR_OVERRIDE(context.myTime);
00988 if(dur_override)
00989 duration = DURATION(context.myTime);
00990 use_event_gate = USE_EVENT_GATE(context.myTime);
00991 inc_tog = INC_TOG(context.myTime);
00992 INC_FNAME(inc_fname, context.myTime);
00993 time_mode = TIME_MODE(context.myTime);
00994 time_offset = TIME_OFFSET(context.myTime);
00995 console_out = CONSOLE_OUT(context.myTime);
00996 COMMENT(comment, context.myTime);
00997
00998
00999
01000 SND_FNAME_1(snd_fname_1, context.myTime);
01001 ftable_1_on = FTBL_1_ON(context.myTime);
01002 ftable_1 = FTBL_1(context.myTime);
01003 GEN_NUM_1(menu_str, context.myTime);
01004 gen_num_1 = atoi((const char *)menu_str);
01005 ftable_1_init = FTBL_1_INIT(context.myTime);
01006 FTBL_1_LEN(menu_str, context.myTime);
01007 ftable_1_len = atoi((const char *)menu_str);
01008 ftable_1_grd_pt = FTBL_1_GRD_PT(context.myTime);
01009 if(ftable_1_grd_pt)
01010 ftable_1_len += 1;
01011 ftable_1_gen_param_1 = FTBL_1_GEN_PARM1(context.myTime);
01012 ftable_1_gen_param_2 = FTBL_1_GEN_PARM2(context.myTime);
01013 ftable_1_gen_param_3 = FTBL_1_GEN_PARM3(context.myTime);
01014 ftable_1_gen_param_4 = FTBL_1_GEN_PARM4(context.myTime);
01015 ftable_1_gen_param_5 = FTBL_1_GEN_PARM5(context.myTime);
01016 ftable_1_gen_param_6 = FTBL_1_GEN_PARM6(context.myTime);
01017 ftable_1_gen_param_7 = FTBL_1_GEN_PARM7(context.myTime);
01018 ftable_1_gen_param_8 = FTBL_1_GEN_PARM8(context.myTime);
01019
01020
01021
01022 SND_FNAME_2(snd_fname_2, context.myTime);
01023 ftable_2_on = FTBL_2_ON(context.myTime);
01024 ftable_2 = FTBL_2(context.myTime);
01025 GEN_NUM_2(menu_str, context.myTime);
01026 gen_num_2 = atoi((const char *)menu_str);
01027 ftable_2_init = FTBL_2_INIT(context.myTime);
01028 FTBL_2_LEN(menu_str, context.myTime);
01029 ftable_2_len = atoi((const char *)menu_str);
01030 ftable_2_grd_pt = FTBL_2_GRD_PT(context.myTime);
01031 if(ftable_2_grd_pt)
01032 ftable_2_len += 1;
01033 ftable_2_gen_param_1 = FTBL_2_GEN_PARM1(context.myTime);
01034 ftable_2_gen_param_2 = FTBL_2_GEN_PARM2(context.myTime);
01035 ftable_2_gen_param_3 = FTBL_2_GEN_PARM3(context.myTime);
01036 ftable_2_gen_param_4 = FTBL_2_GEN_PARM4(context.myTime);
01037 ftable_2_gen_param_5 = FTBL_2_GEN_PARM5(context.myTime);
01038 ftable_2_gen_param_6 = FTBL_2_GEN_PARM6(context.myTime);
01039 ftable_2_gen_param_7 = FTBL_2_GEN_PARM7(context.myTime);
01040 ftable_2_gen_param_8 = FTBL_2_GEN_PARM8(context.myTime);
01041
01042
01043
01044 SND_FNAME_3(snd_fname_3, context.myTime);
01045 ftable_3_on = FTBL_3_ON(context.myTime);
01046 ftable_3 = FTBL_3(context.myTime);
01047 GEN_NUM_3(menu_str, context.myTime);
01048 gen_num_3 = atoi((const char *)menu_str);
01049 ftable_3_init = FTBL_3_INIT(context.myTime);
01050 FTBL_3_LEN(menu_str, context.myTime);
01051 ftable_3_len = atoi((const char *)menu_str);
01052 ftable_3_grd_pt = FTBL_3_GRD_PT(context.myTime);
01053 if(ftable_3_grd_pt)
01054 ftable_3_len += 1;
01055
01056 FTBL_3_GEN_PARM(ftable_3_gen_param, context.myTime);
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071 SND_FNAME_4(snd_fname_4, context.myTime);
01072 ftable_4_on = FTBL_4_ON(context.myTime);
01073 ftable_4 = FTBL_4(context.myTime);
01074 GEN_NUM_4(menu_str, context.myTime);
01075 gen_num_4 = atoi((const char *)menu_str);
01076 ftable_4_init = FTBL_4_INIT(context.myTime);
01077 FTBL_4_LEN(menu_str, context.myTime);
01078 ftable_4_len = atoi((const char *)menu_str);
01079 ftable_4_grd_pt = FTBL_4_GRD_PT(context.myTime);
01080 if(ftable_4_grd_pt)
01081 ftable_4_len += 1;
01082
01083 FTBL_4_GEN_PARM(ftable_4_gen_param, context.myTime);
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097 }
01098
01099
01100 OP_ERROR
01101 CHOP_csound_score::cookMyChop(OP_Context &context)
01102 {
01103 CL_Track *track;
01104 const CL_Clip *parent_clip;
01105 const CL_Track *parent_track;
01106 const CL_Clip *event_clip;
01107 const CL_Track *event_track;
01108 const CL_Clip *inst_clip;
01109 const CL_Track *inst_track;
01110 float *data;
01111 const float *event_data;
01112 const float *inst_data;
01113 float _data[MAX_CHANNELS];
01114 int event_NC = 0;
01115 int inst_NC = 0;
01116 int parent_NC = 0;
01117 int event_gate = 1;
01118
01119 int i = 0, j = 0;
01120 int trk_len = 0;
01121 FILE *fp;
01122 char str[255];
01123
01124 for(i=0; i < MAX_CHANNELS; i++) { _data[i] = 0; }
01125
01126
01127 getUIParms(context);
01128
01129
01130 my_DUR = duration;
01131 my_INST_NUM = inst;
01132
01133 if(DEBUG > 0) {
01134 printf("\n**** CHOP CSound Score DSO ****\n");
01135 printf("**** COOK MY CHOP ****\n\n");
01136 printf("context.myTime: %f \n", context.myTime);
01137 printf("track length: %d\n", myClip->getTrackLength());
01138
01139 printf("score fname: %s\n", (const char *)score_fname);
01140 printf("inst: %d\n", inst);
01141 printf("inst_name: %d\n", inst_name);
01142 printf("use_inst_in: %d\n", use_inst_in);
01143 printf("duration override: %d\n", dur_override);
01144 printf("event duration: %f\n", duration);
01145 printf("use_event_gate: %d\n", use_event_gate);
01146 printf("include toggle: %d\n", inc_tog);
01147 printf("include fname: %s\n", (const char *)inc_fname);
01148 printf("console out: %d\n", console_out);
01149 printf("comment: %s\n", (const char *)comment);
01150
01151 printf("f-table #1 len: %d\n", ftable_1_len);
01152 printf("GEN #1 : %d\n", gen_num_1);
01153
01154 printf("f-table #2 len: %d\n", ftable_2_len);
01155 printf("GEN #2 : %d\n", gen_num_2);
01156
01157 printf("f-table #3 len: %d\n", ftable_3_len);
01158 printf("GEN #3 : %d\n", gen_num_3);
01159
01160 printf("f-table #4 len: %d\n", ftable_4_len);
01161 printf("GEN #4 : %d\n", gen_num_4);
01162
01163 }
01164
01165
01166 if((fp=fopen(score_fname,"wa")) == NULL) {
01167 cerr.setf(ios::unitbuf);
01168 cerr << "Cannot open text file for writing\n";
01169
01170 addWarning(CHOP_ERROR_MESSAGE, "Cannot open text file for writing");
01171 addError(CHOP_ERROR_MESSAGE);
01172 return error();
01173 }
01174
01175
01176 parent_clip = copyInput(context, 0, 1, 1);
01177
01178 parent_NC = parent_clip->getNumTracks();
01179 my_NC = myClip->getNumTracks();
01180 trk_len = myClip->getTrackLength();
01181
01182 if(!dur_override)
01183 duration = (1/myClip->getSampleRate());
01184
01185 if(DEBUG > 1) {
01186 printf("my_NC = %d\n", my_NC);
01187 printf("trk_len = %d\n", trk_len);
01188 }
01189
01190
01191 if(my_NC > MAX_CHANNELS) {
01192 addWarning(CHOP_ERROR_MESSAGE, "Too many input channels");
01193 addError(CHOP_ERROR_MESSAGE);
01194 return error();
01195 }
01196
01197 if(DEBUG > 0) {
01198 UT_String this_chop_path;
01199
01200 printf("number of connected inputs: %d\n", nConnectedInputs());
01201 getFullPath(this_chop_path);
01202 printf("Full path: %s\n", (const char *)this_chop_path);
01203 printf("parent_NC = %d\n", parent_NC);
01204 printf("my_NC = %d\n", my_NC);
01205 }
01206
01207
01208 if (use_inst_in) {
01209
01210 inst_clip = inputClip(1, context);
01211 if (!inst_clip) {
01212 addError(OP_ERR_NUMSRC_TOO_FEW);
01213 return error();
01214 }
01215 inst_NC = inst_clip->getNumTracks();
01216 inst_track = inst_clip->getTrack(0);
01217 inst_data = inst_track->getData();
01218 if(DEBUG > 1) { printf("inst_NC = %d\n", inst_NC); }
01219 }
01220
01221
01222
01223 if (use_event_gate) {
01224
01225 event_clip = inputClip(2, context);
01226 if (!event_clip) {
01227 addError(OP_ERR_NUMSRC_TOO_FEW);
01228 return error();
01229 }
01230 event_NC = event_clip->getNumTracks();
01231 event_track = event_clip->getTrack(0);
01232 event_data = event_track->getData();
01233 if(DEBUG > 1) { printf("event_NC = %d\n", event_NC); }
01234 }
01235 else {
01236
01237 event_gate = 1;
01238 }
01239
01240
01241 if(!writeHeader(fp)) {
01242 return error();
01243 }
01244
01245
01246 for(i=0; i < trk_len; i++) {
01247
01248
01249 if (use_event_gate)
01250 event_gate = (int)event_data[i];
01251
01252
01253 if(event_gate != 0) {
01254
01255 if (use_inst_in)
01256 inst = (int)inst_data[i];
01257
01258
01259 fprintf(fp, "i %d\t%.8f\t%.8f\t", inst, (myClip->getFrame(time_mode ? (i + time_offset) : i,
01260 myClip->getSampleRate()) - 1)/myClip->getSampleRate(), duration);
01261
01262 if(console_out)
01263 printf("i %d\t%.8f\t%.8f\t", inst, (myClip->getFrame(time_mode ? (i + time_offset) : i,
01264 myClip->getSampleRate()) - 1)/myClip->getSampleRate(), duration);
01265
01266 if(DEBUG > 1) {
01267 printf("i %d\t%.8f\t%.8f\n", inst, (myClip->getFrame(time_mode ? (i + time_offset) : i,
01268 myClip->getSampleRate()) - 1)/myClip->getSampleRate(), duration);
01269 printf("event_gate = %d\n", event_gate);
01270 }
01271
01272
01273 for(my_C = 0; my_C < my_NC; my_C++) {
01274
01275
01276 track = myClip->getTrack(my_C);
01277
01278
01279 data = track->getData();
01280
01281 _data[my_C] = data[i];
01282
01283 fprintf(fp, "%f\t", _data[my_C]);
01284
01285 if(console_out)
01286 printf("%f\t", _data[my_C]);
01287
01288 if(DEBUG > 2)
01289 printf("_data = %f\tdata = %f\t my_C = %d\n", _data[my_C], data[i], my_C);
01290
01291 }
01292
01293
01294 fprintf(fp, "\n");
01295
01296
01297 if(console_out) printf("\n");
01298
01299 fflush(fp);
01300 }
01301
01302 if(DEBUG > 1) {
01303 printf("index = %d\t event_gate = %d\n", i, event_gate);
01304 }
01305
01306 }
01307
01308
01309
01310 my_C = 0;
01311 fclose(fp);
01312
01313 return error();
01314 }
01315
01316 float
01317 CHOP_csound_score::getVariableValue(int index, int)
01318 {
01319 switch( index )
01320 {
01321 case VAR_C:
01322 return my_C;
01323
01324 case VAR_NC:
01325 return my_NC;
01326
01327 case VAR_DUR:
01328 return my_DUR;
01329
01330 case VAR_INST_NUM:
01331 return my_INST_NUM;
01332
01333 default:
01334 return CHOP_Node::getVariableValue(index);
01335 }
01336 }
01337
01338 const char *
01339 CHOP_csound_score::inputLabel(unsigned) const
01340 {
01341 return "Instrument Index";
01342 }
01343
01344
01345 int CHOP_csound_score::writeTheFile(void *data, int index,
01346 float time, const PRM_Template *tplate ) {
01347
01348 if(DEBUG > 0)
01349 cout << "writeTheFile() - Writing the Real Flow SD File" << endl;
01350
01351 CHOP_csound_score *me = (CHOP_csound_score *) data;
01352
01353 me->calledFromCallback = true;
01354 me->myCallBackFlags = 0;
01355
01356 OP_Context myContext(time);
01357
01358
01359
01360
01361
01362 me->myCallBackError = me->cookMyChop(myContext);
01363
01364
01365
01366 return 1;
01367 }
01368
01369