Mercurial > hg > jvamp
comparison org/vamp_plugins/RealTime.java @ 20:cf6c69871f9c
Start on RealTime native bits -- incomplete
author | Chris Cannam |
---|---|
date | Wed, 08 Feb 2012 15:22:48 +0000 |
parents | 5b0847d344c3 |
children | c9515589be7d |
comparison
equal
deleted
inserted
replaced
19:5b0847d344c3 | 20:cf6c69871f9c |
---|---|
1 | 1 |
2 package org.vamp_plugins; | 2 package org.vamp_plugins; |
3 | 3 |
4 public class RealTime { | 4 public class RealTime |
5 public int sec; | 5 { |
6 public int nsec; | 6 public RealTime(int s, int n) { initialise(s, n); } |
7 | 7 |
8 public RealTime(int s, int n) { sec = s; nsec = n; } | 8 public native void dispose(); |
9 | 9 |
10 static RealTime frame2RealTime(int frame, int sampleRate) { | 10 public native int sec(); |
11 //!!! warning! doesn't support -ve frame [unlike Vamp SDK version] | 11 public native int nsec(); |
12 int sec = frame / sampleRate; | |
13 frame -= sec * sampleRate; | |
14 int nsec = (int)((((double)frame * 1000000.0) / sampleRate) * 1000.0); | |
15 return new RealTime(sec, nsec); | |
16 } | |
17 | 12 |
18 public String toString() { | 13 public native int usec(); |
19 return sec + ":" + nsec; | 14 public native int msec(); |
20 } | 15 |
16 /// Return a debug-type string to full precision | |
17 public native String toString(); | |
18 | |
19 /// Return a user-readable formatted string to the nearest millisecond | |
20 public native String toText(); | |
21 | |
22 public native static RealTime fromSeconds(double sec); | |
23 public native static RealTime fromMilliseconds(int msec); | |
24 | |
25 public native static RealTime frame2RealTime(long frame, int sampleRate); | |
26 public native static long realTime2Frame(RealTime r, int sampleRate); | |
27 | |
28 private native void initialise(int s, int n); | |
29 private long nativeHandle; | |
21 } | 30 } |
22 | 31 |
23 | 32 |