[질문] 사운드카드 볼륨 조절

살자의 이미지

안녕하세요.
현재 사운드 카드를 이용하여 볼륨을 조절하는 기능을 만들고있습니다.
볼륨은 조절이 돼지만 최고값이 그다지 크지 않아서여.
아래는 저의 사운드 카드 제어 소스입니다.
볼륨 제어에 문제가 없는지, 어떻게 하면 볼륨의 최대값을 더 높일수 있는지 궁금합니다.
고수님들의 많은 조언 부탁드립니다.

unsigned short volume = 0x5a5a; //maximum 0x6464 만 올라가고 다음은 올라가지 않음.
unsigned short micvolume = 0x1f9f;

int CDevice::SoundCardOpen()
{
sound_in = -1;
sound_out = -1;

pthread_mutex_lock(&devicemutex);
sound_in = open("/dev/dsp", O_RDONLY);
sound_out = open("/dev/dsp", O_WRONLY);

if(sound_in {
pthread_mutex_unlock(&devicemutex);
return -1;
}

SetDriver(sound_in); // Sound card setting
SetDriver(sound_out); // Sound card setting

ioctl(sound_out, SOUND_MIXER_WRITE_VOLUME, &volume);
ioctl(sound_in, SOUND_MIXER_WRITE_MIC, &micvolume);
pthread_mutex_unlock(&devicemutex);
return 1;
}

//Sound card setting 함수
int CDevice::SetDriver(int os_handle)
{
int arg, val;
int fragmentValue = 0x7fff0008;
int sampleRate = 8000;
int bitsPerSample = 16;
int numChannels = 2;

arg = val = fragmentValue;
ioctl(os_handle, SNDCTL_DSP_SETFRAGMENT, &arg);

arg = val = (bitsPerSample == 16) ? AFMT_S16_LE : AFMT_S8;
ioctl(os_handle, SNDCTL_DSP_SETFMT, &arg);

arg = val = (numChannels == 2) ? 1 : 0;
ioctl(os_handle, SNDCTL_DSP_STEREO, &arg);

arg = val = sampleRate;
ioctl(os_handle, SNDCTL_DSP_SPEED, &arg);
}

void CDevice::SoundCardClose()
{
int nIn, nOut;
pthread_mutex_lock(&devicemutex);
nIn = close(sound_in);

if (nIn {
pthread_mutex_unlock(&devicemutex);
return;
}
pthread_mutex_unlock(&devicemutex);
}

// 볼륨 조절 함수
void CDevice::SetVolume(int vol)
{
unsigned short getvol;
unsigned short _volume, _svolume, _evolume, _micvolume;

_volume = volume + vol;
_svolume = _volume _evolume = _svolume>>8;
_volume = _svolume + _evolume;
_micvolume = micvolume + vol;

pthread_mutex_lock(&devicemutex);
ioctl(sound_out,SOUND_MIXER_WRITE_VOLUME, &_volume);
ioctl(sound_in, SOUND_MIXER_READ_MIC, &getvol);
pthread_mutex_unlock(&devicemutex);
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.