//private int[] mSampleRates = new int[] { 8000, 11025, 22050, 44100 }; //private int[] audioFormats = new int[] { (int)Encoding.Pcm8bit, (int)Encoding.Pcm16bit }; //private int[] channelConfigs = new int[] { (int)ChannelIn.Mono, (int)ChannelIn.Stereo }; //private int rate = 44100; //private Encoding audioEncoding = Encoding.Pcm16bit; //private ChannelIn channelConfig = ChannelIn.Stereo; //public Action<bool> RecordingStateChanged; //public string[] PermissionsAudio { get; } = { // Manifest.Permission.RecordAudio // }; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); _container = new TinyIoCContainer(); _container.Register <IAudioRecorder, AudioRecorder>().AsSingleton(); _container.Register <IAudioPlayback, AudioPlayback>().AsSingleton(); _container.Register <ITrackMixer, TrackMixer>().AsSingleton(); _audioPlayback = _container.Resolve <IAudioPlayback>(); _audioRecorder = _container.Resolve <IAudioRecorder>(); _trackMixer = _container.Resolve <ITrackMixer>(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); audioTracks = new List <byte[]>(); //layout = FindViewById<LinearLayout>(Resource.Layout.Main); //mainTextView = FindViewById<TextView>(Resource.Id.textView1); Button startRecordingButton = FindViewById <Button>(Resource.Id.btnStartRecording); Button stopRecordingButton = FindViewById <Button>(Resource.Id.btnStopRecording); Button playbackButton = FindViewById <Button>(Resource.Id.btnPlayback); Button mixtrackButton = FindViewById <Button>(Resource.Id.btnMixTracks); startRecordingButton.Click += async(sender, e) => await StartRecordingButton_Click(); stopRecordingButton.Click += async(sender, e) => await StopRecordingButton_Click(); playbackButton.Click += async(sender, e) => await PlaybackButton_Click(); mixtrackButton.Click += async(sender, e) => await MixtrackButton_Click(); }
//Creates a track mixer for an ITrackMixer PlayableBehaviour public static ScriptPlayable <T> CreateTrackMixer <T>(TrackAsset track, PlayableGraph graph, GameObject go, int inputCount) where T : class, IPlayableBehaviour, ITrackMixer, new() { ScriptPlayable <T> playable = ScriptPlayable <T> .Create(graph, inputCount); ITrackMixer mixer = playable.GetBehaviour(); if (mixer != null) { PlayableDirector playableDirector = go.GetComponent <PlayableDirector>(); mixer.SetTrackAsset(track, playableDirector); } return(playable); }
private static PlayableBehaviour GetTrackMixer(Playable root, TrackAsset track, Type type) { int inputCount = root.GetOutputCount(); for (int i = 0; i < inputCount; i++) { Playable rootInput = root.GetOutput(i); if (rootInput.IsValid()) { //If this input is a T, check it matches our track if (rootInput.GetPlayableType() is ITrackMixer) { PlayableBehaviour playableBehaviour = GetPlayableBehaviour(rootInput, type); ITrackMixer trackMixer = playableBehaviour as ITrackMixer; if (trackMixer != null && trackMixer.GetTrackAsset() == track) { return(playableBehaviour); } } //Otherwise search this playable's inputs { PlayableBehaviour trackMixer = GetTrackMixer(rootInput, track, type); if (trackMixer != null) { return(trackMixer); } } } } return(null); }
public void Init(ITrackMixer parentMixer) { _parentMixer = parentMixer; }