Exemple #1
0
        public MainWindow()
        {
            _inputFile = new WavFile($"../../../../Samples/{InputSample}");

            InitializeComponent();

            _soundMesh = new SoundMesh(MeshRows, MeshCols, 6);

            _speaker = new Speaker(new FrequencyGenerator(220), _soundMesh, 1);
            //_speaker = new Speaker(new WavGenerator(_inputFile), _soundMesh, 1);

            _soundMesh.AddSpeaker(_speaker);

            _microphone = new Microphone(_soundMesh, MeshRows / 2, MeshCols / 4);
            _soundMesh.AddMicrophone(_microphone);

            _imageBitmap = new Bitmap(ScreenWidth, ScreenHeight, PixelFormat.Format32bppArgb);
            _backBuffer  = new WriteableBitmap(ScreenWidth, ScreenHeight, 96, 96, PixelFormats.Bgra32, null);

            BackBuffer.Source = _backBuffer;

            _isActive     = true;
            _updateThread = new Thread(GameLoop);
            _updateThread.Start();
        }
Exemple #2
0
        public Microphone(SoundMesh soundMesh, int row, int col)
        {
            _listeningNode = soundMesh.GetNode(row, col);

            _initialNodePosition = new Vector2(_listeningNode.Position.X, _listeningNode.Position.Y);

            _amplitudes = new List <double>();

            _brush = new SolidBrush(Color.Blue);
        }
Exemple #3
0
        public Speaker(ISoundGenerator generator, SoundMesh mesh, int meshColumn)
        {
            _generator = generator;

            _nodes = mesh.GetColumn(meshColumn);

            _initialNodePositions = new List <Vector2>();

            foreach (MeshNode node in _nodes)
            {
                _initialNodePositions.Add(new Vector2(node.Position.X, node.Position.Y));
            }

            _brush = new SolidBrush(Color.Green);
        }