예제 #1
0
int rockola_sh_start(const struct MachineSound *msound)
{
	int vol[3];

	Machine->samples = readsamples(vanguard_sample_names,Machine->gamedrv->name);

	vol[0] = vol[1] = vol[2] = TONE_VOLUME;
	tonechannels = mixer_allocate_channels(3,vol);
	vol[0] = vol[1] = vol[2] = SAMPLE_VOLUME;
	samplechannels = mixer_allocate_channels(3,vol);

	NoSound0=1;
	Sound0Offset=0;
	Sound0Base=0x0000;
	NoSound1=1;
	Sound1Offset=0;
	Sound1Base=0x0800;
	NoSound2=1;
	Sound2Offset=0;
	Sound2Base=0x1000;

	mixer_set_volume(tonechannels+0,0);
	mixer_play_sample(tonechannels+0,(signed char*)waveform,32,1000,1);
	mixer_set_volume(tonechannels+1,0);
	mixer_play_sample(tonechannels+1,(signed char*)waveform,32,1000,1);
	mixer_set_volume(tonechannels+2,0);
	mixer_play_sample(tonechannels+2,(signed char*)waveform,32,1000,1);

	return 0;
}
예제 #2
0
파일: atarisnd.c 프로젝트: Bremma/pinmame
static void playSound(void) {
    if (Machine->gamedrv->flags & GAME_NO_SOUND)
        return;

    if (atarilocals.sound & 0x02) { // noise on
        int i;
        for (i=0; i < sizeof(noiseWave); i++)
            noiseWave[i] = (UINT8)(rand() % 256);
        stopNoise();
        mixer_set_volume(atarilocals.noisechannel, atarilocals.volume*4);
        mixer_play_sample(atarilocals.noisechannel, (signed char *)noiseWave, sizeof(noiseWave),
                          ATARI_SNDFREQ / (16-atarilocals.frequency) * (1 << atarilocals.octave), 1);
    }
    if (atarilocals.sound & 0x01) { // wave on
        stopSound();
        mixer_set_volume(atarilocals.channel, atarilocals.volume*4);
        if (atarilocals.waveform < 4)
            mixer_play_sample(atarilocals.channel, (signed char *)squareWave, sizeof(squareWave),
                              2 * ATARI_SNDFREQ / (16-atarilocals.frequency) * (1 << atarilocals.octave), 1);
        else if (atarilocals.waveform < 8)
            mixer_play_sample(atarilocals.channel, (signed char *)triangleWave, sizeof(triangleWave),
                              2 * ATARI_SNDFREQ / (16-atarilocals.frequency) * (1 << atarilocals.octave), 1);
        else if (atarilocals.waveform < 12)
            mixer_play_sample(atarilocals.channel, (signed char *)sineWave, sizeof(sineWave),
                              2 * ATARI_SNDFREQ / (16-atarilocals.frequency) * (1 << atarilocals.octave), 1);
        else
            mixer_play_sample(atarilocals.channel, (signed char *)sawtoothWave, sizeof(sawtoothWave),
                              2 * ATARI_SNDFREQ / (16-atarilocals.frequency) * (1 << atarilocals.octave), 1);
    }
}
예제 #3
0
int meadows_sh_start(const struct MachineSound *msound)
{
	int vol[2];

	vol[0]=vol[1]=255;
	channel = mixer_allocate_channels(2,vol);
	mixer_set_volume(channel,0);
	mixer_play_sample(channel,waveform,sizeof(waveform),freq1,1);
	mixer_set_volume(channel+1,0);
	mixer_play_sample(channel+1,waveform,sizeof(waveform),freq2,1);
    return 0;
}
예제 #4
0
void bosco_sample_play(int offset, int length)
{
	if (Machine->sample_rate == 0)
		return;

	mixer_play_sample(channel,speech + offset,length,4000,0);
}
예제 #5
0
파일: cclimber.c 프로젝트: cdrr/MAME_hack
static void cclimber_play_sample(int start,int freq,int volume)
{
	int len;
	const UINT8 *rom = memory_region(REGION_SOUND1);


	if (!rom) return;

	/* decode the rom samples */
	len = 0;
	while (start + len < memory_region_length(REGION_SOUND1) && rom[start+len] != 0x70)
	{
		int sample;

		sample = (rom[start + len] & 0xf0) >> 4;
		samplebuf[2*len] = SAMPLE_CONV4(sample) * volume / 31;

		sample = rom[start + len] & 0x0f;
		samplebuf[2*len + 1] = SAMPLE_CONV4(sample) * volume / 31;

		len++;
	}

	mixer_play_sample(channel,samplebuf,2 * len,freq,0);
}
예제 #6
0
int senjyo_sh_start(const struct MachineSound *msound)
{
    int i;


	channel = mixer_allocate_channel(15);
	mixer_set_name(channel,"Tone");

	/* z80 ctc init */
	ctc_intf.baseclock[0] = Machine->drv->cpu[1].cpu_clock;
	z80ctc_init (&ctc_intf);

	/* z80 pio init */
	z80pio_init (&pio_intf);

	if ((_single = (signed char *)malloc(SINGLE_LENGTH)) == 0)
	{
		free(_single);
		return 1;
	}
	for (i = 0;i < SINGLE_LENGTH;i++)		/* freq = ctc2 zco / 8 */
		_single[i] = ((i/SINGLE_DIVIDER)&0x01)*127;

	/* CTC2 single tone generator */
	mixer_set_volume(channel,0);
	mixer_play_sample(channel,_single,SINGLE_LENGTH,single_rate,1);

	return 0;
}
예제 #7
0
/* mixer_play_sample() */
void sample_start(int channel,int samplenum,int loop)
{
    if (Machine->sample_rate == 0) return;
    if (Machine->samples == 0) return;
    if (Machine->samples->sample[samplenum] == 0) return;
    if (channel >= numchannels)
    {
        logerror("error: sample_start() called with channel = %d, but only %d channels allocated\n",channel,numchannels);
        return;
    }
    if (samplenum >= Machine->samples->total)
    {
        logerror("error: sample_start() called with samplenum = %d, but only %d samples available\n",samplenum,Machine->samples->total);
        return;
    }

    if ( Machine->samples->sample[samplenum]->resolution == 8 )
    {
        logerror("play 8 bit sample %d, channel %d\n",samplenum,channel);
        mixer_play_sample(firstchannel + channel,
                          Machine->samples->sample[samplenum]->data,
                          Machine->samples->sample[samplenum]->length,
                          Machine->samples->sample[samplenum]->smpfreq,
                          loop);
    }
    else
    {
        logerror("play 16 bit sample %d, channel %d\n",samplenum,channel);
        mixer_play_sample_16(firstchannel + channel,
                             (short *) Machine->samples->sample[samplenum]->data,
                             Machine->samples->sample[samplenum]->length,
                             Machine->samples->sample[samplenum]->smpfreq,
                             loop);
    }
}
예제 #8
0
int rockola_sh_start(const struct MachineSound *msound)
{
	int vol[CHANNELS];
	int i, offs = 0;

	// allocate tone channels

	for (i = 0; i < CHANNELS; i++)
		vol[i] = TONE_VOLUME;

	tonechannels = mixer_allocate_channels(CHANNELS, vol);

	// allocate sample channels

	for (i = 0; i < CHANNELS; i++)
		vol[i] = SAMPLE_VOLUME;

	samplechannels = mixer_allocate_channels(CHANNELS, vol);

	// clear tone channels

	for (i = 0; i < CHANNELS; i++)
	{
		SoundMute[i] = 1;
		SoundOffset[i] = 0;
		SoundBase[i] = offs;

		offs += 0x800;

		mixer_set_volume(tonechannels + i, 0);
		mixer_play_sample(tonechannels + i, (signed char *)waveform, 32, 1000, 1);
	}

	return 0;
}
예제 #9
0
파일: atarisnd.c 프로젝트: Bremma/pinmame
static WRITE_HANDLER(atari_gen1_w) {
    if (data) {
        atarilocals.frequency = data & 0x0f;
        atarilocals.waveform = data >> 4;
        if (atarilocals.waveform < 4)
            mixer_play_sample(atarilocals.channel, (signed char *)squareWave, sizeof(squareWave),
                              2 * ATARI_SNDFREQ / (16 - atarilocals.frequency), 1);
        else if (atarilocals.waveform < 8)
            mixer_play_sample(atarilocals.channel, (signed char *)triangleWave, sizeof(triangleWave),
                              2 * ATARI_SNDFREQ / (16 - atarilocals.frequency), 1);
        else if (atarilocals.waveform < 12)
            mixer_play_sample(atarilocals.channel, (signed char *)sineWave, sizeof(sineWave),
                              2 * ATARI_SNDFREQ / (16 - atarilocals.frequency), 1);
        else
            mixer_play_sample(atarilocals.channel, (signed char *)sawtoothWave, sizeof(sawtoothWave),
                              2 * ATARI_SNDFREQ / (16 - atarilocals.frequency), 1);
    } else {
        if (mixer_is_sample_playing(atarilocals.channel))
예제 #10
0
int targ_sh_start(const struct MachineSound *msound)
{
	tone_channel = mixer_allocate_channel(50);

	tone_pointer=0;
	tone_offset=0;
	tone_active=0;
	sound_a_freq = 0x00;
	mixer_set_volume(tone_channel,0);
	mixer_play_sample(tone_channel,(signed char*)waveform1,32,1000,1);
	return 0;
}
예제 #11
0
파일: playsnd.c 프로젝트: chrisjubb/pinmame
static WRITE_HANDLER(play2s_ctrl_w) {
  if (!sndlocals.enSn && (data & 1)) { // sound on to full volume
    timer_adjust(sndlocals.timer, TIME_NEVER, 0, 0);
    if (!mixer_is_sample_playing(sndlocals.channel)) {
      mixer_play_sample(sndlocals.channel, (signed char *)squareWave, sizeof(squareWave), 2950000.0 / 4 / (sndlocals.freq + 1), 1);
    }
    sndlocals.volume = 100;
    mixer_set_volume(sndlocals.channel, sndlocals.volume);
  } else if (!(data & 1) && sndlocals.enSn) { // start fading
    timer_adjust(sndlocals.timer, TIME_IN_HZ(120), 0, TIME_IN_HZ(120));
  }
  sndlocals.enSn = data & 1;
}
예제 #12
0
파일: samples.c 프로젝트: neiderm/arcade
void sample_start2(int channel,unsigned char *data,int len,int freq,int volume,int loop)
{
	if (channel >= numchannels)
	{
		if (errorlog) fprintf(errorlog,"error: sample_start() called with channel = %d, but only %d channels allocated\n",channel,numchannels);
		return;
	}

	mixer_play_sample(firstchannel + channel,
				data,
				len,
				freq,
				loop);
}
예제 #13
0
파일: namco52.c 프로젝트: Sunoo/nonamemame
void namcoio_52XX_write(int data)
{
	data &= 0x0f;

//logerror("%04x: custom 52XX write %02x\n",activecpu_get_pc(),data);

	if (Machine->sample_rate == 0)
		return;

	if (data != 0)
	{
		int start = rom[data-1] + (rom[data-1+0x10] << 8);
		int end   = rom[data] + (rom[data+0x10] << 8);

		if (end >= rom_len)
			end = rom_len;

		if (start < end)
			mixer_play_sample(channel, samples + start * 2, (end - start) * 2, intf->baseclock/384, 0);
	}
}
예제 #14
0
파일: votrax.c 프로젝트: cdrr/MAME_hack
void votrax_w(int data)
{
	int Phoneme,Intonation;

    Phoneme = data & 0x3F;
    Intonation = data >> 6;

  	if(errorlog) fprintf(errorlog,"Speech : %s at intonation %d\n",VotraxTable[Phoneme],Intonation);

    if(Phoneme==63)
   		mixer_stop_sample(VotraxChannel);

    if(VotraxSamples->sample[Phoneme])
	{
		mixer_set_volume(VotraxChannel,VotraxBaseVolume+(8*Intonation)*100/255);
		mixer_play_sample(VotraxChannel,VotraxSamples->sample[Phoneme]->data,
				  VotraxSamples->sample[Phoneme]->length,
				  VotraxBaseFrequency+(256*Intonation),
				  0);
	}
}