Exemplo n.º 1
0
        public SampleChannel Get(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            lock (sampleCache)
            {
                SampleChannel channel = null;
                if (!sampleCache.TryGetValue(name, out Sample sample))
                {
                    byte[] data = store.Get(name);
                    if (data != null)
                    {
                        sample = sampleCache[name] = new SampleBass(data, PendingActions, PlaybackConcurrency);
                    }
                }

                if (sample != null)
                {
                    channel = new SampleChannelBass(sample, AddItemToList);
                    RegisterItem(channel);
                }

                return(channel);
            }
        }
        public SampleChannelBass(SampleBass sample)
        {
            this.sample = sample;

            relativeFrequencyHandler = new BassRelativeFrequencyHandler
            {
                FrequencyChangedToZero   = stopChannel,
                FrequencyChangedFromZero = () =>
                {
                    // Only unpause if the channel has been played by the user.
                    if (userRequestedPlay)
                    {
                        playChannel();
                    }
                },
            };

            ensureChannel();
        }
Exemplo n.º 3
0
        public SampleChannel Get(string name)
        {
            lock (sampleCache)
            {
                Sample        sample;
                SampleChannel channel = null;
                if (!sampleCache.TryGetValue(name, out sample))
                {
                    byte[] data = store.Get(name);
                    if (data != null)
                    {
                        sample = sampleCache[name] = new SampleBass(data, PendingActions);
                    }
                }

                if (sample != null)
                {
                    channel = new SampleChannelBass(sample, AddItemToList);
                    RegisterItem(channel);
                }

                return(channel);
            }
        }