static void gpsm_init(struct sndbrdData *brdData) { int mixing_levels[4] = {25,25,25,25}; int i; int s = 0; memset(&gps_locals, 0x00, sizeof(gps_locals)); gps_locals.brdData = *brdData; for (i = 0;i < 32000;i++) { s = (s ? 0 : 1); if (s) { sineWaveext[i] = rand(); } else sineWaveext[i] = 0-rand(); } pia_config(GPS_PIA0, PIA_STANDARD_ORDERING, &gps_pia[0]); pia_config(GPS_PIA1, PIA_STANDARD_ORDERING, &gps_pia[1]); gps_locals.channel = mixer_allocate_channels(4, mixing_levels); mixer_set_name (gps_locals.channel, "MC6840 #Q1"); // 6840 Output timer 1 (q1) is easy wave mixer_set_volume(gps_locals.channel,0); mixer_set_name (gps_locals.channel+1,"MC6840 #Q2"); // 6840 Output timer 2 (q2) is easy wave mixer_set_volume(gps_locals.channel+1,0); mixer_set_name (gps_locals.channel+2,"MC6840 #Q3"); // 6840 Output timer 3 (q3) is easy wave mixer_set_volume(gps_locals.channel+2,0); mixer_set_name (gps_locals.channel+3,"Noise"); // Noise generator mixer_set_volume(gps_locals.channel+3,0); mixer_play_sample_16(gps_locals.channel+3,sineWaveext, sizeof(sineWaveext), 625000 , 1); gps_locals.stateca1 = 0; timer_set(TIME_IN_NSEC(814000000),0,oneshoot); // fire ca1 only once // // this time should run to emulate the 6840 correctly, but it is not needed for gampelan games i think // because the sound rum never reads back the decreased values from the m6840 // // timer_pulse(TIME_IN_HZ(MSU1_INTCLOCK),0x02,m6840_pulse); // start internal clock 6840 // }
static int st300_sh_start(const struct MachineSound *msound) { int mixing_levels[3] = {30,30,30}; int i; int s = 0; memset(&st300loc, 0, sizeof(st300loc)); for (i = 0;i < 9;i++) { snddatst300.ax[i] = 0; snddatst300.axb[i] = 0; snddatst300.c0 = 0; } for (i = 0;i < 32000;i++) { s = (s ? 0 : 1); if (s) { sineWaveext[i] = rand(); } else sineWaveext[i] = 0-rand(); } st300loc.channel = mixer_allocate_channels(3, mixing_levels); mixer_set_name (st300loc.channel, "MC6840 #Q2"); // 6840 Output timer 2 (q2) is easy wave + volume from q3 mixer_set_volume(st300loc.channel,0); mixer_set_name (st300loc.channel+1, "MC6840 #Q1"); // 6840 Output timer 1 (q1) is easy wave + volume always 100 mixer_set_volume(st300loc.channel+1,70*ST300_VOL); mixer_set_name (st300loc.channel+2, "EXT TIM"); // External Timer (U10) is Noise geneartor + volume from q3 mixer_set_volume(st300loc.channel+2,0); timer_pulse(TIME_IN_HZ(ST300_INTCLOCK),0x02,st300_pulse); // start internal clock return 0; }
int stream_init_multi(int channels,const char **names,const int *default_mixing_levels, int sample_rate, int param,void (*callback)(int param,INT16 **buffer,int length)) { int channel,i; channel = mixer_allocate_channels(channels,default_mixing_levels); stream_joined_channels[channel] = channels; for (i = 0;i < channels;i++) { mixer_set_name(channel+i,names[i]); if ((stream_buffer[channel+i] = osd_malloc(sizeof(INT16)*BUFFER_LEN)) == 0) return -1; stream_sample_rate[channel+i] = sample_rate; stream_buffer_pos[channel+i] = 0; if (sample_rate) stream_sample_length[channel+i] = 1000000 / sample_rate; else stream_sample_length[channel+i] = 0; } stream_param[channel] = param; stream_callback_multi[channel] = callback; set_RC_filter(channel,0,0,0,0); return channel; }
int stream_init(const char *name,int default_mixing_level, int sample_rate, int param,void (*callback)(int param,INT16 *buffer,int length)) { int channel; channel = mixer_allocate_channel(default_mixing_level); stream_joined_channels[channel] = 1; mixer_set_name(channel,name); if ((stream_buffer[channel] = osd_malloc(sizeof(INT16)*BUFFER_LEN)) == 0) return -1; stream_sample_rate[channel] = sample_rate; stream_buffer_pos[channel] = 0; if (sample_rate) stream_sample_length[channel] = 1000000 / sample_rate; else stream_sample_length[channel] = 0; stream_param[channel] = param; stream_callback[channel] = callback; set_RC_filter(channel,0,0,0,0); return channel; }
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; }
int namco_52xx_sh_start(const struct MachineSound *msound) { int i; unsigned char bits; intf = msound->sound_interface; rom = memory_region(intf->region); rom_len = memory_region_length(intf->region); channel = mixer_allocate_channel(intf->mixing_level); mixer_set_name(channel,sound_name(msound)); samples = auto_malloc(2*rom_len); if (!samples) return 1; /* decode the rom samples */ for (i = 0;i < rom_len;i++) { bits = rom[i] & 0x0f; samples[2*i] = SAMPLE_CONV4(bits); bits = (rom[i] & 0xf0) >> 4; samples[2*i + 1] = SAMPLE_CONV4(bits); } return 0; }
int pbillian_sh_start(const struct MachineSound *msound) { int i; unsigned char *ROM = memory_region(REGION_SOUND1); channel = mixer_allocate_channel(50); mixer_set_name(channel,"Samples"); samplebuf = auto_malloc(memory_region_length(REGION_SOUND1)); for(i=0;i<memory_region_length(REGION_SOUND1);i++)samplebuf[i]=ROM[i]-0x80; return 0; }
int polyplay_sh_start(const struct MachineSound *msound) { int i; for (i = 0; i < SAMPLE_LENGTH / 2; i++) { backgroundwave[i] = + SAMPLE_AMPLITUDE; } for (i = SAMPLE_LENGTH / 2; i < SAMPLE_LENGTH; i++) { backgroundwave[i] = - SAMPLE_AMPLITUDE; } freq1 = freq2 = 110; channellfo = mixer_allocate_channels(2,lfovol); mixer_set_name(channellfo+0,"Polyplay #0"); mixer_set_name(channellfo+1,"Polyplay #1"); mixer_set_volume(channellfo+0,0); mixer_set_volume(channellfo+1,0); channel_playing1 = 0; channel_playing2 = 0; return 0; }
int mixer_allocate_channels(int channels, const int *default_mixing_levels) { int i, j; /* make sure we didn't overrun the number of available channels */ if (first_free_channel + channels > MIXER_MAX_CHANNELS) { logerror("Too many mixer channels (requested %d, available %d)\n", first_free_channel + channels, MIXER_MAX_CHANNELS); exit(1); } /* loop over channels requested */ for (i = 0; i < channels; i++) { struct mixer_channel_data *channel = &mixer_channel[first_free_channel + i]; /* extract the basic data */ channel->default_mixing_level = MIXER_GET_LEVEL(default_mixing_levels[i]); channel->pan = MIXER_GET_PAN(default_mixing_levels[i]); channel->gain = MIXER_GET_GAIN(default_mixing_levels[i]); channel->volume = 100; /* backwards compatibility with old 0-255 volume range */ if (channel->default_mixing_level > 100) channel->default_mixing_level = channel->default_mixing_level * 25 / 255; /* attempt to load in the configuration data for this channel */ channel->mixing_level = channel->default_mixing_level; if (!config_invalid) { /* if the defaults match, set the mixing level from the config */ if (channel->default_mixing_level == channel->config_default_mixing_level) channel->mixing_level = channel->config_mixing_level; /* otherwise, invalidate all channels that have been created so far */ else { config_invalid = 1; for (j = 0; j < first_free_channel + i; j++) mixer_set_mixing_level(j, mixer_channel[j].default_mixing_level); } } /* set the default name */ mixer_set_name(first_free_channel + i, 0); } /* increment the counter and return the first one */ first_free_channel += channels; return first_free_channel - channels; }
int cclimber_sh_start(const struct MachineSound *msound) { channel = mixer_allocate_channel(50); mixer_set_name(channel,"Samples"); samplebuf = 0; if (memory_region(REGION_SOUND1)) { samplebuf = malloc(2*memory_region_length(REGION_SOUND1)); if (!samplebuf) return 1; } return 0; }
int seta_sh_start(const struct MachineSound *msound) { int i; int mix_lev[SETA_NUM_CHANNELS]; for (i = 0; i < SETA_NUM_CHANNELS; i++) mix_lev[i] = (100 * 2) / SETA_NUM_CHANNELS + 1; firstchannel = mixer_allocate_channels(SETA_NUM_CHANNELS,mix_lev); for (i = 0; i < SETA_NUM_CHANNELS; i++) { char buf[40]; sprintf(buf,"X1-010 Channel #%d",i); mixer_set_name(firstchannel + i,buf); } return 0; }
int samples_sh_start(const struct MachineSound *msound) { int i; int vol[MIXER_MAX_CHANNELS]; const struct Samplesinterface *intf = msound->sound_interface; /* read audio samples if available */ Machine->samples = readsamples(intf->samplenames,Machine->gamedrv->name); numchannels = intf->channels; for (i = 0; i < numchannels; i++) vol[i] = intf->volume; firstchannel = mixer_allocate_channels(numchannels,vol); for (i = 0; i < numchannels; i++) { char buf[40]; sprintf(buf,"Sample #%d",i); mixer_set_name(firstchannel + i,buf); } return 0; }
int bosco_sh_start(const struct MachineSound *msound) { int i; unsigned char bits; channel = mixer_allocate_channel(25); mixer_set_name(channel,"Samples"); speech = auto_malloc(2*memory_region_length(REGION_SOUND2)); if (!speech) return 1; /* decode the rom samples */ for (i = 0;i < memory_region_length(REGION_SOUND2);i++) { bits = memory_region(REGION_SOUND2)[i] & 0x0f; speech[2*i] = SAMPLE_CONV4(bits); bits = (memory_region(REGION_SOUND2)[i] & 0xf0) >> 4; speech[2*i + 1] = SAMPLE_CONV4(bits); } return 0; }