# Trying to access Microphone Input

**URL:** <https://forum.juce.com/t/trying-to-access-microphone-input/62533>\
**Category:** Getting Started\
**Created:** [August 17, 2024, 8:00pm UTC](https://forum.juce.com/t/trying-to-access-microphone-input/62533 "2024-08-17T20:00:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnshin13](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/johnshin13/32/19156_2.png) [@johnshin13](https://forum.juce.com/u/johnshin13)\
**Post date:** [August 17, 2024, 8:00pm UTC](https://forum.juce.com/t/trying-to-access-microphone-input/62533/1 "2024-08-17T20:00:45Z")

</div>

I want to perform some real-time audio processing on my audio input and output it to my speakers. However, when I try to get the device from the device manager and print out the name, I only find that my speakers are selected. How would I go about getting an object that points to my microphone? I am windows running Visual Studio 2022. Code below:

```auto
 auto* InputDevice = deviceManager.getCurrentAudioDevice();
 auto* OutputDevice = deviceManager.getCurrentAudioDevice();

 /*DBG(InputDevice->getName() + "\n");
 DBG(OutputDevice->getName() + "\n");*/

 auto activeInputChannels = InputDevice->getActiveInputChannels();
 auto activeOutputChannels = OutputDevice->getActiveOutputChannels();

 auto maxInputChannels = activeInputChannels.getHighestBit() + 1;
 auto maxOutputChannels = activeOutputChannels.getHighestBit() + 1;

 auto buffer = bufferToFill.buffer;
 
 for (auto channel = 0; channel < maxOutputChannels; ++channel) {
     //in case we have no input channels due to permissions OR if the active output channels isn't outputting anything
     if ((!activeOutputChannels[channel]) || maxInputChannels == 0) {
         DBG("failed to get inputs\n");
         buffer->clear(channel, bufferToFill.startSample, bufferToFill.numSamples);
     }
     else {
         auto actualInputChannel = channel % maxInputChannels;

         if (!activeInputChannels[channel]) {
             DBG("input not active\n");

             buffer->clear(channel, bufferToFill.startSample, bufferToFill.numSamples);
         }
         else {
             auto* inBuffer = buffer->getReadPointer(actualInputChannel, bufferToFill.startSample);
             auto* outBuffer = buffer->getWritePointer(channel, bufferToFill.startSample);
             int numSamplesToProcess = 10;

             for (auto sample = 0; sample < bufferToFill.numSamples; ++sample) {
                 int loudness = juce::Decibels::gainToDecibels(buffer->getRMSLevel(channel, sample, numSamplesToProcess));

                 auto noise = (random.nextFloat() * 2.0f) - 1.0f;
                 outBuffer[sample] = inBuffer[sample] + (inBuffer[sample] * noise * 2);
             }
         }
     }

```

---

<div class="post-metadata">

**Author:** ![DirektDSP](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/direktdsp/32/15061_2.png) [@DirektDSP](https://forum.juce.com/u/DirektDSP)\
**Post date:** [August 18, 2024, 6:51pm UTC](https://forum.juce.com/t/trying-to-access-microphone-input/62533/2 "2024-08-18T18:51:36Z")

</div>

Just curious, but how/why should `deviceManager.getCurrentAudioDevice();` return a different device? would it not just return the same one twice (two outputs in this case?)

edit, i clearly cant read : )
