Ejemplo n.º 1
0
        private void BuildVoicePartDone(SequencingSampleProvider source, UPart part, UProject project)
        {
            lock (lockObject)
            {
                trackSources[part.TrackNo].AddSource(
                    source,
                    TimeSpan.FromMilliseconds(project.TickToMillisecond(part.PosTick)));
                pendingParts--;
            }

            if (pendingParts == 0) StartPlayback();
        }
Ejemplo n.º 2
0
        public async Task <List <TrackSampleProvider> > RenderAsync()
        {
            List <TrackSampleProvider> trackSampleProviders = project.Tracks.Select(
                track => new TrackSampleProvider()
            {
                Volume = PlaybackManager.DecibelToVolume(track.Volume)
            }).ToList();
            var cacheDir = PathManager.Inst.GetCachePath(project.FilePath);

            foreach (UPart part in project.Parts)
            {
                UVoicePart voicePart = part as UVoicePart;
                if (voicePart != null)
                {
                    SequencingSampleProvider sampleProvider = await RenderPartAsync(voicePart, project, cacheDir);

                    if (sampleProvider != null)
                    {
                        trackSampleProviders[voicePart.TrackNo].AddSource(
                            sampleProvider,
                            TimeSpan.FromMilliseconds(project.TickToMillisecond(voicePart.PosTick)));
                    }
                }
                UWavePart wavePart = part as UWavePart;
                if (wavePart != null)
                {
                    try {
                        var stream = new AudioFileReader(wavePart.FilePath);
                        trackSampleProviders[wavePart.TrackNo].AddSource(
                            new WaveToSampleProvider(stream),
                            TimeSpan.FromMilliseconds(project.TickToMillisecond(wavePart.PosTick)));
                    } catch (Exception e) {
                        Log.Error(e, "Failed to open audio file");
                    }
                }
            }
            return(trackSampleProviders);
        }