Beispiel #1
0
        private void ParseFromV1(XAudio2 xaudio, WaveFormat waveFormat, IVoicePool voicePool, string jsonData)
        {
            var project = (ProjectDtoV1)JsonConvert.DeserializeObject(jsonData, typeof(ProjectDtoV1));

            Tracks = project.SampleTracks.ToList()
                     .Select(v1 =>
            {
                var samplePlayer =
                    new SamplePlayer();

                var buildSamplePlayer = Task.Run(async() => await samplePlayer.WithInput(StorageFileLocator.FromDto(v1.File))
                                                 .WithXAudio(xaudio)
                                                 .WithWaveFormat(waveFormat)
                                                 .WithVoicePool(voicePool)
                                                 .WithPitch(v1.Pitch)
                                                 .WithChannelPan(v1.Pan)
                                                 .WithChannelVolume(v1.Volume)
                                                 .BuildAsync()).Result;

                var newTrack = new Track(buildSamplePlayer);
                newTrack.PlayWithTicks(v1.PlayAt);
                return(newTrack);
            })
                     .ToList();

            MasterTrackPan               = project.MasterTrack.Pan;
            MasterTrackPitch             = project.MasterTrack.Pitch;
            MasterTrackVolume            = project.MasterTrack.Volume;
            MasterTrackTransportPosition = project.MasterTrack.TransportPosition;
            MasterTrackPlaying           = project.MasterTrack.Playing;
            MasterTrackBpm               = project.MasterTrack.BPM;
        }
        public TrackStepViewModel AddTrack(SamplePlayer samplePlayer)
        {
            var track = new Track(samplePlayer);

            Tracks.Add(track);

            var trackVm = new TrackStepViewModel(track);

            try
            {
                if (CurrentTrackViewModel != null)
                {
                    var index = TrackViewModels.IndexOf(CurrentTrackViewModel);

                    if (index != -1)
                    {
                        TrackViewModels.Insert(index + 1, trackVm);
                        return(trackVm);
                    }
                }
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            TrackViewModels.Add(trackVm);
            return(trackVm);
        }
Beispiel #3
0
        /// <summary>
        /// Starts synthesizing the current note.
        /// </summary>
        /// <param name="noteNo">The midi note number.</param>
        public void ProcessNoteOnEvent(byte noteNo)
        {
            _synthBuffer = new StereoBuffer(noteNo);
            if (_player == null)
            {
                _player = new SamplePlayer(_synthBuffer);
                _player.Synthesize();
                _player.isOn = true;
            }
            else
            {
                if (_player.isOn == true)
                {
                    if (_player.SynthBuffer.NoteNo != noteNo)
                    {

                        _player.attackTime = 44100 / 20;
                        _player.SynthBuffer = _synthBuffer;
                        //_player = new SamplePlayer(_synthBuffer);
                        _player.Synthesize();
                    }
                }
                else
                {
                    _player.attackTime = 44100 / 5;
                    _player.SynthBuffer = _synthBuffer;
                    _player.Synthesize();
                    _player.isOn = true;
                }
            }
        }
Beispiel #4
0
 void Start()
 {
     SamplesRight = new float[64];
     SamplesLeft  = new float[64];
     Samples      = new float[64];
     player       = GetComponent <SamplePlayer> ();
 }
Beispiel #5
0
 public override void handleServerTriggerStay(Collider other)
 {
     if (other.gameObject.layer == 6)
     {
         SamplePlayer player = other.gameObject.GetComponent <SamplePlayer>();
         player.health = Mathf.Clamp(player.health - Time.deltaTime * 8f, 0, player.maxHealth);
     }
 }
Beispiel #6
0
 // constructor on making a new team
 public SampleTeam(int numPlayers)
 {
     // fill up the roster with players
     for (int i = 0; i < numPlayers; i++)
     {
         // make each player
         roster[i] = new SamplePlayer(i);
     }
 }
Beispiel #7
0
 public override void handleServerTriggerEnter(Collider other)
 {
     if (other.gameObject.layer == 6)
     {
         SamplePlayer player = other.gameObject.GetComponent <SamplePlayer>();
         player.health = Mathf.Clamp(player.health + 20, 0, player.maxHealth);
         WorkerServerManager.instance.spawnManager.despawnObject(obj.objectID);
     }
 }
        public static SamplePlayer CreateSamplePlayer()
        {
            var player = new SamplePlayer();

            player.WithXAudio(AudioDefines.XAudio)
            .WithWaveFormat(AudioDefines.WaveFormat)
            .WithVoicePool(AudioDefines.VoicePool);

            return(player);
        }
        private async Task SelectedSingleItem(FileExplorerItem selectedItem)
        {
            foreach (FileExplorerItem item in CurrentItems)
            {
                if (item != selectedItem)
                {
                    item.Selected = false;
                }
                else
                {
                    item.Selected = true;

                    if (SelectionMode == SelectionMode.FileWithOpen)
                    {
                        try
                        {
                            IStorageFolderEx folder = FolderTree.First();
                            IStorageFileEx   file   = await folder.GetFileAsync(item.Name);

                            if (_player != null)
                            {
                                _player.Dispose();
                            }

                            if (file != null)
                            {
                                _player = new SamplePlayer();

                                _player.WithVoicePool(AudioDefines.VoicePool)
                                .WithXAudio(AudioDefines.XAudio)
                                .WithWaveFormat(AudioDefines.WaveFormat)
                                .WithChannelVolume(0.8)
                                .WithInput(file)
                                .BuildAsync().ContinueWith(task => task.Result.Play(), TaskScheduler.Default);
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                        }
                    }
                }

                FileExplorerItem targetItem = GetItemFromPath(item.Path);
                if (item.Selected && targetItem == null)
                {
                    SelectedItems.Add(item);
                }
                else if (!item.Selected && targetItem != null)
                {
                    SelectedItems.Remove(GetItemFromPath(item.Path));
                }
            }
        }
Beispiel #10
0
        public PlayerStatusList()
        {
            OnlinePlayers = 1;
            SamplePlayer p = new SamplePlayer
            {
                Name = "alexpotter96",
                Id   = JavaUUID.Generate("alexpotter96".ToBytes())
            };

            Players = new[] { p };
        }
Beispiel #11
0
 /// <summary>
 /// Starts recording the current audio or playing back the sample buffer.
 /// </summary>
 /// <param name="noteNo">The midi note number.</param>
 public void ProcessNoteOnEvent(byte noteNo)
 {
     if (_noteMap.ContainsKey(noteNo))
     {
         _player = new SamplePlayer(_noteMap[noteNo]);
     }
     else if (_recorder == null)
     {
         _recorder = new SampleRecorder(noteNo);
     }
 }
Beispiel #12
0
        /// <summary>
        /// Plays back the current sample buffer
        /// </summary>
        /// <param name="channels">Output buffers. Must not be null.</param>
        public void PlayAudio(VstAudioBuffer[] channels)
        {
            if (IsPlaying)
            {
                _player.Play(channels[0], channels[1]);

                if (_player != null && _player.IsFinished)
                {
                    _player = null;
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Starts recording the current audio or playing back the sample buffer.
        /// </summary>
        /// <param name="noteNo">The midi note number.</param>
        public void ProcessNoteOnEvent(byte noteNo)
        {
            if (_noteMap.ContainsKey(noteNo))
            {
                _plugin.PluginEditor.SetItemActive(noteNo);

                var gridItem     = _noteMap[noteNo];
                var stereobuffer = _stereoBuffers.FirstOrDefault(b => b.GridItemId == gridItem.ID);

                _player = new SamplePlayer(gridItem, stereobuffer);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Starts recording the current audio or playing back the sample buffer.
        /// </summary>
        /// <param name="noteNo">The midi note number.</param>
        public void ProcessNoteOnEvent(byte noteNo)
        {
            //System.Diagnostics.Debug.WriteLine("Note On event for note:" + noteNo, "VST.NET");

            if (_noteMap.ContainsKey(noteNo))
            {
                _player = new SamplePlayer(_noteMap[noteNo]);

                //System.Diagnostics.Debug.WriteLine("Playing Sample for note:" + noteNo, "VST.NET");
            }
            else if (_recorder == null)
            {
                _recorder = new SampleRecorder(noteNo);

                //System.Diagnostics.Debug.WriteLine("Recording Sample for note:" + noteNo, "VST.NET");
            }
        }
Beispiel #15
0
 static GameMaster()
 {
     Player    = new SamplePlayer();
     EnemyList = new List <EnemyBase>();
     ShotList  = new List <ShotBase>();
 }