Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
File: audit.cs Progetto: kwanboy/mcs
        //-------------------------------------------------
        //  audit_samples - validate the samples for the
        //  currently-enumerated driver
        //-------------------------------------------------
        public summary audit_samples()
        {
            // start fresh
            m_record_list.clear();

            int required = 0;
            int found    = 0;

            // iterate over sample entries
            foreach (samples_device device in new samples_device_iterator(m_enumerator.config().root_device()))
            {
                // by default we just search using the driver name
                string searchpath = m_enumerator.driver().name;

                // add the alternate path if present
                samples_iterator samplesiter = new samples_iterator(device);
                if (samplesiter.altbasename() != null)
                {
                    searchpath += ";" + samplesiter.altbasename();
                }

                // iterate over samples in this entry
                for (string samplename = samplesiter.first(); samplename != null; samplename = samplesiter.next())
                {
                    required++;

                    // create a new record
                    audit_record record = m_record_list.emplace_back(new audit_record(samplename, audit_record.media_type.MEDIA_SAMPLE)).Value;  //audit_record &record = *m_record_list.emplace(m_record_list.end(), samplename, media_type::SAMPLE);

                    // look for the files
                    emu_file      file = new emu_file(m_enumerator.options().sample_path(), osdcore_global.OPEN_FLAG_READ | osdcore_global.OPEN_FLAG_NO_PRELOAD);
                    path_iterator path = new path_iterator(searchpath);
                    string        curpath;
                    while (path.next(out curpath, samplename))
                    {
                        // attempt to access the file (.flac) or (.wav)
                        osd_file.error filerr = file.open(curpath, ".flac");
                        if (filerr != osd_file.error.NONE)
                        {
                            filerr = file.open(curpath, ".wav");
                        }

                        if (filerr == osd_file.error.NONE)
                        {
                            record.set_status(audit_record.audit_status.STATUS_GOOD, audit_record.audit_substatus.SUBSTATUS_GOOD);
                            found++;
                        }
                        else
                        {
                            record.set_status(audit_record.audit_status.STATUS_NOT_FOUND, audit_record.audit_substatus.SUBSTATUS_NOT_FOUND);
                        }
                    }

                    file.close();
                }
            }

            if (found == 0 && required > 0)
            {
                m_record_list.clear();
                return(summary.NOTFOUND);
            }

            // return a summary
            string unused = "";

            return(summarize(m_enumerator.driver().name, ref unused));
        }