@Override
    public int start(MachineSound msound) {
        NESinterface intf = (NESinterface) msound.sound_interface;
        int i;

        /* Initialize global variables */
        samps_per_sync = (char) (Machine.sample_rate / Machine.drv.frames_per_second);
        buffer_size = samps_per_sync;
        real_rate = (char) (samps_per_sync * Machine.drv.frames_per_second);
        chip_max = intf.num;
        apu_incsize = (float) (N2A03_DEFAULTCLOCK / (float) real_rate);

        /* Use initializer calls */
        create_noise(noise_lut, 13, NOISE_LONG);
        create_vbltimes(vbl_times, vbl_length, samps_per_sync);
        create_syncs(samps_per_sync);

        /* Adjust buffer size if 16 bits */
        buffer_size += samps_per_sync;

        /* Initialize individual chips */
        for (i = 0; i < chip_max; i++) {
            APU[i] = new apu_t();

            //memset(cur,0,sizeof(apu_t));

            /* Check for buffer allocation failure and bail out if necessary */
            /*if ((cur.buffer = malloc(buffer_size))==NULL)
             {
             while (--i >= 0) free(APU[i].buffer);
             return 1;
             }*/
            APU[i].buffer = new byte[buffer_size];
            (APU[i].dpcm).cpu_mem = memory_region(intf.region[i]);
        }

        channel = mixer_allocate_channels(chip_max, intf.volume);
        for (i = 0; i < chip_max; i++) {
            //char name[40];

            name = sprintf("%s #%d", sound_name(msound), i);
            mixer_set_name(channel, name);
        }

        return 0;
    }