示例#1
0
 public static int get_num_songs(H5File h5) {
   H5CompoundDS metadata;
   try {
     metadata = (H5CompoundDS) h5.get("/metadata/songs");
     metadata.init();
     return metadata.getHeight();
   } catch (Exception e) {
     e.printStackTrace();
     return -1;
   }
 }
示例#2
0
 @SuppressWarnings("rawtypes")
 public static String get_member_string(H5File h5, int songidx, String table, String member)
     throws Exception {
   H5CompoundDS analysis = (H5CompoundDS) h5.get(table);
   analysis.init();
   int wantedMember = find(analysis.getMemberNames(), member);
   assert (wantedMember >= 0);
   Vector alldata = (Vector) analysis.getData();
   String[] col = (String[]) alldata.get(wantedMember);
   return col[songidx];
 }
示例#3
0
 @SuppressWarnings("rawtypes")
 public static String[] get_array_string(H5File h5, int songidx, String group, String arrayname)
     throws Exception {
   // index
   H5CompoundDS analysis = (H5CompoundDS) h5.get(group + "/songs");
   analysis.init();
   int wantedMember = find(analysis.getMemberNames(), "idx_" + arrayname);
   assert (wantedMember >= 0);
   Vector alldata = (Vector) analysis.getData();
   int[] col = (int[]) alldata.get(wantedMember);
   int pos1 = col[songidx];
   // data
   H5ScalarDS array = (H5ScalarDS) h5.get("/" + group + "/" + arrayname);
   String[] data = (String[]) array.getData();
   int pos2 = data.length;
   if (songidx + 1 < col.length) pos2 = col[songidx + 1];
   // copy
   String[] res = new String[pos2 - pos1];
   for (int k = 0; k < res.length; k++) res[k] = data[pos1 + k];
   return res;
 }
示例#4
0
 @SuppressWarnings("rawtypes")
 public static double[] get_array_double(
     H5File h5, int songidx, String group, String arrayname, int ndims, String idxname)
     throws Exception {
   // index
   H5CompoundDS analysis = (H5CompoundDS) h5.get(group + "/songs");
   analysis.init();
   if (idxname.equals("")) idxname = "idx_" + arrayname;
   int wantedMember = find(analysis.getMemberNames(), idxname);
   assert (wantedMember >= 0);
   Vector alldata = (Vector) analysis.getData();
   int[] col = (int[]) alldata.get(wantedMember);
   int pos1 = col[songidx];
   // data
   H5ScalarDS array = (H5ScalarDS) h5.get("/" + group + "/" + arrayname);
   if (ndims == 1) {
     double[] data = (double[]) array.getData();
     int pos2 = data.length;
     if (songidx + 1 < col.length) pos2 = col[songidx + 1];
     // copy
     double[] res = new double[pos2 - pos1];
     for (int k = 0; k < res.length; k++) res[k] = data[pos1 + k];
     return res;
   } else if (ndims == 2) // multiply by 12
   {
     pos1 *= 12;
     double[] data = (double[]) array.getData();
     int pos2 = data.length;
     if (songidx + 1 < col.length) pos2 = col[songidx + 1] * 12;
     // copy
     double[] res = new double[pos2 - pos1];
     for (int k = 0; k < res.length; k++) res[k] = data[pos1 + k];
     return res;
   }
   // more than 2 dims?
   return null;
 }