Package javax.sound.sampled

Examples of javax.sound.sampled.SourceDataLine.open()


     */
    public static SourceDataLine getLine() {
        if (activeMixer != null) {
            try {
                SourceDataLine line = (SourceDataLine) activeMixer.getLine(TargetLineInfo);
                line.open();
                return line;
            } catch (LineUnavailableException ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        }
View Full Code Here


        // get a line and construct a new player
        AudioFormat requestedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, Rate, 16, Channels, 4, Rate, false);
        SourceDataLine line;
        try {
            line = AudioSystem.getSourceDataLine(requestedFormat);
            line.open();
        } catch (LineUnavailableException ex) {
            LOG.log(Level.SEVERE, null, ex);
            return;
        }
        line.start();
View Full Code Here

        DataLine.Info info = new DataLine.Info(SourceDataLine.class, targetFormat);
        SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);

        if (line != null) {
            // open it
            line.open();

            // start
            line.start();
            int nBytesRead = 0, nBytesWritten = 0;
            while (nBytesRead != -1) {
View Full Code Here

    // JavaSound setup.
    int sampleSize = 2;
    AudioFormat audioFormat = new AudioFormat(sampleRate, 8 * sampleSize, outChans, true, true);
    DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
    SourceDataLine sourceDataLine = (SourceDataLine) AudioSystem.getLine(info);
    sourceDataLine.open(audioFormat);
    sourceDataLine.start();

    // Buffer setup for exchanging samples between libpd and JavaSound.
    // Question: Is this the best possible solution?  It seems to involve too
    // much copying.
View Full Code Here

        SourceDataLine auline = null;
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
        try {
            auline = (SourceDataLine) AudioSystem.getLine(info);
            auline.open(format);
        } catch (LineUnavailableException e) {
            e.printStackTrace();
            return;
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

                    float seconds = 0.3f;
                    try {
                        AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, true);
                        DataLine.Info info = new DataLine.Info(SourceDataLine.class, af);
                        SourceDataLine source = (SourceDataLine) AudioSystem.getLine(info);
                        source.open(af);
                        source.start();
                        byte[] buf = new byte[(int) (SAMPLE_RATE * seconds)];
                        for (int i = 0; i < buf.length; i++) {
                            buf[i] = (byte) (Math.sin(RAD * frequency / SAMPLE_RATE * i) * 64.0 / Math.sqrt(i));
                        }
View Full Code Here

        SourceDataLine auline = null;
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);

        try {
            auline = (SourceDataLine) AudioSystem.getLine(info);
            auline.open(format);
        } catch (LineUnavailableException e) {
            e.printStackTrace();
            return;
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

        SourceDataLine line = null;
        try {
            line = (SourceDataLine)mixer.getLine(linfo);
            log("    got line: " + line);
            log("    open...");
            line.open();
        } catch (IllegalArgumentException ex) {
            log("    unsupported (IllegalArgumentException)");
            return;
        } catch (LineUnavailableException ex) {
            log("    unavailable: " + ex);
View Full Code Here

        SourceDataLine auline = null;
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);

        try {
            auline = (SourceDataLine) AudioSystem.getLine(info);
            auline.open(format);
        } catch (LineUnavailableException e) {
            e.printStackTrace();
            return;
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

            Collections.sort(scale);

            System.out.println("Scale: " + scale);

            SourceDataLine line = AudioSystem.getSourceDataLine(af);
            line.open(af);
            line.start();

            Double[] scaleFrequencies = scale.toArray(new Double[scale.size()]);

            // first play the whole scale
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.