Send AudioFormat down a TCP type connection - Java javax.sound.sampled

Java examples for javax.sound.sampled:Audio

Description

Send AudioFormat down a TCP type connection

Demo Code


//package com.java2s;

import java.io.PrintWriter;
import javax.sound.sampled.AudioFormat;

public class Main {
    /**/*  www. j  av a  2 s. c om*/
     * Send AudioFormat down a TCP type connection, so it can be decoded by
     * {@link #receiveAudioFormatFromTCP(BufferedReader)
     * receiveAudioFormatFromTCP}
     *
     * @param tcpTo
     *            the connection a PrintWriter
     * @param format
     *            the Audio Format to send
     */
    public static void sendAudioFormatDownTCP(PrintWriter tcpTo,
            AudioFormat format) {
        tcpTo.println(format.getEncoding());
        tcpTo.println(format.getSampleRate());
        tcpTo.println(format.getSampleSizeInBits());
        tcpTo.println(format.getChannels());
        tcpTo.println(format.getFrameSize());
        tcpTo.println(format.getFrameRate());
        tcpTo.println(format.isBigEndian());
    }
}

Related Tutorials