public override void run() { this.totalSamplesRead = 0L; Microphone.access_200(this.this_0).info("started recording"); if (Microphone.access_300(this.this_0)) { Microphone.access_402(this.this_0, new Utterance("Microphone", Microphone.access_500(this.this_0).getFormat())); } Microphone.access_700(this.this_0).add(new DataStartSignal(Microphone.access_600(this.this_0))); Microphone.access_800(this.this_0).info("DataStartSignal added"); IOException ex2; try { Microphone.access_100(this.this_0).start(); while (!this.done) { Data data = this.readData(Microphone.access_400(this.this_0)); if (data == null) { this.done = true; break; } Microphone.access_700(this.this_0).add(data); } Microphone.access_100(this.this_0).flush(); if (Microphone.access_900(this.this_0)) { Microphone.access_500(this.this_0).close(); Microphone.access_100(this.this_0).close(); java.lang.System.err.println("set to null"); Microphone.access_102(this.this_0, null); } } catch (IOException ex) { ex2 = ex; goto IL_138; } goto IL_173; IL_138: IOException ex3 = ex2; Microphone.access_1000(this.this_0).warning(new StringBuilder().append("IO Exception ").append(Throwable.instancehelper_getMessage(ex3)).toString()); Throwable.instancehelper_printStackTrace(ex3); IL_173: long duration = ByteCodeHelper.d2l((double)this.totalSamplesRead / (double)Microphone.access_500(this.this_0).getFormat().getSampleRate() * 1000.0); Microphone.access_700(this.this_0).add(new DataEndSignal(duration)); Microphone.access_1100(this.this_0).info("DataEndSignal ended"); Microphone.access_1200(this.this_0).info("stopped recording"); lock (this.@lock) { Object.instancehelper_notify(this.@lock); } }
private Data readData(Utterance utterance) { byte[] array = new byte[Microphone.access_1400(this.this_0)]; int channels = Microphone.access_500(this.this_0).getFormat().getChannels(); long num = this.totalSamplesRead; long num2 = (long)channels; long firstSampleNumber = (num2 != -1L) ? (num / num2) : (-num); int num3 = Microphone.access_500(this.this_0).read(array, 0, array.Length); if (!this.started) { lock (this) { this.started = true; System.Threading.Thread.MemoryBarrier(); Object.instancehelper_notifyAll(this); } } if (Microphone.access_1500(this.this_0).isLoggable(Level.FINE)) { Microphone.access_1600(this.this_0).info(new StringBuilder().append("Read ").append(num3).append(" bytes from audio stream.").toString()); } if (num3 <= 0) { return(null); } int num4 = Microphone.access_500(this.this_0).getFormat().getSampleSizeInBits() / 8; long num5 = this.totalSamplesRead; int num6 = num3; int num7 = num4; this.totalSamplesRead = num5 + (long)((num7 != -1) ? (num6 / num7) : (-(long)num6)); if (num3 != Microphone.access_1400(this.this_0)) { bool flag = num3 != 0; int num8 = num4; if (num8 != -1 && (flag ? 1 : 0) % num8 != 0) { string text = "Incomplete sample read."; throw new Error(text); } array = Arrays.copyOf(array, num3); } if (Microphone.access_300(this.this_0)) { utterance.add(array); } double[] array2; if (Microphone.access_1700(this.this_0)) { array2 = DataUtil.bytesToValues(array, 0, array.Length, num4, Microphone.access_1800(this.this_0)); } else { array2 = DataUtil.littleEndianBytesToValues(array, 0, array.Length, num4, Microphone.access_1800(this.this_0)); } if (channels > 1) { array2 = Microphone.access_1900(this.this_0, array2, channels); } return(new DoubleData(array2, ByteCodeHelper.f2i(Microphone.access_500(this.this_0).getFormat().getSampleRate()), firstSampleNumber)); }