c# - CSCore Application Audio Mixer Name+Peak -
i try peak(the level of green bar in audio mixer of win7) of processid example 5640 - spotify.
searched @ internet library. found cscore.
now have this:
class program { static void main(string[] args) { using (var sessionmanager = getdefaultaudiosessionmanager2(dataflow.render)) { using (var sessionenumerator = sessionmanager.getsessionenumerator()) { foreach (var session in sessionenumerator) { using (var audiometerinformation = session.queryinterface<audiometerinformation>()) { console.writeline(audiometerinformation.getpeakvalue()*100); } } } } console.readkey(); } private static audiosessionmanager2 getdefaultaudiosessionmanager2(dataflow dataflow) { using (var enumerator = new mmdeviceenumerator()) { using (var device = enumerator.getdefaultaudioendpoint(dataflow, role.multimedia)) { debug.writeline("defaultdevice: " + device.friendlyname); var sessionmanager = audiosessionmanager2.frommmdevice(device); return sessionmanager; } } } } }
the documentation of http://cscore.codeplex.com/ doesn't helped me. can give me example code, how can output this:
58,31232---process-id---spotify
at moment looks this:
you can modify code (also take @ unit-tests of cscore):
class program { static void main(string[] args) { using (var sessionmanager = getdefaultaudiosessionmanager2(dataflow.render)) using (var sessionenumerator = sessionmanager.getsessionenumerator()) { foreach (var session in sessionenumerator) { assert.isnotnull(session); using (var session2 = session.queryinterface<audiosessioncontrol2>()) using (var audiometerinformation = session.queryinterface<audiometerinformation>()) { debug.writeline("process: {0}; peak: {1:p}", session2.process == null ? string.empty : session2.process.mainwindowtitle, audiometerinformation.getpeakvalue()*100); } } } console.readkey(); } private static audiosessionmanager2 getdefaultaudiosessionmanager2(dataflow dataflow) { using (var enumerator = new mmdeviceenumerator()) { using (var device = enumerator.getdefaultaudioendpoint(dataflow, role.multimedia)) { debug.writeline("defaultdevice: " + device.friendlyname); var sessionmanager = audiosessionmanager2.frommmdevice(device); return sessionmanager; } } } }
Comments
Post a Comment