Esempio n. 1
0
void Player_SID::update() { // $481B
	if (initializing)
		return;

	if (_soundInQueue) {
		for (int i = 6; i >= 0; --i) {
			if (_soundQueue[i] != -1)
				processSongData(i);
		}
		_soundInQueue = false;
	}

	// no sound
	if (busyChannelBits == 0)
		return;

	for (int i = 6; i >= 0; --i) {
		if (busyChannelBits & BITMASK[i]) {
			updateFreq(i);
		}
	}

	// seems to be used for background (prio=1?) sounds.
	// If a bg sound cannot be played because all SID
	// voices are used by higher priority sounds, the
	// bg sound's state is updated here so it will be at
	// the correct state when a voice is available again.
	if (swapPrepared) {
		swapVars(0, 0);
		swapVarLoaded = true;
		updateFreq(0);
		swapVars(0, 0);
		if (pulseWidthSwapped) {
			swapVars(4, 1);
			updateFreq(4);
			swapVars(4, 1);
		}
		swapVarLoaded = false;
	}

	for (int i = 6; i >= 0; --i) {
		if (busyChannelBits & BITMASK[i])
			setSIDWaveCtrlReg(i);
	};

	if (isMusicPlaying) {
		handleMusicBuffer();
	}

	return;
}
Esempio n. 2
0
int updateIndex(char* word, int documentId, INVERTED_INDEX* index) {
    int unique;
    int i;

    // make words lowercase
    for(i = 0; word[i]; i++) {
        word[i] = tolower(word[i]);
    }
    unique = checkUniqueness(word, index);
    if(unique == 1) { // if the word is unique, add new WORD and DOCUMENTNODE
        addNode(word, index, documentId);
        // printf("added new unique node at hash: %d\n", hashIndex);
    } else {
        updateFreq(word, documentId, index);
    }
    return 1;
}
GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) :
	QGridLayout(parent),
	v4l2(fd),
	m_row(0),
	m_col(0),
	m_cols(n),
	m_audioInput(NULL),
	m_tvStandard(NULL),
	m_videoPreset(NULL),
	m_freq(NULL),
	m_vidCapFormats(NULL),
	m_frameSize(NULL),
	m_vidOutFormats(NULL)
{
	setSpacing(3);

	setSizeConstraint(QLayout::SetMinimumSize);

	if (querycap(m_querycap)) {
		addLabel("Device:");
		addLabel(device + (useWrapper() ? " (wrapped)" : ""), Qt::AlignLeft);

		addLabel("Driver:");
		addLabel((char *)m_querycap.driver, Qt::AlignLeft);

		addLabel("Card:");
		addLabel((char *)m_querycap.card, Qt::AlignLeft);

		addLabel("Bus:");
		addLabel((char *)m_querycap.bus_info, Qt::AlignLeft);
	}

	g_tuner(m_tuner);

	v4l2_standard vs;
	if (enum_std(vs, true)) {
		addLabel("TV Standard");
		m_tvStandard = new QComboBox(parent);
		do {
			m_tvStandard->addItem((char *)vs.name);
		} while (enum_std(vs));
		addWidget(m_tvStandard);
		connect(m_tvStandard, SIGNAL(activated(int)), SLOT(standardChanged(int)));
		updateStandard();
	}

	v4l2_dv_enum_preset preset;
	if (enum_dv_preset(preset, true)) {
		addLabel("Video Preset");
		m_videoPreset = new QComboBox(parent);
		do {
			m_videoPreset->addItem((char *)preset.name);
		} while (enum_dv_preset(preset));
		addWidget(m_videoPreset);
		connect(m_videoPreset, SIGNAL(activated(int)), SLOT(presetChanged(int)));
		updatePreset();
	}

	v4l2_input vin;
	if (enum_input(vin, true)) {
		addLabel("Input");
		m_videoInput = new QComboBox(parent);
		do {
			m_videoInput->addItem((char *)vin.name);
		} while (enum_input(vin));
		addWidget(m_videoInput);
		connect(m_videoInput, SIGNAL(activated(int)), SLOT(inputChanged(int)));
		updateVideoInput();
	}

	v4l2_output vout;
	if (enum_output(vout, true)) {
		addLabel("Output");
		m_videoOutput = new QComboBox(parent);
		do {
			m_videoOutput->addItem((char *)vout.name);
		} while (enum_output(vout));
		addWidget(m_videoOutput);
		connect(m_videoOutput, SIGNAL(activated(int)), SLOT(outputChanged(int)));
		updateVideoOutput();
	}

	v4l2_audio vaudio;
	if (enum_audio(vaudio, true)) {
		addLabel("Input Audio");
		m_audioInput = new QComboBox(parent);
		do {
			m_audioInput->addItem((char *)vaudio.name);
		} while (enum_audio(vaudio));
		addWidget(m_audioInput);
		connect(m_audioInput, SIGNAL(activated(int)), SLOT(inputAudioChanged(int)));
		updateAudioInput();
	}

	v4l2_audioout vaudout;
	if (enum_audout(vaudout, true)) {
		addLabel("Output Audio");
		m_audioOutput = new QComboBox(parent);
		do {
			m_audioOutput->addItem((char *)vaudout.name);
		} while (enum_audout(vaudout));
		addWidget(m_audioOutput);
		connect(m_audioOutput, SIGNAL(activated(int)), SLOT(outputAudioChanged(int)));
		updateAudioOutput();
	}

	if (m_tuner.type) {
		m_freq = new QSpinBox(parent);
		m_freq->setMinimum(m_tuner.rangelow);
		m_freq->setMaximum(m_tuner.rangehigh);
		m_freq->setWhatsThis(QString("Frequency\nLow: %1\nHigh: %2")
				.arg(m_tuner.rangelow).arg(m_tuner.rangehigh));
		connect(m_freq, SIGNAL(valueChanged(int)), SLOT(freqChanged(int)));
		updateFreq();
		addLabel("Frequency");
		addWidget(m_freq);

		addLabel("Frequency Table");
		m_freqTable = new QComboBox(parent);
		for (int i = 0; v4l2_channel_lists[i].name; i++) {
			m_freqTable->addItem(v4l2_channel_lists[i].name);
		}
		addWidget(m_freqTable);
		connect(m_freqTable, SIGNAL(activated(int)), SLOT(freqTableChanged(int)));

		addLabel("Channels");
		m_freqChannel = new QComboBox(parent);
		m_freqChannel->setSizeAdjustPolicy(QComboBox::AdjustToContents);
		addWidget(m_freqChannel);
		connect(m_freqChannel, SIGNAL(activated(int)), SLOT(freqChannelChanged(int)));
		updateFreqChannel();
	}

	v4l2_fmtdesc fmt;
	addLabel("Capture Image Formats");
	m_vidCapFormats = new QComboBox(parent);
	if (enum_fmt_cap(fmt, true)) {
		do {
			m_vidCapFormats->addItem(pixfmt2s(fmt.pixelformat) +
					" - " + (const char *)fmt.description);
		} while (enum_fmt_cap(fmt));
	}
	addWidget(m_vidCapFormats);
	connect(m_vidCapFormats, SIGNAL(activated(int)), SLOT(vidCapFormatChanged(int)));

	addLabel("Frame Width");
	m_frameWidth = new QSpinBox(parent);
	addWidget(m_frameWidth);
	connect(m_frameWidth, SIGNAL(editingFinished()), SLOT(frameWidthChanged()));
	addLabel("Frame Height");
	m_frameHeight = new QSpinBox(parent);
	addWidget(m_frameHeight);
	connect(m_frameHeight, SIGNAL(editingFinished()), SLOT(frameHeightChanged()));

	addLabel("Frame Size");
	m_frameSize = new QComboBox(parent);
	m_frameSize->setSizeAdjustPolicy(QComboBox::AdjustToContents);
	addWidget(m_frameSize);
	connect(m_frameSize, SIGNAL(activated(int)), SLOT(frameSizeChanged(int)));

	addLabel("Frame Interval");
	m_frameInterval = new QComboBox(parent);
	m_frameInterval->setSizeAdjustPolicy(QComboBox::AdjustToContents);
	addWidget(m_frameInterval);
	connect(m_frameInterval, SIGNAL(activated(int)), SLOT(frameIntervalChanged(int)));

	updateVidCapFormat();

	if (caps() & V4L2_CAP_VIDEO_OUTPUT) {
		addLabel("Output Image Formats");
		m_vidOutFormats = new QComboBox(parent);
		if (enum_fmt_out(fmt, true)) {
			do {
				m_vidOutFormats->addItem(pixfmt2s(fmt.pixelformat) +
						" - " + (const char *)fmt.description);
			} while (enum_fmt_out(fmt));
		}
		addWidget(m_vidOutFormats);
		connect(m_vidOutFormats, SIGNAL(activated(int)), SLOT(vidOutFormatChanged(int)));
	}

	addLabel("Capture Method");
	m_capMethods = new QComboBox(parent);
	if (m_querycap.capabilities & V4L2_CAP_STREAMING) {
		v4l2_requestbuffers reqbuf;

		// Yuck. The videobuf framework does not accept a count of 0.
		// This is out-of-spec, but it means that the only way to test which
		// method is supported is to give it a non-zero count. But non-videobuf
		// drivers like uvc do not allow e.g. S_FMT calls after a REQBUFS call
		// with non-zero counts unless there is a REQBUFS call with count == 0
		// in between. This is actual proper behavior, although somewhat
		// unexpected. So the only way at the moment to do this that works
		// everywhere is to call REQBUFS with a count of 1, and then again with
		// a count of 0.
		if (reqbufs_user_cap(reqbuf, 1)) {
			m_capMethods->addItem("User pointer I/O", QVariant(methodUser));
			reqbufs_user_cap(reqbuf, 0);
		}
		if (reqbufs_mmap_cap(reqbuf, 1)) {
			m_capMethods->addItem("Memory mapped I/O", QVariant(methodMmap));
			reqbufs_mmap_cap(reqbuf, 0);
		}
	}
	if (m_querycap.capabilities & V4L2_CAP_READWRITE) {
		m_capMethods->addItem("read()", QVariant(methodRead));
	}
	addWidget(m_capMethods);

	QGridLayout::addWidget(new QWidget(parent), rowCount(), 0, 1, n);
	setRowStretch(rowCount() - 1, 1);
}
Esempio n. 4
0
void VOCODE3::doupdate()
{
	double p[15];
	update(p, 15);

	_amp = p[3];

	bool setallmodfilts = false;
	bool setallcarfilts = false;

	if (p[10] != _modq) {
		_modq = p[10];
		setallmodfilts = true;
	}
	if (p[11] != _carq) {
		_carq = p[11];
		setallcarfilts = true;
	}

	if (p[8] != _modtransp) {
		_modtransp = p[8];
		setallmodfilts = true;
	}
	if (p[9] != _cartransp) {
		_cartransp = p[9];
		setallcarfilts = true;
	}

	if (setallmodfilts) {
		for (int i = 0; i < _numfilts; i++) {
			_modtable_prev[i] = _modtable_src[i];     // src freq may've changed
			float freq = updateFreq(_modtable_src[i], _modtransp);
			_modulator_filt[i]->setparams(freq, _modq);
		}
	}
	else if (p[4] != 0.0) {                // mod. cf table has changed
		for (int i = 0; i < _numfilts; i++) {
			if (_modtable_prev[i] != _modtable_src[i]) {
				_modtable_prev[i] = _modtable_src[i];
				float freq = updateFreq(_modtable_src[i], _modtransp);
				_modulator_filt[i]->setparams(freq, _modq);
			}
		}
	}

	if (setallcarfilts) {
		for (int i = 0; i < _numfilts; i++) {
			_cartable_prev[i] = _cartable_src[i];
			float freq = updateFreq(_cartable_src[i], _cartransp);
			_carrier_filt[i]->setparams(freq, _carq);
		}
	}
	else if (p[5] != 0.0) {                // car. cf table has changed
		for (int i = 0; i < _numfilts; i++) {
			if (_cartable_prev[i] != _cartable_src[i]) {
				_cartable_prev[i] = _cartable_src[i];
				float freq = updateFreq(_cartable_src[i], _cartransp);
				_carrier_filt[i]->setparams(freq, _carq);
			}
		}
	}

	if (p[6] != 0.0) {                     // mapping table has changed
		for (int i = 0; i < _numfilts; i++)
			_maptable[i] = int(_maptable_src[i]);
	}

	const float rt = (_nargs > 12) ? p[12] : 0.01f;
	if (rt != _responsetime) {
		_responsetime = rt;
		int windowlen = int(_responsetime * SR + 0.5f);
		if (windowlen < 2)   // otherwise, can get ear-splitting output
			windowlen = 2;
		for (int i = 0; i < _numfilts; i++)
			_balancer[i]->setwindow(windowlen);
	}

	int newhold = int(p[13]);
	if (newhold != _hold) {
		_hold = newhold;
		if (_hold) {
			for (int i = 0; i < _numfilts; i++) {
				_lastmod[i] = _modulator_filt[i]->last();
				// _modulator_filt[i]->clear();	// doesn't seem necessary
			}
		}
	}

	_pan = (_nargs > 14) ? p[14] : 0.5f;
}
Esempio n. 5
0
int VOCODE3::init(double p[], int n_args)
{
	_nargs = n_args;
	if (_nargs < 11)
		return usage();

	const float outskip = p[0];
	const float inskip = p[1];
	const float dur = p[2];

	if (rtsetoutput(outskip, dur, this) == -1)
		return DONT_SCHEDULE;
	if (rtsetinput(inskip, this) == -1)
		return DONT_SCHEDULE;

	if (outputChannels() > 2)
		return die("VOCODE3", "Output must be either mono or stereo.");
	if (inputChannels() != 2)
		return die("VOCODE3",
		"Must use 2 input channels: 'left' for carrier; 'right' for modulator.");

	_modtable_src = (double *) getPFieldTable(4, &_numfilts);
	if (_modtable_src == NULL)
		return die("VOCODE3", "p4 must have the modulator center freq. table.");
	int len;
	_cartable_src = (double *) getPFieldTable(5, &len);
	if (_cartable_src == NULL)
		return die("VOCODE3", "p5 must have the carrier center freq. table.");
	if (len != _numfilts)
		return die("VOCODE3", "Modulator and carrier center freq. tables must "
									 "be the same size.");
	_modtable_prev = new double [_numfilts];   // these two arrays inited below
	_cartable_prev = new double [_numfilts];

	_maptable_src = (double *) getPFieldTable(6, &len);
	if (_maptable_src && (len != _numfilts))
		return die("VOCODE3", "Center freq. mapping table (p6) must be the same "
									 "size as the modulator and carrier tables.");
	_maptable = new int [_numfilts];
	if (_maptable_src) {
		for (int i = 0; i < _numfilts; i++)
			_maptable[i] = int(_maptable_src[i]);
	}
	else {	// no user mapping table; make linear mapping
		for (int i = 0; i < _numfilts; i++)
			_maptable[i] = i;
	}

	_scaletable = (double *) getPFieldTable(7, &len);
	if (_scaletable && (len != _numfilts))
		return die("VOCODE3", "The carrier scaling table must be the same size "
		                      "(%d elements) as the carrier frequency table.",
		                      _numfilts);

	_modtransp = p[8];
	_cartransp = p[9];
	_modq = p[10];
	_carq = p[11];

	_lastmod = new float [_numfilts];

	_modulator_filt = new Oequalizer * [_numfilts];
	_carrier_filt = new Oequalizer * [_numfilts];
	_balancer = new Obalance * [_numfilts];

#ifdef NOTYET
	const bool print_stats = Option::printStats();
#else
	const bool print_stats = true;
#endif
	if (print_stats) {
		rtcmix_advise(NULL, "VOCODE3:  mod. CF\tcar. CF  [Hz, after transp]");
		rtcmix_advise(NULL, "          (Q=%2.1f)\t(Q=%2.1f)", _modq, _carq);
		rtcmix_advise(NULL, "          -----------------------------------------");
	}

	for (int i = 0; i < _numfilts; i++) {
		_modulator_filt[i] = new Oequalizer(SR, kBandPassType);
		_modtable_prev[i] = _modtable_src[i];
		float mfreq = updateFreq(_modtable_src[i], _modtransp);
		_modulator_filt[i]->setparams(mfreq, _modq);

		_carrier_filt[i] = new Oequalizer(SR, kBandPassType);
		_cartable_prev[i] = _cartable_src[i];
		float cfreq = updateFreq(_cartable_src[i], _cartransp);
		_carrier_filt[i]->setparams(cfreq, _carq);

		_balancer[i] = new Obalance(SR);

		_lastmod[i] = 0.0f;	// not necessary

		if (print_stats)
			rtcmix_advise(NULL, "          %7.1f\t%7.1f", mfreq, cfreq);
	}

	return nSamps();
}