void PitchFlockViewer::plot_beat () { const size_t I = synth().size; const size_t X = Rectangle::width(); const size_t Y = Rectangle::height(); const float * restrict phase_x = synth().get_phase_x(); const float * restrict phase_y = synth().get_phase_y(); float * restrict image = m_beat_image; complex force = synth().get_force_snapshot(); float beat = abs(force) * m_force_gain.update(abs(force)); if (m_image_mutex.try_lock()) { for (size_t i = 0; i < I; ++i) { float x = wrap(atan2f(phase_y[i], phase_x[i]) / (2 * M_PI)) * X; float y = (i + 0.5f) / I * Y; BilinearInterpolate(x, X, y, Y).imax(image, beat); } m_image_mutex.unlock(); } }
void iiwt_ref(SchroFrameData *p, int filter) { int16_t tmp1[100], *hi; int16_t tmp2[100], *lo; int16_t tmp3[100], *tmpbuf; int16_t *data; int i; hi = tmp1 + 4; lo = tmp2 + 4; tmpbuf = tmp3 + 8; for(i=0;i<p->width;i++){ data = OFFSET(p->data,i*sizeof(int16_t)); copy(tmpbuf, sizeof(int16_t), data, p->stride, p->height); synth (tmpbuf, p->height, filter); copy(data, p->stride, tmpbuf, sizeof(int16_t), p->height); } for(i=0;i<p->height;i++){ data = OFFSET(p->data,i*p->stride); copy(hi, sizeof(int16_t), data, sizeof(int16_t), p->width/2); copy(lo, sizeof(int16_t), data + p->width/2, sizeof(int16_t), p->width/2); orc_interleave2_s16 (tmpbuf, hi, lo, p->width/2); synth (tmpbuf, p->width, filter); copy(data, sizeof(int16_t), tmpbuf, sizeof(int16_t), p->width); } rshift(p, filtershift[filter]); }
int main(int argc, char *argv[]) { bool expand = true; if ( argc > 1) { if (argc == 2 && strcmp(argv[1], "-s") == 0) { expand = false; } else { std::cerr << "Usage: cec-astgrc [-s]\n"; return 1; } } try { IR::Node *root; IR::XMListream r(std::cin); r >> root; AST::Modules *mods = dynamic_cast<AST::Modules*>(root); if (!mods) throw IR::Error("Root node is not a Modules object"); for ( std::vector<AST::Module*>::iterator i = mods->modules.begin() ; i != mods->modules.end() ; i++ ) { assert(*i); // Compute completion codes for this module ASTGRC::CompletionCodes cc(*i); // Synthesize GRC for this module and replace it if (expand) { ASTGRC::GrcSynth synth(*i, cc); (*i)->body = synth.synthesize(); } else { ASTGRC::RecursiveSynth synth(*i, cc); (*i)->body = synth.synthesize(); } assert((*i)->body); AST::GRCgraph *g = dynamic_cast<AST::GRCgraph *>((*i)->body); assert(g); assert(g->control_flow_graph); // Add dependencies ASTGRC::Dependencies::compute(g->control_flow_graph); } IR::XMLostream w(std::cout); w << mods; } catch (IR::Error &e) { std::cerr << e.s << std::endl; return -1; } return 0; }
void ISynth::noRTHelper() { for (;;) { char c; int n = read(readFd, &c, 1); if (n != 1) { perror("ISynth::read ipc failed\n"); continue; } int id = getFontId(); if (id != -1) { #ifdef FS_DEBUG fprintf(stderr, "ISynth: unload old font\n"); #endif fluid_synth_sfunload(synth(), (unsigned)id, true); } const char* fontname = getFont(); int rv = fluid_synth_sfload(synth(), fontname, true); if (rv == -1) { fprintf(stderr, "ISynth: sfload %s failed\n", fluid_synth_error(synth())); } else { setFontId(rv); // Inform the gui. p4.0.27 Tim int slen = strlen(fontname); int n = slen + 2; unsigned char d[n]; d[0] = FS_SEND_SOUNDFONT_NAME; if(slen != 0) memcpy(d + 1, fontname, slen); d[1 + slen] = 0; MusECore::MidiPlayEvent ev(0,0, MusECore::ME_SYSEX, d, n); gui->writeEvent(ev); #ifdef FS_DEBUG fprintf(stderr, "ISynth: sfont %s loaded as %d\n ", getFont(), rv); #endif } fluid_synth_set_gain(synth(), 1.0); //? _busy = false; } }
void playerB(int N, int *data) { long long C = 1; for(int i = N - 1; i >= 0; --i) { C = C * 2 + data[i]; } int A, B; synth(C - 1, &A, &B); answer(A, B); }
void PitchFlockViewer::plot_bend () { const size_t I = synth().size; const size_t X = Rectangle::width(); const size_t Y = Rectangle::height(); const float * restrict power = get_power(); const float * restrict energy = get_energy(); const float * restrict bend = synth().get_bend(); float * restrict red = m_bend_image.red; float * restrict green = m_bend_image.green; float * restrict blue = m_bend_image.blue; float energy_gain = m_energy_gain.update(max(get_energy())); float power_gain = m_power_gain.update(max(get_power())); float bend_variance = norm_squared(synth().get_bend()) / I; float bend_gain = m_bend_gain.update(bend_variance); float min_freq = min(synth().get_freq()); float max_freq = max(synth().get_freq()); float pitch_scale = 1 / log(max_freq / min_freq); if (m_image_mutex.try_lock()) { for (size_t i = 0; i < I; ++i) { float m = energy_gain * energy[i]; float e = power_gain * power[i]; float b = atanf(0.5f * bend_gain * bend[i]) / M_PI + 0.5f; float p = static_cast<float>(i) / I + pitch_scale * log(1 + bend[i]); BilinearInterpolate lin(b * X, X, p * Y, Y); lin.imax(red, e); lin.imax(green, m); lin.imax(blue, 1); } m_image_mutex.unlock(); } }
void emit(int i, int x) { switch (i) { case 'l': case 'g': queue(i, x); break; case '_': load(); gen("neg A"); break; default: synth(i); break; } }
int main() { //create a synth BicycletteSynth synth(SAMPLE_RATE_DOUBLE, 16, CHANNELS_NUMBER); //create a sound manager WindowsSound windowsSound(&synth); if(windowsSound.Init() == false) { //TODO: handle error } if(windowsSound.Start() == false) { //TODO: handle error } for(int i=0; i<50; i++) { if(i == 0) { BicycletteEvent ev; ev.channel = 1; ev.delta = 50; ev.note = 69; ev.type = BicycletteEventType_NoteOn; ev.velocity = 100; synth.AddEvent(ev); } if(i == 40) { BicycletteEvent ev; ev.channel = 1; ev.delta = 50; ev.note = 69; ev.type = BicycletteEventType_NoteOff; ev.velocity = 100; synth.AddEvent(ev); } windowsSound.Update(); sleep(100); } windowsSound.Stop(); return 0; }
int main(int argc, char** argv){ if(argc != 5){ Usage(argc,argv); return 1; } // amount of mask attenuation (dB) float amount = (float)pow(10, atof(argv[4])/20.f); // masking file SndWave inmask(argv[2], READ); // input file SndWave infile(argv[1], READ); // Hamming window HammingTable window(DEF_FFTSIZE, 0.54f); // masking table PVTable table2(DEF_FFTSIZE,&inmask,&window, 0.f, 1.f); // input signal SndIn in(&infile); // PV analysis PVA anal(&window, &in, 0.6f); // Masking PVMask mask(amount, &table2, &anal); // PV synthesis PVS synth(&window, &mask); // output file SndWave output(argv[3], OVERWRITE, 1); output.SetOutput(1, &synth); // processing loop while(!infile.Eof()){ infile.Read(); in.DoProcess(); anal.DoProcess(); mask.DoProcess(); synth.DoProcess(); output.Write(); } return 0; }
void TempoFlockViewer::plot_beat () { const size_t I = synth().size(); const size_t X = Rectangle::width(); const size_t Y = Rectangle::height(); const float * restrict mass = synth().get_mass(); const float * restrict phase_x = synth().get_phase_x(); const float * restrict phase_y = synth().get_phase_y(); const complex r_part = exp_2_pi_i(0 / 3.0f); const complex g_part = exp_2_pi_i(1 / 3.0f); const complex b_part = exp_2_pi_i(2 / 3.0f); float * restrict red = m_image.red; float * restrict green = m_image.green; float * restrict blue = m_image.blue; //const float * restrict acuity = synth().get_acuity(); //const float acuity1 = synth().max_acuity(); const float * restrict duration = synth().get_duration(); const float duration0 = synth().min_duration(); if (m_image_mutex.try_lock()) { if (m_rhythm_mutex.try_lock()) { for (size_t i = 0; i < I; ++i) { complex phase(phase_x[i], phase_y[i]); float x = wrap(arg(phase) / (2 * M_PI) + 0.5f); //float y = synth().acuity_cdf(acuity[i], acuity1); float y = synth().duration_cdf(duration[i], duration0); float m = min(mass[i], 1.0f); float r = m; float g = sqr(m); float b = 1; BilinearInterpolate lin(x * X, X, y * Y, Y); lin.imax(red, r); lin.imax(green, g); lin.imax(blue, b); } m_rhythm_mutex.unlock(); } m_image_mutex.unlock(); } }
float sample_val(int note, unsigned int phase) { float f; // f = freq(note+12); switch(note) { case 0: f = NOTE_0; break; case 1: f = NOTE_1; break; case 2: f = NOTE_2; break; case 3: f = NOTE_3; break; case 4: f = NOTE_4; break; case 5: f = NOTE_5; break; case 6: f = NOTE_6; break; case 7: f = NOTE_7; break; case 8: f = NOTE_8; break; case 9: f = NOTE_9; break; case 10: f = NOTE_10; break; case 11: f = NOTE_11; break; } return (synth(phase, f) * intensity(note, 0) + synth(phase, f*2) * intensity(note, 1) + synth(phase, f*4) * intensity(note, 2) + synth(phase, f*8) * intensity(note, 3) + synth(phase, f*16) * intensity(note, 4) + synth(phase, f*32) * intensity(note, 5)); }
int main(int argc, char *argv[]) { if (argc < 4) { std::cout << "not enough arguments" << std::endl; return 1; } AudioFile audioFile(argv[1]); Synthesizer synth(44100, 10, 16000); std::cout << "Input file information:\nSamples: " << audioFile.getFrameCount() << "\nSample rate: " << audioFile.getSampleRate() << "\nChannels: " << audioFile.getChannelCount() << std::endl; AudioProcessorPlugin audioProcessor(& synth, argv[3], argc - 4, argv + 4); SF_INFO outfileInfo = { 0 }; outfileInfo.samplerate = audioProcessor.getSampleRate(); outfileInfo.channels = audioProcessor.getChannelCount(); outfileInfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; SNDFILE * outFile = sf_open(argv[2], SFM_WRITE, & outfileInfo); if (outFile == NULL) { std::cerr << "Failed to create/open output file '" << argv[2] << "': " << sf_strerror(outFile) << std::endl; return 1; } std::vector<float> frameBuffer; bool ok = true; unsigned int framesRead = audioProcessor.getFrames(frameBuffer); while (framesRead > 0) { const sf_count_t framesWritten = sf_write_float(outFile, &frameBuffer[0], framesRead); if (framesWritten != framesRead) { std::cout << "Failed to write frames to output file" << std::endl; ok = false; break; } framesRead = audioProcessor.getFrames(frameBuffer); } sf_close(outFile); return ok ? 0 : 1; }
int main(int argc, char** argv){ float dur, time; if(argc == 3){ dur = (float) atof(argv[1]); time = (float) atof(argv[2]); } else { Usage(argv[0]); exit(1); } SndRTIO input(1, SND_INPUT); SndRTIO output(1, SND_OUTPUT); HammingTable window(1024, 0.54f); SndIn in(&input); PVA anal(&window, &in); PVBlur blur(&anal, time); PVS synth(&window, &blur); output.SetOutput(1, &synth); int end = dur*DEF_SR/DEF_VECSIZE; for(int i=0; i<end; i++){ input.Read(); in.DoProcess(); anal.DoProcess(); blur.DoProcess(); synth.DoProcess(); output.Write(); } return 0; }
int main(int argc, char **argv) { if(argc < 6) { printf("usage: %s <source image> <srcwrap> <neighborhood> <destw> <desth>\n", argv[0]); return -1; } srand(time(NULL)); Img *srcim = Img::load_png(argv[1]); printf("loaded %dx%d source\n", srcim->w, srcim->h); int w = atoi(argv[4]); int h = atoi(argv[5]); TextureSynth<_K_> synth(srcim, w, h, atoi(argv[3]), atoi(argv[2])?true:false); printf("synthesizing %dx%d with neighborhood=%d (%d^2), srcwrap=%s\n", w,h, synth.Nsize, synth.Nsize*2+1, synth.srcwrap ? "on" : "off"); int keeprows = (synth.Nsize+3)/2; for(int version=0;version<VERSIONS;version++) { synth.init(version==0 ? 0 : synth.Nsize); for(int iterations=0;iterations<ITERATIONS;iterations++) { printf("\rout%d.png iteration %d/%d: E:", version, 1+iterations, ITERATIONS); printf("%u M:", synth.estep(version==0 ? 0 : keeprows)); unsigned e = synth.mstep(version==0 ? 0 : keeprows); printf("%u\e[K", e); fflush(stdout); if(!e) break; } printf(" final err: %d", synth.estep(version==0 ? 0 : keeprows)); char buf[20]; sprintf(buf, "out%d.png", version); synth.dstim->save_png(buf); printf(" done\n"); } return 0; }
void PitchFlockViewer::select_notes (float x, float y) { const size_t I = synth().size; const float * restrict select_x = m_select_x; const float * restrict select_y1 = m_select_y1; const float * restrict select_y2 = m_select_y2; const float radius = 1 / sqrtf(I); const float r2 = sqr(radius); bool stereo; switch (m_plot_type) { case e_plot_pca: case e_plot_pca_freq: stereo = true; break; default: stereo = false; break; } float total_power = 0; Notes & restrict notes = m_temp_notes; for (size_t i = 0; i < I; ++i) { float xi = select_x[i]; float dx2 = sqr(xi - x); if (dx2 < r2) { float pitch = (i + 0.5f) / I; { float yi = select_y1[i]; float dy2 = sqr(yi - y) / 2; if (dx2 + dy2 < r2) { float power = r2 - dx2 - dy2; notes.push_back(Note(pitch, power)); total_power += power; } } if (stereo) { float yi = select_y2[i]; float dy2 = sqr(yi - y) / 2; if (dx2 + dy2 < r2) { float power = r2 - dx2 - dy2; notes.push_back(Note(pitch, power)); total_power += power; } } } } if (total_power > 0) { float scale = 1.0f / total_power; typedef Notes::iterator Auto; for (Auto n = notes.begin(); n < notes.end(); ++n) { n->power *= scale; } } m_notes_mutex.lock(); std::swap(m_notes, m_temp_notes); m_notes_mutex.unlock(); m_temp_notes.clear(); }
void PitchFlockViewer::plot_pca_4d () { float timescale = FLOCK_PCA_TIMESCALE_SEC * DEFAULT_AUDIO_FRAMERATE; float dt = 1 / timescale; m_pca.add_sample(synth().get_beat(), dt); const size_t I = synth().size; const size_t X = Rectangle::width(); const size_t Y = Rectangle::height(); float * restrict select_x = m_select_x; float * restrict select_y = m_select_y1; float pca_gain = sqrtf(I) / 8; const float * restrict energy = get_energy(); const float * restrict pca_w = m_pca.component(0); const float * restrict pca_x = m_pca.component(1); const float * restrict pca_y = m_pca.component(2); const float * restrict pca_z = m_pca.component(3); const float * restrict pca_u = m_pca.component(4); const float * restrict pca_v = m_pca.component(5); const float ru = 1.0f; const float bu = cos(2 * M_PI / 3); const float bv = sin(2 * M_PI / 3); const float gu = cos(-2 * M_PI / 3); const float gv = sin(-2 * M_PI / 3); float * restrict energy_image = m_energy_image; float * restrict red = m_pca_image.red; float * restrict green = m_pca_image.green; float * restrict blue = m_pca_image.blue; const LinAlg::Orientation4D angle = m_angle4; if (m_image_mutex.try_lock()) { for (size_t i = 0; i < I; ++i) { float m = energy[i]; float wxyz[4] = {pca_w[i], pca_x[i], pca_y[i], pca_z[i]}; float u = pca_u[i] * pca_gain; float v = pca_v[i] * pca_gain; float uv_scale = 1 / (1 + sqrt(max(1e-20f, sqr(u) + sqr(v)))); u *= uv_scale; v *= uv_scale; float r = sqr((1 + ru * u) / 2); float g = sqr((1 + gu * u + gv * v) / 2); float b = sqr((1 + bu * u + bv * v) / 2); float x = pca_gain * angle.coord_dot(0, wxyz); float y = pca_gain * angle.coord_dot(1, wxyz); float x_01 = select_x[i] = (1 + x) / 2; float y_01 = select_y[i] = (1 + y) / 2; BilinearInterpolate lin(x_01 * X, X, y_01 * Y, Y); lin.imax(energy_image, m); lin.imax(red, r); lin.imax(green, g); lin.imax(blue, b); } m_image_mutex.unlock(); } }
void PitchFlockViewer::plot_pca_freq () { float timescale = FLOCK_PCA_TIMESCALE_SEC * DEFAULT_AUDIO_FRAMERATE; float dt = 1 / timescale; m_pca.add_sample(synth().get_beat(), dt); const size_t I = synth().size; const size_t X = Rectangle::width(); const size_t Y = Rectangle::height(); float * restrict select_x = m_select_x; float * restrict select_y1 = m_select_y1; float * restrict select_y2 = m_select_y2; float pca_gain = sqrtf(I) / 8; float dx_gain = sqrtf(I) / synth().num_tones(); const float * restrict energy = get_energy(); const float * restrict pca_y = m_pca.component(0); const float * restrict pca_z = m_pca.component(1); const float * restrict pca_u = m_pca.component(2); const float * restrict pca_v = m_pca.component(3); const float * restrict pca_dx = m_pca.component(4); const float ru = 1.0f; const float bu = cos(2 * M_PI / 3); const float bv = sin(2 * M_PI / 3); const float gu = cos(-2 * M_PI / 3); const float gv = sin(-2 * M_PI / 3); float * restrict energy_image = m_energy_image; float * restrict red = m_pca_image.red; float * restrict green = m_pca_image.green; float * restrict blue = m_pca_image.blue; const LinAlg::Orientation3D angle = m_angle3; const float skew = 1.0f / 20; if (m_image_mutex.try_lock()) { for (size_t i = 0; i < I; ++i) { float m = energy[i]; float xyz[3] = { 1 - (i + 0.5f) / I * 2 + pca_dx[i] * dx_gain, pca_y[i] * pca_gain, pca_z[i] * pca_gain }; float u = pca_u[i] * pca_gain; float v = pca_v[i] * pca_gain; float uv_scale = 1 / (1 + sqrt(max(1e-20f, sqr(u) + sqr(v)))); u *= uv_scale; v *= uv_scale; float r = sqr((1 + ru * u) / 2); float g = sqr((1 + gu * u + gv * v) / 2); float b = sqr((1 + bu * u + bv * v) / 2); float x = angle.coord_dot(0, xyz); float y = angle.coord_dot(1, xyz); float z = angle.coord_dot(2, xyz); float y1 = y - skew * z; float y2 = y + skew * z; float x_01 = select_x[i] = (1 + x) / 2; float y1_01 = select_y1[i] = (1 + y1) / 4; float y2_01 = select_y2[i] = (1 + y2 + 2) / 4; BilinearInterpolate lin(x_01 * X, X, y1_01 * Y, Y); lin.imax(energy_image, m); lin.imax(red, r); lin.imax(green, g); lin.imax(blue, b); lin.y(y2_01 * Y, Y); lin.imax(energy_image, m); lin.imax(red, r); lin.imax(green, g); lin.imax(blue, b); } m_image_mutex.unlock(); } }
/** * Synthesize text into an audio file, but do not send to the audio device. * @param text The text to be synthesized. * @param suggestedFilename Full pathname of file to create. The plugin * may ignore this parameter and choose its own * filename. KTTSD will query the generated * filename using getFilename(). * * If the plugin supports asynchronous operation, it should return immediately. */ void FreeTTSProc::synthText(const QString& text, const QString& suggestedFilename) { kdDebug() << "Running: FreeTTSProc::synthText" << endl; synth(text, suggestedFilename, m_freettsJarPath); }
int main(int argc, char* argv[]) { int testsignal = 0; bool runSpeedTest = false; bool connectAudio = false; std::vector<std::string> midiConnections; std::map<unsigned, unsigned> patchFromCmdline; struct option longopts[] = { { "testsignal", 1, 0, 't' }, { "speedtest", 0, 0, 's' }, { "connect-audio", 0, 0, 'C' }, { "connect-midi", 1, 0, 'M' }, { "patch", 1, 0, 'p' }, { "help", no_argument, 0, 'h' }, { 0, 0, 0, 0 } }; int opt; while ((opt = getopt_long(argc, argv, "st:CM:p:h", longopts, 0)) != -1) { switch (opt) { case 't': testsignal = atoi(optarg); break; case 's': runSpeedTest = true; break; case 'C': connectAudio = true; break; case 'M': midiConnections.push_back(optarg); break; case 'p': unsigned channel, program; sscanf(optarg, "%u:%u", &channel, &program); patchFromCmdline[channel] = program; break; default: case 'h': printHelp(); return 0; } } if (testsignal) { TGlobal::SampleRate = 44100; TGlobal::NyquistFrequency = TGlobal::SampleRate / 2; TAudioFileWriter fileWriter("testsignal.wav", 2, TGlobal::SampleRate); TFileAudioPort inputPortL("", TFileAudioPort::INPUT); TFileAudioPort inputPortR("", TFileAudioPort::INPUT); TAudioPortCollection inputPorts( { &inputPortL, &inputPortR }); TFileAudioPort intOutPort1("/dev/null", TFileAudioPort::OUTPUT); TFileAudioPort intOutPort2("/dev/null", TFileAudioPort::OUTPUT); TFileAudioPort intOutPort3("/dev/null", TFileAudioPort::OUTPUT); TFileAudioPort intOutPort4("/dev/null", TFileAudioPort::OUTPUT); TAudioPortCollection intOutPorts( { &intOutPort1, &intOutPort2, &intOutPort3, &intOutPort4 }); TAudioPortCollection outputPorts = fileWriter.GetPorts(); TJackSynth synth(inputPorts, outputPorts, intOutPorts); switch (testsignal) { case 1: testSignalSawSweep(synth); break; case 2: testSignalFilterSweep(synth); break; case 3: testSignalDelay(synth); break; case 4: testSignalReverb(synth); break; } } else if (runSpeedTest) { speedTest(); } else { signal(SIGINT, sigterm); signal(SIGTERM, sigterm); runInJack(connectAudio, midiConnections, patchFromCmdline); } return 0; }
void runInJack(bool connectAudio, std::vector<std::string> midiConnections, std::map<unsigned, unsigned> patchFromCmdline) { Client = jack_client_open("jacksynth", JackNullOption, 0); if (!Client) { std::cerr << "Cannot connect to JACK" << std::endl; abort(); } std::cout << "Connected to JACK:" << std::endl << " Sample rate " << jack_get_sample_rate(Client) << " Hz" << std::endl << " Buffer size " << jack_get_buffer_size(Client) << " frames" << std::endl << " Sample size " << sizeof(TSample) << " bytes" << std::endl; TJackAudioPort inputPortL("leftin", Client, TJackAudioPort::INPUT); TJackAudioPort inputPortR("rightin", Client, TJackAudioPort::INPUT); TJackAudioPort outputPortL("left", Client, TJackAudioPort::OUTPUT); TJackAudioPort outputPortR("right", Client, TJackAudioPort::OUTPUT); TJackAudioPort intOutPort1("int1", Client, TJackAudioPort::OUTPUT); TJackAudioPort intOutPort2("int2", Client, TJackAudioPort::OUTPUT); TJackAudioPort intOutPort3("int3", Client, TJackAudioPort::OUTPUT); TJackAudioPort intOutPort4("int4", Client, TJackAudioPort::OUTPUT); MidiIn = jack_port_register(Client, "MIDI-IN", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0); MidiOut = jack_port_register(Client, "MIDI-OUT", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0); TGlobal::SampleRate = jack_get_sample_rate(Client); TGlobal::NyquistFrequency = TGlobal::SampleRate / 2; TAudioPortCollection inputPorts( { &inputPortL, &inputPortR }); TAudioPortCollection outputPorts( { &outputPortL, &outputPortR }); TAudioPortCollection intermediateOutPorts( { &intOutPort1, &intOutPort2, &intOutPort3, &intOutPort4 }); TJackSynth synth(inputPorts, outputPorts, intermediateOutPorts); synth.SetMidiSendCallback(send_midi); jack_set_process_callback(Client, process, &synth); if (jack_activate(Client)) { std::cerr << "Cannot start jackiness" << std::endl; abort(); } if (connectAudio) { inputPortL.Connect("system:capture_1"); inputPortR.Connect("system:capture_2"); outputPortL.Connect("system:playback_1"); outputPortR.Connect("system:playback_2"); } for (auto con : midiConnections) { const char* me = jack_port_name(MidiIn); jack_connect(Client, con.c_str(), me); } for (auto patch : patchFromCmdline) { uint8_t channel = 0xc0 | (patch.first - 1); uint8_t pgm = patch.second - 1; synth.HandleMidi({ channel, pgm }); } while (!die) sleep(1); jack_client_close(Client); }
/** * Say a text. Synthesize and audibilize it. * @param text The text to be spoken. * * If the plugin supports asynchronous operation, it should return immediately. */ void FreeTTSProc::sayText(const QString &text) { synth(text, QString::null, m_freettsJarPath); }
/** * Synthesize text into an audio file, but do not send to the audio device. * @param text The text to be synthesized. * @param suggestedFilename Full pathname of file to create. The plugin * may ignore this parameter and choose its own * filename. KTTSD will query the generated * filename using getFilename(). * * If the plugin supports asynchronous operation, it should return immediately. */ void CommandProc::synthText(const QString& text, const QString& suggestedFilename) { synth(text, suggestedFilename, m_ttsCommand, m_stdin, m_codec, m_language); }
/** * Say a text. Synthesize and audibilize it. * @param text The text to be spoken. * * If the plugin supports asynchronous operation, it should return immediately. */ void CommandProc::sayText(const QString &text) { synth(text, QString::null, m_ttsCommand, m_stdin, m_codec, m_language); }