播放WAV文件落后

编程入门 行业动态 更新时间:2024-10-23 16:23:20
本文介绍了播放WAV文件落后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我做的编织在Java中。如果你后退的时候,声音反向播放。如何向后播放WAV文件?也许用类似 previous流()?辫的网站,你可以明白我的意思。

I'm making Braid in Java. If you rewind the time, the sound plays backward. How to play a WAV file backwards? Maybe with a stream with something like previous()? On the site of Braid can you see what I mean.

更新: 解决了!看到了自己的职务。

推荐答案

YEEEEEEESSSSS !!!!!!!!

YEEEEEEESSSSS!!!!!!!!

我解决了我自己(14岁!)结果我写这个类:

I solved it by myself (14 years old!!) I've written this class:

import java.io.IOException; import javax.sound.sampled.AudioInputStream; /** * * @author Martijn */ public class FrameBuffer { private byte[][] frames; private int frameSize; public FrameBuffer(AudioInputStream stream) throws IOException { readFrames(stream); } public byte[] getFrame(int i) { return frames[i]; } public int numberFrames() { return frames.length; } public int frameSize() { return frameSize; } private void readFrames(AudioInputStream stream) throws IOException { frameSize = stream.getFormat().getFrameSize(); frames = new byte[stream.available() / frameSize][frameSize]; int i = 0; for (; i < frames.length; i++) { byte[] frame = new byte[frameSize]; int numBytes = stream.read(frame, 0, frameSize); if (numBytes == -1) { break; } frames[i] = frame; } System.out.println("FrameSize = " + frameSize); System.out.println("Number frames = " + frames.length); System.out.println("Number frames read = " + i); } }

和则:

FrameBuffer frameStream = new FrameBuffer(austream); //austream is the audiostream int frame = frameStream.numberFrames() - 1; while (frame >= 0) { auline.write(frameStream.getFrame(frame), 0, frameStream.frameSize()); frame--; }

更多推荐

播放WAV文件落后

本文发布于:2023-07-11 12:19:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094035.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:落后   文件   WAV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!