Exemplo n.º 1
0
        public IInstrument GetInstrument()
        {
            string name = Settings[Prefix + "instrument"];

            string level = InstrumentTuningLevel;

            if (null != _cachedInstrument)
            {
                if (_cachedInstrument.Name == name && _cachedInstrument.Level == level)
                {
                    return(_cachedInstrument);
                }
                _cachedInstrument = null;
                _cachedTuning     = null;
            }

            InstrumentSet instruments = _configFile.Instruments;

            while (null != instruments)
            {
                if (instruments.Level == level)
                {
                    Instrument i;
                    if (instruments.TryGet(name, out i))
                    {
                        _cachedInstrument = i;
                        break;
                    }
                }

                instruments = instruments.Parent;
            }

            return(_cachedInstrument);
        }
Exemplo n.º 2
0
        internal InstrumentSet(InstrumentSet parent, string level) : this(level)
        {
            if (null == parent)
            {
                throw new ArgumentNullException("parent");
            }

            Parent = parent;
        }
Exemplo n.º 3
0
        public ConfigFile(string level)
        {
            Level = level;

            ChordiousSettings = new ChordiousSettings(level);
            DiagramStyle      = new DiagramStyle(level);
            Instruments       = new InstrumentSet(level);
            ChordQualities    = new ChordQualitySet(level);
            Scales            = new ScaleSet(level);
            DiagramLibrary    = new DiagramLibrary(DiagramStyle);
        }
Exemplo n.º 4
0
        public void CopyFrom(InstrumentSet instrumentSet)
        {
            if (null == instrumentSet)
            {
                throw new ArgumentNullException(nameof(instrumentSet));
            }

            foreach (Instrument sourceInstrument in instrumentSet)
            {
                if (!TryGet(sourceInstrument.Name, out Instrument instrument))
                {
                    instrument = Add(sourceInstrument.Name, sourceInstrument.NumStrings);
                }

                if (sourceInstrument.NumStrings == instrument.NumStrings)
                {
                    instrument.Tunings.CopyFrom(sourceInstrument.Tunings);
                }
            }
        }
Exemplo n.º 5
0
 public InstrumentNameAlreadyExistsException(InstrumentSet instrumentSet, string name) : base(instrumentSet, name)
 {
 }
Exemplo n.º 6
0
 public InstrumentNotFoundException(InstrumentSet instrumentSet, string name) : base(instrumentSet, name)
 {
 }
Exemplo n.º 7
0
 public TargetInstrumentException(InstrumentSet instrumentSet, string name) : base(instrumentSet)
 {
     Name = name;
 }
Exemplo n.º 8
0
 public InstrumentSetException(InstrumentSet instrumentSet) : base()
 {
     InstrumentSet = instrumentSet;
 }
Exemplo n.º 9
0
 internal InstrumentSet(InstrumentSet parent, string level) : this(level)
 {
     Parent = parent ?? throw new ArgumentNullException(nameof(parent));
 }
Exemplo n.º 10
0
 internal Instrument(InstrumentSet parent, XmlReader xmlReader) : this(parent)
 {
     Read(xmlReader);
 }
Exemplo n.º 11
0
 internal Instrument(InstrumentSet parent, string name, int numStrings) : this(parent)
 {
     Name       = name;
     NumStrings = numStrings;
 }
Exemplo n.º 12
0
 private Instrument(InstrumentSet parent)
 {
     ReadOnly = false;
     _tunings = new TuningSet(this);
     Parent   = parent;
 }