MATLAB has function audiorecorder
ready to use :
Fs = 44100; % [Hz] sampling freq
nBits = 16;
nChannels = 2;
ID = -1; % default audio input device
recObj = audiorecorder(Fs,nBits,nChannels,ID);
disp("start recording")
recDuration = 15; % record for 15 seconds
recordblocking(recObj,recDuration);
disp("stop recording")
play(recObj);
MATLAB home edition is really cheap, have a look :