Guest User

Untitled

a guest
Nov 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. // worklez@treblefrei ~ % svn cat svn://localhost/kedr/trunk/src/org/treblefrei/kedr/database/musicdns/ofa/Ofa.java
  2. package org.treblefrei.kedr.database.musicdns.ofa;
  3.  
  4. import com.sun.jna.Library;
  5. import com.sun.jna.Native;
  6. import com.sun.jna.NativeLong;
  7. import org.treblefrei.kedr.audio.AudioDecoderException;
  8. import org.treblefrei.kedr.audio.DecodedAudioData;
  9.  
  10. import java.io.FileNotFoundException;
  11.  
  12. /**
  13. * Created by IntelliJ IDEA.
  14. * User: worklez
  15. * Date: 05.12.2009
  16. * Time: 23:53:37
  17. */
  18.  
  19. interface COfa extends Library {
  20. COfa instance = (COfa) Native.loadLibrary("ofa", COfa.class);
  21. String ofa_create_print(byte[] samples, int byteOrder, NativeLong size, int sRate, int stereo);
  22. }
  23.  
  24. public class Ofa {
  25. public static String createPrint(byte[] samples, int sRate, int stereo) {
  26. NativeLong nlSize = new NativeLong(samples.length);
  27. // LITTLE_ENDIAN = 0, BIG_ENDIAN = 1
  28. return COfa.instance.ofa_create_print(samples, 0, nlSize, sRate, stereo);
  29. }
  30.  
  31. public static String createPrint(DecodedAudioData data) throws AudioDecoderException, FileNotFoundException {
  32. int channels = data.getChannels();
  33. if (channels > 2) {
  34. throw new RuntimeException("too many audio channels");
  35. }
  36. return Ofa.createPrint(data.getData(), data.getSampleRate(), channels - 1);
  37. }
  38. }
Add Comment
Please, Sign In to add comment