Example #1
0
bool ScreenReaderDriverWE::Speak(const wchar_t *str, bool interrupt) {
  if (!controller) return false;
  if (interrupt && !Silence()) return false;
  const BSTR bstr = SysAllocString(str);
  const bool succeeded = SUCCEEDED(speech->Speak(bstr, varOpt));
  SysFreeString(bstr);
  return succeeded;
}
Example #2
0
CSoundStream::CSoundStream ()
    : m_pStream(NULL)
{
    m_nSampleBufferSize = (FRAGMENT_SIZE + (m_nSamplesPerFrame * GetOption(latency))) * m_nSampleSize;
    TRACE("Sample buffer size = %d samples\n", m_nSampleBufferSize/m_nSampleSize);
    m_pbEnd = (m_pbNow = m_pbStart = new BYTE[m_nSampleBufferSize]) + m_nSampleBufferSize;

    Silence();
}
Example #3
0
bool ScreenReaderDriverWE::Output(const wchar_t *str, bool interrupt) {
  if (interrupt && !Silence()) return false;
  const BSTR bstr = SysAllocString(str);
  // Beware short-circuiting.
  const bool speakSucceeded = SUCCEEDED(speech->Speak(bstr, varOpt));
  const bool brailleSucceeded = SUCCEEDED(braille->Display(bstr, varOpt, varOpt));
  SysFreeString(bstr);
  return (speakSucceeded || brailleSucceeded);
}
Example #4
0
static void
UpdateSequence(struct namcona *chip, struct sequence *pSequence )
{
	UINT16 *pStatus = GetSequenceStatusAddr(chip,pSequence);
	UINT16 data = *pStatus;

	if( data&0x0040 )
	{ /* bit 0x0040 indicates that a sound request was written by the main CPU */
		int offs = ReadMetaDataWord(chip,0)+(data>>8)*2;
		memset( pSequence, 0x00, sizeof(struct sequence) );
		if( pSequence == &chip->mSequence[0] ) Silence(chip); /* hack! */
		pSequence->addr = ReadMetaDataWord(chip,offs);
		*pStatus = (data&0xffbf)|0x0080; /* set "sequence-is-playing" flag */
	}
Example #5
0
int main(int argc, char *argv[])
{
	int pitch = 48;  // middle C
	FrqValue duration = 1.0;
	AmpValue lfoAmp = 10;
	bsInt32 tl = 16384;

	if (argc > 1)
		duration = atof(argv[1]);
	if (argc > 2)
		pitch = atoi(argv[2]);
	if (argc > 3)
		tl = atol(argv[3]);

	InitSynthesizer(44100, tl);

	FrqValue frequency = synthParams.GetFrequency(pitch);
	
	if (wvf.OpenWaveFile("example04.wav", 1) < 0)
	{
		printf("Cannot open wavefile for output\n");
		exit(1);
	}

	//EnvGen eg;
	EnvGenExp eg;
	//EnvGenLog eg;
	eg.SetBias(0.2);
	eg.InitEG(0.7, duration, 0.2, 0.3);

	GenWaveWT wv;
	GenWaveI  wvi;
	GenWave32 wv32;
	//GenWave64 wv64;
	GenWaveFM wvfm;
	GenWaveAM wvam;
	GenWaveRM wvrm;

	/////////////////////////////////////////////////
	// 1 - sine wave
	/////////////////////////////////////////////////
	wv.InitWT(frequency, WT_SIN);
	Generate(duration, &wv, &eg);
	//GenerateVib(duration, &wv, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wv, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 2 - sine wave using interpolation
	/////////////////////////////////////////////////
	wvi.InitWT(frequency, WT_SIN);
	Generate(duration, &wvi, &eg);
	//GenerateVib(duration, &wvi, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wvi, &eg, lfoAmp);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 3 - fixed summation of sine waves
	/////////////////////////////////////////////////
	wv.InitWT(frequency, WT_SAW);
	Generate(duration, &wv, &eg);
	//GenerateVib(duration, &wv, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wv, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 4 - fixed summation of sine waves using interpolation
	/////////////////////////////////////////////////
	wvi.InitWT(frequency, WT_SAW);
	Generate(duration, &wvi, &eg);
	//GenerateVib(duration, &wvi, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wvi, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 5 - 32 bit fixed-point index,
	/////////////////////////////////////////////////
	wv32.InitWT(frequency, WT_SAW);
	Generate(duration, &wv32, &eg);
	//GenerateVib(duration, &wv32, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wv32, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 6 - 64 bit fixed-point index,
	/////////////////////////////////////////////////
	//wv64.InitWT(frequency, WT_SAW);
	//Generate(duration, &wv64, &eg);
	//GenerateVib(duration, &wv64, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wv64, &eg, lfoAmp);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 7 - square wave (summation)
	/////////////////////////////////////////////////
	wv.InitWT(frequency, WT_SQR);
	Generate(duration, &wv, &eg);
	//GenerateVib(duration, &wv, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wv, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 8 - triangle wave (summation)
	/////////////////////////////////////////////////
	wv.InitWT(frequency, WT_TRI);
	Generate(duration, &wv, &eg);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 9 - FM
	/////////////////////////////////////////////////
	wvfm.InitFM(frequency/2, 2.0, 1.0, WT_SIN);
	Generate(duration, &wvfm, &eg);
	wvfm.InitFM(frequency, 2.0, 1.0, WT_SIN);
	Generate(duration, &wvfm, &eg);
	//GenerateVib(duration, &wvfm, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wvfm, &eg, lfoAmp);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 10 - Amplitude Modulation
	/////////////////////////////////////////////////
	wvam.InitAM(frequency, frequency*2.5, 1.0, WT_SIN);
	Generate(duration, &wvam, &eg);

	/////////////////////////////////////////////////
	// 11 - Ring Modulation
	/////////////////////////////////////////////////
	wvrm.InitAM(frequency, frequency*2.5, 1.0, WT_SIN);
	Generate(duration, &wvrm, &eg);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 12 - Dynamic summing: sawtooth
	/////////////////////////////////////////////////
	GenWaveSum wvs;
	AmpValue mult[8];
	AmpValue amps[8];
	for (int pnum = 0; pnum < 8; pnum++)
	{
		AmpValue x = (AmpValue)pnum + 1;
		mult[pnum] = x;
		amps[pnum] = 1.0/x;
		if (pnum & 1)
			amps[pnum] = -amps[pnum];
	}
	wvs.InitParts(8, mult, amps, 1);
	wvs.InitWT(frequency, WT_SIN);
	Generate(duration, &wvs, &eg);
	//GenerateVib(duration, &wvs, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wvs, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 13 - Dynamic summing: doubling at the fifth
	/////////////////////////////////////////////////
	mult[0] = 1.0f;
	mult[1] = 1.5f;
	amps[0] = 0.5f;
	amps[1] = 0.5f;
	wvs.InitParts(2, mult, amps, 0);
	wvs.InitWT(frequency, WT_SAW);
	Generate(duration, &wvs, &eg);
	//GenerateVib(duration, &wvs, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 14 - Dynamic summing: chorus effect, two notes at slightly different frequency
	/////////////////////////////////////////////////
	mult[0] = 1.0;
	mult[1] = 1.001;
	amps[0] = 0.6;
	amps[1] = 0.4;
	wvs.InitParts(2, mult, amps, 0);
	wvs.InitWT(frequency, WT_SAW);
	Generate(duration, &wvs, &eg);
	//GenerateVib(duration, &wvs, &eg, lfoAmp);

	Silence(0.25);

	// For comparison:

	/////////////////////////////////////////////////
	// 15 - Sine wave Direct
	/////////////////////////////////////////////////
	GenWave wvsin;
	wvsin.Init(1, &frequency);
	Generate(duration, &wvsin, &eg);
	//GenerateVib(duration, &wvsin, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 16 - Sawtooth Direct
	/////////////////////////////////////////////////
	GenWaveSaw wvsaw;
	wvsaw.Init(1, &frequency);
	Generate(duration, &wvsaw, &eg);
	//GenerateVib(duration, &wvsaw, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wvsaw, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 17 - Triangle Direct
	/////////////////////////////////////////////////
	GenWaveTri wvtri;
	wvtri.Init(1, &frequency);
	Generate(duration, &wvtri, &eg);
	//GenerateVib(duration, &wvtri, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wvtri, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 18 - Square Direct
	/////////////////////////////////////////////////
	GenWaveSqr wvsqr;
	wvsqr.InitSqr(frequency, 50.0);
	Generate(duration, &wvsqr, &eg);
	//GenerateVib(duration, &wvsqr, &eg, lfoAmp);
	//GeneratePhaseVib(duration, &wvsqr, &eg, lfoAmp);

	/////////////////////////////////////////////////
	// 19 - Square Direct Integer
	/////////////////////////////////////////////////
	GenWaveSqr32 wvsqr32;
	wvsqr32.InitSqr(frequency, 50.0);
	Generate(duration, &wvsqr32, &eg);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 20 - White Noise
	/////////////////////////////////////////////////
	GenNoise wvn;
	Generate(duration, &wvn, &eg);

	/////////////////////////////////////////////////
	// 21 - 'H' White Noise (sampled)
	/////////////////////////////////////////////////
	GenNoiseH wvnh;
	float h;
	for (h = 2000.0; h < 10000.0; h += 2000.0)
	{
		wvnh.Init(1, &h);
		Generate(duration, &wvnh, &eg);
	}

	/////////////////////////////////////////////////
	// 21 - 'Interploated' White Noise
	/////////////////////////////////////////////////
	GenNoiseI wvni;
	for (h = 2000.0; h < 10000.0; h += 2000.0)
	{
		wvni.Init(1, &h);
		Generate(duration, &wvni, &eg);
	}

	Silence(0.25);


	/////////////////////////////////////////////////
	// 22 - "Pink-ish" Noise (FIR filter)
	/////////////////////////////////////////////////
	GenNoisePink1 wvp1;
	Generate(duration, &wvp1, &eg);

	/////////////////////////////////////////////////
	// 23 - "Pink-ish" Noise (IIR filter)
	/////////////////////////////////////////////////
	GenNoisePink2 wvp2;
	Generate(duration, &wvp2, &eg);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 23 - Pitched Noise (ring modulation of sine wave and noise)
	/////////////////////////////////////////////////
	GenWaveNZ wvnzp;
	wvnzp.InitNZ(500.0, 400.0, WT_SIN);
	Generate(duration, &wvnzp, &eg);
	wvnzp.InitNZ(800.0, 400.0, WT_SIN);
	Generate(duration, &wvnzp, &eg);

	Silence(0.25);

	/////////////////////////////////////////////////
	// 24 - BUZZ generator
	/////////////////////////////////////////////////
	GenWaveBuzz buzz;
	buzz.InitBuzz(frequency, 20);
	Generate(duration, &buzz, &eg);
	buzz.InitBuzz(frequency, 100);
	Generate(duration, &buzz, &eg);

//	buzz.InitBuzz(frequency, 100);
//	GenerateVib(duration, &buzz, &eg, lfoAmp);
//	GeneratePhaseVib(duration, &buzz, &eg, lfoAmp);

	Silence(0.25);

	GenWaveBuzz2 buzz2;
	buzz2.InitBuzz(frequency, 20);
	Generate(duration, &buzz2, &eg);
	buzz2.InitBuzz(frequency, 100);
	Generate(duration, &buzz2, &eg);

	Silence(0.25);

	GenWaveBuzzA buzza;
//	buzza.SetOscillatorA(new GenWaveI);
//	buzza.SetOscillatorB(new GenWaveI);
	buzza.InitBuzz(frequency, 20);
	Generate(duration, &buzza, &eg);
	buzza.InitBuzz(frequency, 100);
	Generate(duration, &buzza, &eg);

	Silence(0.25);
	
	GenWaveDS ds;
	ds.InitDS(frequency, 0.5);
	Generate(duration, &ds, &eg);
	ds.InitDS(frequency, 0.95);
	Generate(duration, &ds, &eg);

	Silence(0.25);

	GenWaveDSB gbz;
	gbz.InitDSB(frequency, 1, 100, 0.5);
	Generate(duration, &gbz, &eg);
	gbz.InitDSB(frequency, 1, 100, 0.95);
	Generate(duration, &gbz, &eg);

	// Odd harmonics, like square wave
	gbz.InitDSB(frequency, 2, 100, 0.5);
	Generate(duration, &gbz, &eg);
	gbz.InitDSB(frequency, 2, 100, 0.95);
	Generate(duration, &gbz, &eg);

	/////////////////////////////////////////////////
	if (wvf.CloseWaveFile())
		perror("Close");

	return 0;
}
Example #6
0
int main(int argc, char *argv[])
{
	InitSynthesizer();

	long n;
	int pitch = 48;
	FrqValue duration = 2.75;
	AmpValue value1, value2;

	if (argc > 1)
		duration = atof(argv[1]);
	if (argc > 2)
		pitch = atoi(argv[2]);

	FrqValue frequency = synthParams.GetFrequency(pitch);

	if (wvf.OpenWaveFile("example07b.wav", 2))
	{
		printf("Cannot open wavefile for output\n");
		exit(1);
	}

	GenWaveFM wv;
	wv.InitFM(frequency, 1, 2, WT_SIN);

	EnvGen eg;
	eg.InitEG(0.5f, duration, 0.5f, 0.5f);

	long totalSamples = (long) ((duration * synthParams.sampleRate) + 0.5);

	// reference sound. 
	for (n = 0; n < totalSamples; n++)
	{
		value2 = (eg.Gen() * wv.Gen());
		wvf.Output1(value2);
	}
	Silence(0.25);


	// Flanger #1 varies from 0 to 5ms
	Flanger flng1;
	flng1.InitFlanger(0.5, 0.5, 0, 0.0025, 0.005, 0.15);

	// Flanger #2 varies from 45 to 50ms
	Flanger flng2;
	flng2.InitFlanger(0.5, 0.5, 0, 0.0042, 0.005, 0.15);

	// Flanger #3 is set for a chorus effect
	Flanger flng3;
	flng3.InitFlanger(0.5, 0.5, 0.5, 0.100, 0.001, 0.8);

	for (float snd = 0.5; snd <= 1; snd += 0.5)
	{
		wv.InitFM(frequency*snd, 1, 2, WT_SIN);
		eg.Reset();
		flng1.Clear();
		for (n = 0; n < totalSamples; n++)
		{
			value1 = (eg.Gen() * wv.Gen());
			value2 = flng1.Sample(value1);
			wvf.Output2(value2, value2);
		}
		Silence(0.25);

		eg.Reset();
		flng2.Clear();
		for (n = 0; n < totalSamples; n++)
		{
			value1 = (eg.Gen() * wv.Gen());
			value2 = flng2.Sample(value1);
			wvf.Output2(value2, value2);
		}
		Silence(0.25);

		eg.Reset();
		flng3.Clear();
		for (n = 0; n < totalSamples; n++)
		{
			value1 = (eg.Gen() * wv.Gen());
			value2 = flng3.Sample(value1);
			wvf.Output2(value2, value2);
		}
		Silence(0.25);
	}

	wvf.CloseWaveFile();

	return 0;
}