int main (int argc, char *argv[]) { NYX_CHANNEL *c1, *c2, *c3; NYX_NET *net; NYX_QUEUE *q; pthread_t tid; nyx_init (); /* Create client channels */ c1 = nyx_channel_new (NULL); nyx_channel_tcp_init (c1, "127.0.0.1", 8000, 0); nyx_channel_set_cb (c1, read_cb); c2 = nyx_channel_new (NULL); nyx_channel_tcp_init (c2, "127.0.0.1", 8001,0); nyx_channel_set_cb (c2, read_cb); c3 = nyx_channel_new (NULL); nyx_channel_tcp_init (c3, "127.0.0.1", 8001,0); nyx_channel_set_cb (c3, read_cb); /* Create Queue */ q = nyx_queue_new (50); /* Create worker */ pthread_create (&tid, NULL, consumer, q); /* Create net object */ net = nyx_net_init (); /* register channels */ nyx_net_register (net, c1, q); nyx_net_register (net, c2, q); nyx_net_register (net, c3, q); nyx_net_run (net); nyx_channel_free (c2); nyx_channel_free (c1); nyx_queue_free (q); nyx_net_free (net); nyx_cleanup (); return 0; }
bool EffectNyquist::Process() { bool success = true; if (mExternal) { mProgress->Hide(); } // We must copy all the tracks, because Paste needs label tracks to ensure // correct sync-lock group behavior when the timeline is affected; then we just want // to operate on the selected wave tracks this->CopyInputTracks(Track::All); SelectedTrackListOfKindIterator iter(Track::Wave, mOutputTracks); mCurTrack[0] = (WaveTrack *) iter.First(); mOutputTime = mT1 - mT0; mCount = 0; mProgressIn = 0; mProgressOut = 0; mProgressTot = 0; mScale = (GetEffectFlags() & PROCESS_EFFECT ? 0.5 : 1.0) / GetNumWaveGroups(); mStop = false; mBreak = false; mCont = false; mDebugOutput = ""; // Keep track of whether the current track is first selected in its sync-lock group // (we have no idea what the length of the returned audio will be, so we have // to handle sync-lock group behavior the "old" way). mFirstInGroup = true; Track *gtLast = NULL; while (mCurTrack[0]) { mCurNumChannels = 1; if (mT1 >= mT0) { if (mCurTrack[0]->GetLinked()) { mCurNumChannels = 2; mCurTrack[1] = (WaveTrack *)iter.Next(); if (mCurTrack[1]->GetRate() != mCurTrack[0]->GetRate()) { wxMessageBox(_("Sorry, cannot apply effect on stereo tracks where the tracks don't match."), wxT("Nyquist"), wxOK | wxCENTRE, mParent); success = false; goto finish; } mCurStart[1] = mCurTrack[1]->TimeToLongSamples(mT0); } // Check whether we're in the same group as the last selected track SyncLockedTracksIterator gIter(mOutputTracks); Track *gt = gIter.First(mCurTrack[0]); mFirstInGroup = !gtLast || (gtLast != gt); gtLast = gt; mCurStart[0] = mCurTrack[0]->TimeToLongSamples(mT0); sampleCount end = mCurTrack[0]->TimeToLongSamples(mT1); mCurLen = (sampleCount)(end - mCurStart[0]); mProgressIn = 0.0; mProgressOut = 0.0; // libnyquist breaks except in LC_NUMERIC=="C". // // Note that we must set the locale to "C" even before calling // nyx_init() because otherwise some effects will not work! // // MB: setlocale is not thread-safe. Should use uselocale() // if available, or fix libnyquist to be locale-independent. char *prevlocale = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); nyx_init(); nyx_set_os_callback(StaticOSCallback, (void *)this); nyx_capture_output(StaticOutputCallback, (void *)this); success = ProcessOne(); nyx_capture_output(NULL, (void *)NULL); nyx_set_os_callback(NULL, (void *)NULL); nyx_cleanup(); // Reset previous locale setlocale(LC_NUMERIC, prevlocale); if (!success) { goto finish; } mProgressTot += mProgressIn + mProgressOut; } mCurTrack[0] = (WaveTrack *) iter.Next(); mCount += mCurNumChannels; } mT1 = mT0 + mOutputTime; finish: if (mDebug && !mExternal) { NyquistOutputDialog dlog(mParent, -1, _("Nyquist"), _("Nyquist Output: "), NyquistToWxString(mDebugOutput.c_str())); dlog.CentreOnParent(); dlog.ShowModal(); } this->ReplaceProcessedTracks(success); //mDebug = false; return success; }