Exemple #1
0
        //-------------------------------------------------
        //  load_samples - load all the samples in our
        //  attached interface
        //  Returns true when all samples were successfully read, else false
        //-------------------------------------------------
        bool load_samples()
        {
            bool ok = true;

            // if the user doesn't want to use samples, bail
            if (!machine().options().samples())
            {
                return(false);
            }

            // iterate over ourself
            string           basename    = machine().basename();
            samples_iterator iter        = new samples_iterator(this);
            string           altbasename = iter.altbasename();

            // pre-size the array
            m_sample.resize((size_t)iter.count());

            // load the samples
            int index = 0;

            for (string samplename = iter.first(); samplename != null; index++, samplename = iter.next())
            {
                // attempt to open as FLAC first
                emu_file            file   = new emu_file(machine().options().sample_path(), OPEN_FLAG_READ);
                std.error_condition filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.flac", basename, samplename));
                if (filerr && !string.IsNullOrEmpty(altbasename))
                {
                    filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.flac", altbasename, samplename));
                }

                // if not, try as WAV
                if (filerr)
                {
                    filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.wav", basename, samplename));
                }

                if (filerr && !string.IsNullOrEmpty(altbasename))
                {
                    filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.wav", altbasename, samplename));
                }

                // if opened, read it
                if (!filerr)
                {
                    read_sample(file, m_sample[index]);
                }
                else
                {
                    logerror("Error opening sample '{0}' ({1}:{2} {3})\n", samplename, filerr.category().name(), filerr.value(), filerr.message());
                    ok = false;
                }

                file.close();
            }

            return(ok);
        }
Exemple #2
0
        //-------------------------------------------------
        //  load_samples - load all the samples in our
        //  attached interface
        //  Returns true when all samples were successfully read, else false
        //-------------------------------------------------
        bool load_samples()
        {
            bool ok = true;

            // if the user doesn't want to use samples, bail
            if (!machine().options().samples())
            {
                return(false);
            }

            // iterate over ourself
            string           basename    = machine().basename();
            samples_iterator iter        = new samples_iterator(this);
            string           altbasename = iter.altbasename();

            // pre-size the array
            m_sample.resize(iter.count());

            // load the samples
            int index = 0;

            for (string samplename = iter.first(); samplename != null; index++, samplename = iter.next())
            {
                // attempt to open as FLAC first
                emu_file       file   = new emu_file(machine().options().sample_path(), OPEN_FLAG_READ);
                osd_file.error filerr = file.open(basename, PATH_SEPARATOR, samplename, ".flac");
                if (filerr != osd_file.error.NONE && altbasename != null)
                {
                    filerr = file.open(altbasename, PATH_SEPARATOR, samplename, ".flac");
                }

                // if not, try as WAV
                if (filerr != osd_file.error.NONE)
                {
                    filerr = file.open(basename, PATH_SEPARATOR, samplename, ".wav");
                }
                if (filerr != osd_file.error.NONE && altbasename != null)
                {
                    filerr = file.open(altbasename, PATH_SEPARATOR, samplename, ".wav");
                }

                // if opened, read it
                if (filerr == osd_file.error.NONE)
                {
                    read_sample(file, m_sample[index]);
                }
                else if (filerr == osd_file.error.NOT_FOUND)
                {
                    logerror("{0}: Sample '{1}' NOT FOUND\n", tag(), samplename);
                    ok = false;
                }

                file.close();
            }

            return(ok);
        }