public App(IBluetooth bluetooth, IAudio audio, IAudioResource audioResource) { Bluetooth = bluetooth; AudioRenderer = new AudioRenderer(audio, audioResource); bluetooth.ConnectedDevices.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => { if (e.OldItems != null) { foreach (BluetoothDevice oldItem in e.OldItems) { oldItem.BeatReceived -= BeatReceived; } } if (e.NewItems != null) { foreach (BluetoothDevice newItem in e.NewItems) { newItem.BeatReceived += BeatReceived; } } }; // The root page of your application MainPage = new ContentPage(); OpenScanView(); }
public SampleBeat(IAudioResource audioResource, Beat beat, Dictionary <string, string> beatMap) { Name = beat.Name; Time = beat.Time; Intensity = (float)beat.Intensity; Audio = audioResource.GetAudioResource(beatMap[beat.Name]); }
public static void PlayAudioFile(string fileName) { if (_audioResource == null) { _audioResource = DependencyService.Get <IAudioResource>(); } if (FileResource.IsExists(fileName) == false) { var audio = EmbadedResource.GetAudio(fileName); FileResource.Save(fileName, audio); } _audioResource.PlayAudioFile(fileName); }
public AudioRenderer(IAudio audio, IAudioResource audioResource) { _audio = audio; _audioResource = audioResource; _beatList = new LinkedList <SampleBeat> (); _lastBeatTime = new Dictionary <string, DateTime> (); BeatMap = new Dictionary <string, string> () { { "foot", "psycho_boomer.raw" }, { "pad1", "drum.raw" }, { "pad2", "hi_hat.raw" }, { "pad3", "hi_hat_2.raw" }, { "pad4", "kick.raw" }, { "pad5", "plunk.raw" }, { "pad6", "snare.raw" }, { "pad7", "stick.raw" }, { "pad8", "inception.raw" }, }; audio.ProcessBlockEventHandler += ProcessBlock; audio.Start(); }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ public PlayerController() { /*load walking sound*/ this._walkSound = (IAudioResource) SystemCore.ResourceManager.GetResource("/Data/Audio/mech_walk.mp3", null).Data; }