0

I'm developing an application for recording , so I'm trying to decode trafic rtp using library Jnetpcap . The codec provided have in general two types : G711 alaw or G711 ulaw . I convert the payload and save it as a wav file but i can't listen the voice recorded . I use this code to convert byte array to a wav file :

     byte[] pcm_data= rtp.getPayload();
     pcm_data= new byte[44100*2];
     double L1      = 44100.0/440.0;
     double L2      = 44100.0/455.0;
     for(int i=0;i<pcm_data.length;i++){
        pcm_data[i]=  (byte)(55*Math.sin((i/L1)*Math.PI*2));
        pcm_data[i]+= (byte)(55*Math.sin((i/L2)*Math.PI*2));
        }

     AudioFormat      frmt= new AudioFormat(44100,8,1,true,false);
     AudioInputStream ais = new AudioInputStream(
                new ByteArrayInputStream(pcm_data)
               ,frmt
               ,pcm_data.length);

     AudioSystem.write(
                ais
               ,AudioFileFormat.Type.WAVE
               ,new File("test.wav"));
tintin
  • 11
  • 5
  • That's just two sine waves and has nothing to do with your input... – Henry Dec 25 '17 at 10:41
  • This is have a hard link with my input , i want to decode rtp trafic G711 and convert it to audio file , and above is my code for conversion , so read another one my input to understand it – tintin Dec 26 '17 at 10:52

0 Answers0