예제 #1
0
        private void SetHandView()
        {
            SourceConverter converter = new SourceConverter();
            ImageButtonList = new List<ImageButton>();

            MyGrid.Children.Clear();
            MyGrid.ColumnDefinitions.Clear();


            for (int i = 0; i < Hand.Count; i++)
            {
                ImageButton temp = new ImageButton();

                MyGrid.ColumnSpacing = -30;

                temp.Source = temp.Source = "card0068.png";
                temp.BackgroundColor = Color.Transparent;

                ImageButtonList.Add(temp);

                MyGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                MyGrid.Children.Add(temp, i, 0);

                MyGrid.Children[i].HorizontalOptions = LayoutOptions.FillAndExpand;

                MyGrid.Children[i].HeightRequest = MyGrid.Height;

                MyGrid.Children[i].WidthRequest = MyGrid.Children[i].Height / 1.9;
            }
        }
예제 #2
0
        private async Task <SourceStatus> IndexSource(IStorageFeed feed, PackageName packageName, ISourceInfo sourceInfo)
        {
            var sourceStatus = new SourceStatus(new SourceName(Path.GetFileName(sourceInfo.OriginalPath), sourceInfo.Hash));

            try
            {
                Debug.WriteLine("Indexing source {0}", sourceStatus.SourceName);
                await RequestOrSkip(string.Format("src/{0}", sourceStatus.SourceName),
                                    async() =>
                {
                    using (var stream = sourceInfo.File.GetStream())
                        using (var convertedStream = SourceConverter.Convert(stream))
                            await feed.GetSource(packageName, sourceStatus.SourceName).Put(convertedStream);
                });

                sourceStatus.Stored = true;
                Debug.WriteLine("Stored source {0}", sourceStatus.SourceName);
            }
            catch (Exception e)
            {
                support.TrackException(e, new { packageName });
                sourceStatus.Exception = new ExceptionStatus(e);
            }

            return(sourceStatus);
        }
        async void CreateAudioGraphAsync()
        {
            var graphResult = await AudioGraph.CreateAsync(new AudioGraphSettings(Windows.Media.Render.AudioRenderCategory.Media));

            if (graphResult.Status != AudioGraphCreationStatus.Success)
            {
                throw new InvalidOperationException($"Graph creation failed {graphResult.Status}");
            }
            _graph = graphResult.Graph;
            var inputNodeResult = await _graph.CreateDeviceInputNodeAsync(Windows.Media.Capture.MediaCategory.Media);

            if (inputNodeResult.Status != AudioDeviceNodeCreationStatus.Success)
            {
                throw new InvalidOperationException($"Input node creation failed {inputNodeResult.Status}");
            }

            _inputNode = inputNodeResult.DeviceInputNode;

            _source                     = AudioVisualizer.PlaybackSource.CreateFromAudioNode(_inputNode);
            _converter                  = new SourceConverter();
            _converter.Source           = _source.Source;
            _converter.MinFrequency     = 110.0f;     // Note A2
            _converter.MaxFrequency     = 3520.0f;    // Note A7
            _converter.FrequencyCount   = 12 * 5 * 5; // 5 octaves, 5 bars per note
            _converter.FrequencyScale   = ScaleType.Logarithmic;
            _converter.SpectrumRiseTime = TimeSpan.FromMilliseconds(20);
            _converter.SpectrumFallTime = TimeSpan.FromMilliseconds(200);
            _converter.RmsRiseTime      = TimeSpan.FromMilliseconds(20); // Use RMS to gate noise, fast rise slow fall
            _converter.RmsFallTime      = TimeSpan.FromMilliseconds(500);
            _converter.ChannelCount     = 1;
            notesSpectrum.Source        = _converter;

            _graph.Start();
        }
예제 #4
0
 private void TestFromMemory(byte[] originalData, byte[] convertedExpected)
 {
     using (var originalStream = new MemoryStream(originalData))
         using (var convertedStream = SourceConverter.Convert(originalStream))
         {
             var convertedData = GetData(convertedStream);
             Compare(convertedData, convertedExpected);
         }
 }
        public MediaPlayerPage()
        {
            this.InitializeComponent();
            _player              = new MediaPlayer();
            _player.MediaOpened += Player_MediaOpened;
            _player.PlaybackSession.PositionChanged += Player_PositionChanged;
            _playbackSource = PlaybackSource.CreateFromMediaPlayer(_player);
            _playbackSource.SourceChanged += PlaybackSource_Changed;
            _source                          = (SourceConverter)Resources["source"];
            _analogSource                    = (SourceConverter)Resources["analogSource"];
            _spectrumSource                  = (SourceConverter)Resources["spectrumSource"];
            _source.RmsRiseTime              = TimeSpan.FromMilliseconds(50);
            _source.RmsFallTime              = TimeSpan.FromMilliseconds(50);
            _source.PeakRiseTime             = TimeSpan.FromMilliseconds(50);
            _source.PeakFallTime             = TimeSpan.FromMilliseconds(1000);
            _analogSource.RmsRiseTime        = TimeSpan.FromMilliseconds(500);
            _analogSource.RmsFallTime        = TimeSpan.FromMilliseconds(500);
            _analogSource.AnalyzerTypes      = AnalyzerType.RMS;
            _spectrumSource.SpectrumRiseTime = TimeSpan.FromMilliseconds(100);
            _spectrumSource.SpectrumFallTime = TimeSpan.FromMilliseconds(200);
            _spectrumSource.FrequencyCount   = 50;
            _spectrumSource.MinFrequency     = 20.0f;
            _spectrumSource.MaxFrequency     = 20000.0f;
            _spectrumSource.FrequencyScale   = ScaleType.Logarithmic;
            _spectrumSource.AnalyzerTypes    = AnalyzerType.Spectrum;

            // Create bar steps with 1db steps from -86db to +6
            const int fromDb = -86;
            const int toDb   = 6;

            MeterBarLevel[] levels    = new MeterBarLevel[toDb - fromDb];
            Color           fromColor = Colors.Yellow;
            Color           toColor   = Colors.Red;
            float           redStep   = (float)toColor.R - (float)fromColor.R;
            float           greenStep = (float)toColor.G - (float)fromColor.G;
            float           blueStep  = (float)toColor.B - (float)fromColor.B;

            for (int i = 0; i < levels.Count(); i++)
            {
                float ratio = (float)i / (float)levels.Count();
                levels[i].Color = Color.FromArgb(255, (byte)((redStep * ratio) + fromColor.R), (byte)((greenStep * ratio) + fromColor.G), (byte)((blueStep * ratio) + fromColor.B));
                levels[i].Level = i + fromDb;
            }
            bar0.Levels = levels;
            bar1.Levels = levels;
            barspectrum.ElementFactory          = this;
            barspectrum.ElementShadowBlurRadius = 5;
            barspectrum.ElementShadowOffset     = new Vector3(2, 2, -10);
            barspectrum.ElementShadowColor      = Colors.LightGreen;
        }
        public void TestInitialize()
        {
            sut               = new SourceConverter();
            testSource        = new FakeVisualizationSource();
            sut.Source        = testSource;
            propertiesChanged = new List <string>();

            sut.ConfigurationChanged += new TypedEventHandler <IVisualizationSource, string>(
                (sender, property) =>
            {
                propertiesChanged.Add(property);
            }
                );
        }
예제 #7
0
 private void TestFromFile(string name, byte[] originalExpected, byte[] convertedExpected)
 {
     using (var originalStream = GetStream(name))
     {
         var originalData = GetData(originalStream);
         originalStream.Position = 0;
         using (var convertedStream = SourceConverter.Convert(originalStream))
         {
             var convertedData = GetData(convertedStream);
             Compare(originalData, originalExpected);
             Compare(convertedData, convertedExpected);
         }
     }
 }
        public void TestInit()
        {
            sut        = new SourceConverter();
            testSource = new FakeVisualizationSource();
            testSource.ExpectedChannels = expectedChannelCount;
            sut.Source = testSource;

            testFrame = new VisualizationDataFrame(
                TimeSpan.Zero,
                TimeSpan.FromMilliseconds(16.7),
                ScalarData.CreateEmpty(expectedChannelCount),
                ScalarData.CreateEmpty(expectedChannelCount),
                SpectrumData.CreateEmpty(expectedChannelCount, 10, ScaleType.Linear, ScaleType.Linear, 0, 10000));


            testSource.Frame = testFrame;
        }
예제 #9
0
        public override void BuildRenderTree(RenderTreeBuilder builder, object?value)
        {
            object?result = Source;

            if (_sourceBinding.HasValue)
            {
                ReflectionHelper.TryGetPropertyValue(value, _sourceBinding, out result);
            }

            if (SourceConverter != null)
            {
                result = SourceConverter.ConvertTypeSafe <string>(result);
            }

            builder.OpenComponent(0, typeof(LxIcon));
            builder.AddAttribute(1, "Size", Size);
            builder.AddAttribute(2, "Source", result?.ToString());
            builder.CloseComponent();
        }
        public void TestInit()
        {
            sut        = new SourceConverter();
            testSource = new FakeVisualizationSource();
            sut.Source = testSource;

            testFrame = new VisualizationDataFrame(
                expectedTime,
                expectedDuration,
                ScalarData.CreateEmpty(expectedChannelCount),
                ScalarData.CreateEmpty(expectedChannelCount),
                SpectrumData.CreateEmpty(expectedChannelCount, expectedFrequencyCount, ScaleType.Linear, ScaleType.Linear, expectedMinFrequency, expectedMaxFrequency)
                );
            otherFrame = new VisualizationDataFrame(
                expectedTime.Add(expectedDuration),
                expectedDuration,
                ScalarData.CreateEmpty(expectedChannelCount),
                ScalarData.CreateEmpty(expectedChannelCount),
                SpectrumData.CreateEmpty(expectedChannelCount, expectedFrequencyCount, ScaleType.Linear, ScaleType.Linear, expectedMinFrequency, expectedMaxFrequency)
                );

            testSource.Frame = testFrame;
        }
        private void CreateJob(PackageProject metadata, byte[] data)
        {
            string directory = Path.Combine(metadata.Name, metadata.Version.Name);

            Directory.CreateDirectory(Path.Combine(configuration.DataPath, directory));

            string file = Path.Combine(configuration.DataPath, directory, metadata.Name + ".symbols.zip");

            File.WriteAllBytes(file, data);

            using (var zipMemoryStream = new MemoryStream(data))
                using (var zipfile = ZipFile.Read(zipMemoryStream))
                {
                    var zipInfo = new TransformingWrapperPackageFile(new ZipPackageFile(zipfile), new UrlTransformation());
                    var addInfo = addInfoBuilder.Build(zipInfo);

                    string binariesDirectory = Path.Combine(directory, "Binaries");
                    Directory.CreateDirectory(Path.Combine(configuration.DataPath, binariesDirectory));
                    string sourcesDirectory = Path.Combine(directory, "Sources");
                    Directory.CreateDirectory(Path.Combine(configuration.DataPath, sourcesDirectory));

                    foreach (var binaryInfo in addInfo.Binaries)
                    {
                        if (binaryInfo.SymbolInfo == null)
                        {
                            continue;
                        }

                        string binaryDirectory = Path.Combine(binariesDirectory, binaryInfo.Name, binaryInfo.SymbolHash);
                        Directory.CreateDirectory(Path.Combine(configuration.DataPath, binaryDirectory));

                        using (var binaryInfoStream = binaryInfo.File.Stream)
                            using (var binaryStream = File.OpenWrite(Path.Combine(configuration.DataPath, binaryDirectory, binaryInfo.Name + "." + binaryInfo.Type)))
                                binaryInfoStream.CopyTo(binaryStream);

                        using (var symbolInfoStream = binaryInfo.SymbolInfo.File.Stream)
                            using (var symbolStream = File.OpenWrite(Path.Combine(configuration.DataPath, binaryDirectory, binaryInfo.Name + "." + binaryInfo.SymbolInfo.Type)))
                                symbolInfoStream.CopyTo(symbolStream);

                        string indexDirectory = Path.Combine(configuration.IndexPath, binaryInfo.Name);
                        Directory.CreateDirectory(indexDirectory);

                        File.AppendAllText(Path.Combine(indexDirectory, binaryInfo.SymbolHash + ".txt"), binaryDirectory + Environment.NewLine);

                        var sourceIndex = new List <string>();

                        foreach (var sourceInfo in binaryInfo.SymbolInfo.SourceInfos.Where(info => info.ActualPath != null))
                        {
                            string sourcePath = Path.Combine(sourcesDirectory, sourceInfo.KeyPath);
                            Directory.CreateDirectory(Path.Combine(configuration.DataPath, Path.GetDirectoryName(sourcePath)));

                            sourceIndex.Add(sourceInfo.OriginalPath + "|" + sourceInfo.KeyPath);

                            using (var sourceInfoStream = sourceInfo.ActualPath.Stream)
                                using (var convertedStream = SourceConverter.Convert(sourceInfoStream))
                                    using (var sourceStream = File.OpenWrite(Path.Combine(configuration.DataPath, sourcePath)))
                                        convertedStream.CopyTo(sourceStream);

                            File.WriteAllLines(Path.Combine(configuration.DataPath, binaryDirectory, binaryInfo.Name + ".txt"), sourceIndex);
                        }
                    }
                }

            File.Delete(file);
        }
 public void TestInit()
 {
     sut = new SourceConverter();
 }