2012-10-26 2 views
0

Windows phone 7의 음성 (오디오) 녹음과 관련하여 다음과 같은 문제가 있습니다.Windows Phone 7에서 녹음 된 오디오를 증폭하고, 비트 전송률을 높이고, 페이드 아웃하는 방법은 무엇입니까?

Microsoft.Xna.Framework.Audio 네임 스페이스에서 사용할 수있는 마이크 클래스를 사용하여 사운드를 녹음하고 있습니다. 여기에 코드입니다 -

변수 선언 :

private Microphone mic = Microphone.Default; 
private MemoryStream stream; 
private const string FILE_NAME = "recording.mp3"; 
byte[] buffer; 

가 녹화 버튼 클릭이

mic.BufferDuration = TimeSpan.FromSeconds(1); 
buffer = new byte[mic.GetSampleSizeInBytes(mic.BufferDuration)]; 

// Create the event handler. I could have done an anonymous 
// delegate here if I had so desired. 
mic.BufferReady += new EventHandler<EventArgs>(mic_BufferReady); 

stream = new MemoryStream(); 
mic.Start(); 

버퍼 준비 이벤트 코드 ----------

void mic_BufferReady(object sender, EventArgs e) 
{ 
    mic.GetData(buffer); 
    // Write buffer to stream 
    stream.Write(buffer, 0, buffer.Length); 
} 
을 코드 -

버튼 스톱 코드 -

private void btnStop_Click(object sender, RoutedEventArgs e) 
{ 
    dt.Stop(); 
    btnStop.IsEnabled = false; 
    btnPlayRecording.IsEnabled = true; 

    mic.Stop(); 
    //Writing stream into Storage 
    writeFile(stream); 
} 

private void writeFile(MemoryStream s, string name) 
{ 
    try 
    { 
     using (var userStore = IsolatedStorageFile.GetUserStoreForApplication()) 
     { 
      if (userStore.FileExists(name)) 
      { 
       userStore.DeleteFile(name); 
      } 
      using (var file = userStore.OpenFile(name, FileMode.CreateNew)) 
      { 
       s.WriteTo(file); 
      } 
     } 
    } 
    catch (Exception ee) 
    { 

    } 
} 

일단 스트림을 격리 된 저장소에 저장하고 재생하면 볼륨이 낮아지고 품질도 좋지 않습니다.

그래서

  1. 우리는 볼륨을 증폭 할 수 있습니까?
  2. 우리는 비트율을 높일 수 있습니까?
  3. 우리는 Fadin-Fadout을 할 수 있습니까?

위의 세 가지 모두를 Windows Phone 7에서 사용할 수없는 경우 이러한 모든 작업을 수행 할 수있는 타사 API가 있습니까?

미리 감사드립니다.

답변

0

.NET의 증폭은 간단하지 않습니다. 내가 찾은 최선의 접근법은 "사운드 프로세싱 프로그램의 스위스 육군 칼"인 SoX에 외부 프로세스 호출을하는 것이 었습니다. (http://sox.sourceforge.net/)

저는 Windows 7 전화가 없으므로 SOX가 실행되고 있는지 확실하지 않습니다.

형식은 그래서 증폭 inputFileName 출력 _ volume_parameter SOX -V 것 :

는 "sox.exe -v 3.0 myNormalFile.wav의 myAmpedFile.wav는"

당신에게 300 %의 증폭을 줄 것입니다. Sox는 또한 비트율 변경을 허용합니다 ... Fadein/Fadeout에 대한 확신이 없습니다.

은 내가 특별히 윈도우 7 전화에 대해 아무것도하지만, 직선 .NET에서/C# 코드하지 않습니다

string finalFileName = "myAmplifiedFile.WAV"; 
string tmpFileName = "tmpHoldingFile.WAV"; 
string soxEXE = @"C:\SOX\sox.exe"; 
string soxArgs = "-v 3.0 "; 

/// OTHER STUFF HERE 

/*----------------------------------------------------------- 
* Call the SOX utility to amplify it so it is 3 times as loud. 
*-----------------------------------------------------------*/ 
try 
{ 
    System.Diagnostics.Process process = new System.Diagnostics.Process(); 
    process.StartInfo = new System.Diagnostics.ProcessStartInfo(); 
    process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
    process.StartInfo.FileName = soxEXE; 
    process.StartInfo.Arguments = string.Format("{0} {1} {2}", 
          soxArgs, tmpFileName, finalFileName); 
    process.Start(); 
    process.WaitForExit(); 
    int exitCode = process.ExitCode; 
} 
catch (Exception ex) 
{ 
    string err = ex.Message; 
    return false; 
} 
/*------------------------------------------------------------- 
* OK, now we play it using SoundPlayer 
*-------------------------------------------------------------*/ 
try 
{ 
    SoundPlayer simpleSound = new SoundPlayer(@finalFileName); 
    simpleSound.PlaySync(); 
    FileInfo readFile = new FileInfo(finalFileName); 
    string finalDestination = finalDirectory + "/" + readFile.Name; 
    readFile.MoveTo(finalDestination); 
} 
catch (Exception e) 
{ 
    string errmsg = e.Message; 
    return false; 
} 
finalFileName = ""; 
tmpFileName = ""; 
spVoice = null; 
관련 문제