开发者

java sound api AudioSystem.getMixerInfo() issue

开发者 https://www.devze.com 2023-04-01 09:49 出处:网络
i\'m trying to make some simple audiorecorder-player from line-in but i\'ve faced a really annoying problem: When i\'m trying to AudioSystem.getMixerInfo() and printout list of available Mixer, i\'m g

i'm trying to make some simple audiorecorder-player from line-in but i've faced a really annoying problem: When i'm trying to AudioSystem.getMixerInfo() and printout list of available Mixer, i'm getting

????????? ???????? ??????? 
???????? (SoundMAX Integrated Digital HD Audio) 
????????? SPDIF (SoundMAX Integrated开发者_开发知识库 Digital HD Audio) 
????????? ??????? ?????? ????? 
????? ?????????? (SoundMAX Inte 
???. ???? (SoundMAX Integrated 
Java Sound Audio Engine 
Port ???????? (SoundMAX Integrated D 
Port ????????? SPDIF (SoundMAX Integ 
Port ???. ???? (SoundMAX Integrated  
Port ????? ?????????? (SoundMAX Inte 

Sorry?don't know how to format text, so i placed \n to mark where the line ends.

i can't understand what device to select because i can't even read nor russian description nor device name in most lines. Currently i'm using Win & x64 Russian Language. is it possible to solve somehow?


I'm a bit late with answer. But maybe this will help you or someone else facing same issue. I managed to solve it by properly decoding device name.

 byte bytes[] = deviceName.getBytes("ISO-8859-1"); // <- from
 String value = new String(bytes, "Windows-1251"); // <- to

Full code will be something like:

public static void main(String[] args) throws UnsupportedEncodingException {

    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
    for(int i = 0; i < mixerInfo.length; i++)
    {
        String deviceName = mixerInfo[i].getName();

        byte bytes[] = deviceName.getBytes("ISO-8859-1"); // <- from
        String value = new String(bytes, "Windows-1251"); // <- to

        System.out.println(value);

    }

}

And the output:

Primary Sound Driver
Динамики (Realtek High Definition Audio)
C24F390 (Аудио Intel(R) для дисплеев)
Port Динамики (Realtek High Definiti
Port C24F390 (Аудио Intel(R))
0

精彩评论

暂无评论...
验证码 换一张
取 消