示例#1
0
 public AlbumStore(
     [FromServices] Dbc dbc,
     [FromServices] Library library,
     [FromServices] TrackStore trackStore
     ) : base(dbc)
 {
     this._library    = library;
     this._trackStore = trackStore;
 }
示例#2
0
        protected override void Dispose(bool disposing)
        {
            if (!this.IsDisposed && disposing)
            {
                this._library = null;
                this._trackStore.Dispose();
                this._trackStore = null;
            }

            base.Dispose(disposing);
        }
示例#3
0
        /// <summary>
        /// Obtains the <see cref="TrackStore"/> corresponding to a given resource store.
        /// Returns the global <see cref="TrackStore"/> if no resource store is passed.
        /// </summary>
        /// <param name="store">The <see cref="IResourceStore{T}"/> of which to retrieve the <see cref="TrackStore"/>.</param>
        public ITrackStore GetTrackStore(IResourceStore <byte[]> store = null)
        {
            if (store == null)
            {
                return(globalTrackStore.Value);
            }

            TrackStore tm = new TrackStore(store);

            globalTrackStore.Value.AddItem(tm);
            return(tm);
        }
示例#4
0
        /// <summary>
        /// Obtains the <see cref="TrackStore"/> corresponding to a given resource store.
        /// Returns the global <see cref="TrackStore"/> if no resource store is passed.
        /// </summary>
        /// <param name="store">The <see cref="IResourceStore{T}"/> of which to retrieve the <see cref="TrackStore"/>.</param>
        /// <param name="mixer">The <see cref="AudioMixer"/> to use for tracks created by this store. Defaults to the global <see cref="TrackMixer"/>.</param>
        public ITrackStore GetTrackStore(IResourceStore <byte[]> store = null, AudioMixer mixer = null)
        {
            if (store == null)
            {
                return(globalTrackStore.Value);
            }

            TrackStore tm = new TrackStore(store, mixer ?? TrackMixer);

            globalTrackStore.Value.AddItem(tm);
            return(tm);
        }
示例#5
0
 public AlbumTracksStore(
     [FromServices] Dbc dbc,
     [FromServices] Library library,
     [FromServices] Playback playback,
     [FromServices] TrackStore trackStore,
     [FromServices] AlbumStore albumStore
     ) : base(dbc)
 {
     this._library    = library;
     this._playback   = playback;
     this._trackStore = trackStore;
     this._albumStore = albumStore;
 }
示例#6
0
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            thread = audioThread;

            thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore, TrackMixer);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore, SampleMixer);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            AddItem(TrackMixer  = createAudioMixer(null, nameof(TrackMixer)));
            AddItem(SampleMixer = createAudioMixer(null, nameof(SampleMixer)));

            CancellationToken token = cancelSource.Token;

            scheduler.Add(() =>
            {
                // sync audioDevices every 1000ms
                new Thread(() =>
                {
                    while (!token.IsCancellationRequested)
                    {
                        try
                        {
                            syncAudioDevices();
                            Thread.Sleep(1000);
                        }
                        catch
                        {
                        }
                    }
                })
                {
                    IsBackground = true
                }.Start();
            });
        }
示例#7
0
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            Thread = audioThread;

            Thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            // check for device validity every 100ms
            scheduler.AddDelayed(() =>
            {
                try
                {
                    if (!IsCurrentDeviceValid())
                    {
                        setAudioDevice();
                    }
                }
                catch
                {
                }
            }, 100, true);

            // enumerate new list of devices every second
            scheduler.AddDelayed(() =>
            {
                try
                {
                    setAudioDevice(AudioDevice.Value);
                }
                catch
                {
                }
            }, 1000, true);
        }
示例#8
0
        /// <summary>
        /// Obtains the <see cref="TrackStore"/> corresponding to a given resource store.
        /// Returns the global <see cref="TrackStore"/> if no resource store is passed.
        /// </summary>
        /// <param name="store">The <see cref="IResourceStore{T}"/> of which to retrieve the <see cref="TrackStore"/>.</param>
        public IAdjustableResourceStore <Track.Track> GetTrackStore(IResourceStore <byte[]> store = null)
        {
            if (store == null)
            {
                return(globalTrackManager.Value);
            }

            TrackStore tm = new TrackStore(store);

            AddItem(tm);
            tm.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);

            return(tm);
        }
        public BassTestComponents(bool init = true)
        {
            if (init)
            {
                Init();
            }

            Mixer = CreateMixer();

            Resources   = new DllResourceStore(typeof(TrackBassTest).Assembly);
            TrackStore  = new TrackStore(Resources, Mixer);
            SampleStore = new SampleStore(Resources, Mixer);

            Add(TrackStore, SampleStore);
        }
示例#10
0
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            Thread = audioThread;

            Thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            trackStore.AddExtension(@"mp3");

            sampleStore.AddExtension(@"wav");
            sampleStore.AddExtension(@"mp3");

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            scheduler.Add(() =>
            {
                try
                {
                    setAudioDevice();
                }
                catch
                {
                }
            });

            scheduler.AddDelayed(delegate
            {
                updateAvailableAudioDevices();
                checkAudioDeviceChanged();
            }, 1000, true);
        }
示例#11
0
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            Thread = audioThread;

            Thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            // sync audioDevices every 200ms
            CancellationToken token = cancellationTokenSource.Token;

            Task.Factory.StartNew(() =>
            {
                while (!token.IsCancellationRequested)
                {
                    try
                    {
                        var task = Task.Delay(200, token);
                        syncAudioDevices();
                        task.Wait(token);
                    }
                    catch
                    {
                    }
                }
            }, token, TaskCreationOptions.None, TaskScheduler.Default);
        }