Exemplo n.º 1
0
        public async System.Threading.Tasks.Task CreateAudioGraphAsync(string outputFileName)
        {
            Windows.Media.Audio.AudioGraphSettings graphSettings = new Windows.Media.Audio.AudioGraphSettings(Windows.Media.Render.AudioRenderCategory.Media);
            graphSettings.QuantumSizeSelectionMode = Windows.Media.Audio.QuantumSizeSelectionMode.LowestLatency;

            // TODO: let user pick from list of devices instead of blindly picking first one -- hoping for the microphone.
            Windows.Devices.Enumeration.DeviceInformationCollection deviceInformationCollection = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.AudioRender);

            Windows.Devices.Enumeration.DeviceInformation deviceInformation = deviceInformationCollection[0]; // blindly pick first one
            graphSettings.PrimaryRenderDevice = deviceInformation;

            Windows.Media.Audio.CreateAudioGraphResult result = await Windows.Media.Audio.AudioGraph.CreateAsync(graphSettings);

            if (result.Status != Windows.Media.Audio.AudioGraphCreationStatus.Success)
            {
                WoundifyShared.Log.WriteLine("Cannot create graph:" + result.Status.ToString());
                return;
            }

            graph = result.Graph;

            await AudioDeviceInputAsync(); // setup microphone (usually)

            //await AudioDeviceOutputAsync(); // setup speakers (usually)
            await AudioFileOutputAsync(WoundifyShared.Options.options.tempFolderPath + outputFileName); // setup file

            deviceInputNode.AddOutgoingConnection(fileOutputNode);
        }
Exemplo n.º 2
0
 public void Dispose() // TODO: implement IDispose
 {
     if (graph != null)
     {
         graph.Dispose();
         graph = null;
     }
 }