void mm6221aa_tune_w(int chip, int tune) { struct TMS36XX *tms = sndti_token(SOUND_TMS36XX, chip); /* which tune? */ tune &= 3; if( tune == tms->tune_num ) return; LOG(("%s tune:%X\n", tms->subtype, tune)); /* update the stream before changing the tune */ stream_update(tms->channel); tms->tune_num = tune; tms->tune_ofs = 0; tms->tune_max = 96; /* fixed for now */ }
void okim6295_device::set_bank_base(offs_t base) { // flush out anything pending stream_update(m_stream); // if we are setting a non-zero base, and we have no bank, allocate one if (!m_bank_installed && base != 0) { // override our memory map with a bank memory_install_read_bank(space(), 0x00000, 0x3ffff, 0, 0, tag()); m_bank_installed = true; } // if we have a bank number, set the base pointer if (m_bank_installed) { m_bank_offs = base; memory_set_bankptr(&m_machine, tag(), m_region->base() + base); } }
void channelf_sound_w(int mode) { if (mode == sound_mode) return; stream_update(channel, 0); sound_mode = mode; switch(mode) { case 0: envelope = 0; break; case 1: case 2: case 3: envelope = max_amplitude; break; } }
void wave_close(int id) { struct wave_file *w = &wave[id]; if( !w->file ) return; if( w->timer ) { if( w->channel != -1 ) stream_update(w->channel, 0); w->samples = w->playpos; w->length = w->samples * w->resolution / 8; timer_remove(w->timer); w->timer = NULL; } if( w->mode ) { wave_output(id,0); wave_write(id); w->mode = 0; } if( w->data ) free(w->data); w->data = NULL; if (w->file) { osd_fclose(w->file); w->file = NULL; } w->offset = 0; w->playpos = 0; w->counter = 0; w->smpfreq = 0; w->resolution = 0; w->samples = 0; w->length = 0; }
void tms36xx_note_w(const device_config *device, int octave, int note) { tms_state *tms = get_safe_token(device); octave &= 3; note &= 15; if (note > 12) return; LOG(("%s octave:%X note:%X\n", tms->subtype, octave, note)); /* update the stream before changing the tune */ stream_update(tms->channel); /* play a single note from 'tune 4', a list of the 13 tones */ tms36xx_reset_counters(tms); tms->octave = octave; tms->tune_num = 4; tms->tune_ofs = note; tms->tune_max = note + 1; }
void sample_start_raw_n(int num,int channel,INT16 *sampledata,int samples,int frequency,int loop) { struct samples_info *info = sndti_token(SOUND_SAMPLES, num); struct sample_channel *chan; assert( channel < info->numchannels ); chan = &info->channel[channel]; /* force an update before we start */ stream_update(chan->stream); /* update the parameters */ chan->source = sampledata; chan->source_length = samples; chan->source_num = -1; chan->pos = 0; chan->frac = 0; chan->basefreq = frequency; chan->step = ((INT64)chan->basefreq << FRAC_BITS) / Machine->sample_rate; chan->loop = loop; }
void sample_start_raw(const device_config *device,int channel,const INT16 *sampledata,int samples,int frequency,int loop) { samples_info *info = get_safe_token(device); sample_channel *chan; assert( channel < info->numchannels ); chan = &info->channel[channel]; /* force an update before we start */ stream_update(chan->stream); /* update the parameters */ chan->source = sampledata; chan->source_length = samples; chan->source_num = -1; chan->pos = 0; chan->frac = 0; chan->basefreq = frequency; chan->step = ((INT64)chan->basefreq << FRAC_BITS) / info->device->machine->sample_rate; chan->loop = loop; }
void ay8910_write_ym(void *chip, int addr, int data) { ay8910_context *psg = chip; if (addr & 1) { /* Data port */ int r = psg->register_latch; if (r > 15) return; if (r == AY_ESHAPE || psg->regs[r] != data) { /* update the output buffer before changing the register */ stream_update(psg->channel); } ay8910_write_reg(psg,r,data); } else { /* Register port */ psg->register_latch = data & 0x0f; } }
void tms36xx_note_w(int chip, int octave, int note) { struct TMS36XX *tms = tms36xx[chip]; octave &= 3; note &= 15; if (note > 12) return; LOG((errorlog,"%s octave:%X note:%X\n", tms->subtype, octave, note)); /* update the stream before changing the tune */ stream_update(tms->channel,0); /* play a single note from 'tune 4', a list of the 13 tones */ tms36xx_reset_counters(chip); tms->octave = octave; tms->tune_num = 4; tms->tune_ofs = note; tms->tune_max = note + 1; }
/* ストリームの先頭がmatchだったら読み飛ばす */ int stream_take(stream_t* buff, const char* match, int sensitive) { if (stream_skip(buff) == ERR_FATAL || stream_update(buff) == ERR_FATAL) { return ERR_FATAL; } int tail = buff->tail; while (buff->tail != buff->head && sensitive_eq(buff->buff[buff->tail], *match, sensitive) && *match != '\0') { buff->tail += 1; match += 1; if (buff->tail == BUFF_SIZE) { buff->tail = 0; } } if (*match == '\0') { return 1; } else { buff->tail = tail; return 0; } }
void tms3617_enable_w(int chip, int enable) { struct TMS36XX *tms = tms36xx[chip]; int i, bits = 0; /* duplicate the 6 voice enable bits */ enable = (enable & 0x3f) | ((enable & 0x3f) << 6); if (enable == tms->enable) return; /* update the stream before changing the tune */ stream_update(tms->channel,0); LOG((errorlog, "%s enable voices", tms->subtype)); for (i = 0; i < 6; i++) { if (enable & (1 << i)) { bits += 2; /* each voice has two instances */ #if VERBOSE switch (i) { case 0: LOG((errorlog," 16'")); break; case 1: LOG((errorlog," 8'")); break; case 2: LOG((errorlog," 5 1/3'")); break; case 3: LOG((errorlog," 4'")); break; case 4: LOG((errorlog," 2 2/3'")); break; case 5: LOG((errorlog," 2'")); break; } #endif } } /* set the enable mask and number of active voices */ tms->enable = enable; tms->voices = bits; LOG((errorlog, "%s\n", bits ? "" : " none")); }
void dmadac_transfer(const device_config **devlist, UINT8 num_channels, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, INT16 *data) { int i, j; /* flush out as much data as we can */ for (i = 0; i < num_channels; i++) { dmadac_state *info = get_safe_token(devlist[i]); stream_update(info->channel); } /* loop over all channels and accumulate the data */ for (i = 0; i < num_channels; i++) { dmadac_state *ch = get_safe_token(devlist[i]); if (ch->enabled) { int maxin = (ch->bufout + BUFFER_SIZE - 1) % BUFFER_SIZE; INT16 *src = data + i * channel_spacing; int curin = ch->bufin; /* copy the data */ for (j = 0; j < total_frames && curin != maxin; j++) { ch->buffer[curin++ % BUFFER_SIZE] = *src; src += frame_spacing; } ch->bufin = curin; /* log overruns */ if (j != total_frames) logerror("dmadac_transfer: buffer overrun (short %d frames)\n", total_frames - j); } } //LOG(("dmadac_transfer - %d samples, %d effective, %d in buffer\n", total_frames, (int)(total_frames * (double)DEFAULT_SAMPLE_RATE / dmadac[first_channel].frequency), dmadac[first_channel].curinpos - dmadac[first_channel].curoutpos)); }
/* update request from fm.c */ void YM2203UpdateRequest(void *param) { struct ym2203_info *info = param; stream_update(info->stream,0); }
int tms5110_ready_r(void) { /* bring up to date first */ stream_update(stream, 0); return tms5110_ready_read(); }
/* update request from fm.c */ void YM2151UpdateRequest(int chip) { stream_update(stream[chip],0); }
static void saa1099_write_port_w( int chip, int offset, int data ) { struct SAA1099 *saa = sndti_token(SOUND_SAA1099, chip); int reg = saa->selected_reg; int ch; /* first update the stream to this point in time */ stream_update(saa->stream); switch (reg) { /* channel i amplitude */ case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: ch = reg & 7; saa->channels[ch].amplitude[LEFT] = amplitude_lookup[data & 0x0f]; saa->channels[ch].amplitude[RIGHT] = amplitude_lookup[(data >> 4) & 0x0f]; break; /* channel i frequency */ case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: ch = reg & 7; saa->channels[ch].frequency = data & 0xff; break; /* channel i octave */ case 0x10: case 0x11: case 0x12: ch = (reg - 0x10) << 1; saa->channels[ch + 0].octave = data & 0x07; saa->channels[ch + 1].octave = (data >> 4) & 0x07; break; /* channel i frequency enable */ case 0x14: saa->channels[0].freq_enable = data & 0x01; saa->channels[1].freq_enable = data & 0x02; saa->channels[2].freq_enable = data & 0x04; saa->channels[3].freq_enable = data & 0x08; saa->channels[4].freq_enable = data & 0x10; saa->channels[5].freq_enable = data & 0x20; break; /* channel i noise enable */ case 0x15: saa->channels[0].noise_enable = data & 0x01; saa->channels[1].noise_enable = data & 0x02; saa->channels[2].noise_enable = data & 0x04; saa->channels[3].noise_enable = data & 0x08; saa->channels[4].noise_enable = data & 0x10; saa->channels[5].noise_enable = data & 0x20; break; /* noise generators parameters */ case 0x16: saa->noise_params[0] = data & 0x03; saa->noise_params[1] = (data >> 4) & 0x03; break; /* envelope generators parameters */ case 0x18: case 0x19: ch = reg - 0x18; saa->env_reverse_right[ch] = data & 0x01; saa->env_mode[ch] = (data >> 1) & 0x07; saa->env_bits[ch] = data & 0x10; saa->env_clock[ch] = data & 0x20; saa->env_enable[ch] = data & 0x80; /* reset the envelope */ saa->env_step[ch] = 0; break; /* channels enable & reset generators */ case 0x1c: saa->all_ch_enable = data & 0x01; saa->sync_state = data & 0x02; if (data & 0x02) { int i; /* Synch & Reset generators */ logerror("%04x: (SAA1099 #%d) -reg 0x1c- Chip reset\n",activecpu_get_pc(), chip); for (i = 0; i < 6; i++) { saa->channels[i].level = 0; saa->channels[i].counter = 0.0; } } break; default: /* Error! */ logerror("%04x: (SAA1099 #%d) Unknown operation (reg:%02x, data:%02x)\n",activecpu_get_pc(), chip, reg, data); } }
/* update request from fm.c */ void ym2610_update_request(void *param) { ym2610_state *info = (ym2610_state *)param; stream_update(info->stream); }
void S14001A_reg_0_w(int data) { if (stream != -1) stream_update(stream, 0); WordInput = data; }
void tia_sh_update(void) { stream_update(channel, 0); }
void tms36xx_sh_update(void) { int i; for( i = 0; i < intf->num; i++ ) stream_update(i,0); }
static void _stream_update_3526(void *param, int interval) { struct ym3526_info *info = param; stream_update(info->stream, interval); }
static void _stream_update_8950(void *param, int interval) { struct y8950_info *info = param; stream_update(info->stream); }
void discrete_sh_update(void) { if(!init_ok) return; /* Bring stream upto the present time */ stream_update(discrete_stream, 0); }
void speaker_sh_update(void) { int i; for( i = 0; i < intf->num; i++ ) stream_update(speaker[i].channel, 0); }
void streams_update(running_machine *machine) { streams_private *strdata = machine->streams_data; attotime curtime = timer_get_time(machine); int second_tick = FALSE; sound_stream *stream; VPRINTF(("streams_update\n")); /* see if we ticked over to the next second */ if (curtime.seconds != strdata->last_update.seconds) { assert(curtime.seconds == strdata->last_update.seconds + 1); second_tick = TRUE; } /* iterate over all the streams */ for (stream = strdata->stream_head; stream != NULL; stream = stream->next) { INT32 output_bufindex = stream->output_sampindex - stream->output_base_sampindex; int outputnum; /* make sure this stream is up-to-date */ stream_update(stream); /* if we've ticked over another second, adjust all the counters that are relative to the current second */ if (second_tick) { stream->output_sampindex -= stream->sample_rate; stream->output_base_sampindex -= stream->sample_rate; } /* note our current output sample */ stream->output_update_sampindex = stream->output_sampindex; /* if we don't have enough output buffer space to hold two updates' worth of samples, we need to shuffle things down */ if (stream->output_bufalloc - output_bufindex < 2 * stream->max_samples_per_update) { INT32 samples_to_lose = output_bufindex - stream->max_samples_per_update; if (samples_to_lose > 0) { /* if we have samples to move, do so for each output */ if (output_bufindex > 0) for (outputnum = 0; outputnum < stream->outputs; outputnum++) { stream_output *output = &stream->output[outputnum]; memmove(&output->buffer[0], &output->buffer[samples_to_lose], sizeof(output->buffer[0]) * (output_bufindex - samples_to_lose)); } /* update the base position */ stream->output_base_sampindex += samples_to_lose; } } } /* remember the update time */ strdata->last_update = curtime; /* update sample rates if they have changed */ for (stream = strdata->stream_head; stream != NULL; stream = stream->next) if (stream->new_sample_rate != 0) { UINT32 old_rate = stream->sample_rate; int outputnum; /* update to the new rate and remember the old rate */ stream->sample_rate = stream->new_sample_rate; stream->new_sample_rate = 0; /* recompute all the data */ recompute_sample_rate_data(machine, stream); /* reset our sample indexes to the current time */ stream->output_sampindex = (INT64)stream->output_sampindex * (INT64)stream->sample_rate / old_rate; stream->output_update_sampindex = (INT64)stream->output_update_sampindex * (INT64)stream->sample_rate / old_rate; stream->output_base_sampindex = stream->output_sampindex - stream->max_samples_per_update; /* clear out the buffer */ for (outputnum = 0; outputnum < stream->outputs; outputnum++) memset(stream->output[outputnum].buffer, 0, stream->max_samples_per_update * sizeof(stream->output[outputnum].buffer[0])); } }
/* update request from fm.c */ void YM2612UpdateRequest(int chip) { stream_update(stream[chip],100); }
/* update request from fm.c */ void YM2610UpdateRequest(void *param) { struct ym2610_info *info = param; stream_update(info->stream); }
void sid6581_port_w (SID6581 *This, int offset, int data) { offset &= 0x1f; switch (offset) { case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: break; case 0x15: case 0x16: case 0x17: case 0x18: stream_update(This->mixer_channel); This->reg[offset] = data; This->masterVolume = ( This->reg[0x18] & 15 ); This->masterVolumeAmplIndex = This->masterVolume << 8; if ((This->reg[0x18]&0x80) && ((This->reg[0x17]&This->optr3.filtVoiceMask)==0)) This->optr3_outputmask = 0; /* off */ else This->optr3_outputmask = ~0; /* on */ This->filter.Type = This->reg[0x18] & 0x70; if (This->filter.Type != This->filter.CurType) { This->filter.CurType = This->filter.Type; This->optr1.filtLow = (This->optr1.filtRef = 0); This->optr2.filtLow = (This->optr2.filtRef = 0); This->optr3.filtLow = (This->optr3.filtRef = 0); } if ( This->filter.Enabled ) { This->filter.Value = 0x7ff & ( (This->reg[0x15]&7) | ( (UINT16)This->reg[0x16] << 3 )); if (This->filter.Type == 0x20) This->filter.Dy = bandPassParam ? bandPassParam[This->filter.Value] : 0.0f; else This->filter.Dy = lowPassParam ? lowPassParam[This->filter.Value] : 0.0f; This->filter.ResDy = filterResTable[This->reg[0x17] >> 4] - This->filter.Dy; if ( This->filter.ResDy < 1.0f ) This->filter.ResDy = 1.0f; } sidEmuSet( &This->optr1 ); sidEmuSet( &This->optr3 ); sidEmuSet( &This->optr2 ); // relies on sidEmuSet also for other channels! sidEmuSet2( &This->optr1 ); sidEmuSet2( &This->optr2 ); sidEmuSet2( &This->optr3 ); break; default: stream_update(This->mixer_channel); This->reg[offset] = data; if (offset<7) { This->optr1.reg[offset] = data; } else if (offset<14) { This->optr2.reg[offset-7] = data; } else if (offset<21) { This->optr3.reg[offset-14] = data; } sidEmuSet( &This->optr1 ); sidEmuSet( &This->optr3 ); sidEmuSet( &This->optr2 ); // relies on sidEmuSet also for other channels! sidEmuSet2( &This->optr1 ); sidEmuSet2( &This->optr2 ); sidEmuSet2( &This->optr3 ); break; }
static void _stream_update_3812(void * param, int interval) { struct ym3812_info *info = param; stream_update(info->stream); }
void s14001a_set_volume(device_t *device, int volume) { S14001AChip *chip = get_safe_token(device); stream_update(chip->stream); chip->VSU1000_amp = volume; }