public void StartRecording() { System.IO.Stream outputStream = System.IO.File.Open(wavPath, FileMode.Create); bWriter = new BinaryWriter(outputStream); audioBuffer = new byte[44100 * 5]; // 44100 sample rate * 10 sek (max time) audRecorder = new AudioRecord(AudioSource.Mic, 44100, ChannelIn.Mono, Android.Media.Encoding.Pcm16bit, audioBuffer.Length); // long longSampleRate = 44100; // int channels = 2; // long byteRate = 16*longSampleRate*channels/8; // // long totalAudioLen = audioBuffer.Length; // long totalDataLen = totalAudioLen + 36; // // WriteWaveFileHeader(bWriter, // totalAudioLen, // totalDataLen, // longSampleRate, // channels, // byteRate); IsRecording = true; audRecorder.StartRecording(); SaveBinaryAudio(outputStream); }
public void XML_Carga(string raizW, string raizL, string[] arqs) { Mensaje_Curto("Carregando arquivos da Web..."); foreach (string arq in arqs) { HttpWebRequest llamadas = (HttpWebRequest)WebRequest.Create(raizW + arq); HttpWebResponse resposta = (HttpWebResponse)llamadas.GetResponse(); System.IO.Stream txt = resposta.GetResponseStream(); StreamWriter doc = new StreamWriter(raizL + arq); byte[] buf = new byte[8192]; string lin = null; int con = 1; while (con > 0) { con = txt.Read(buf, 0, buf.Length); if (con != 0) { lin = System.Text.Encoding.UTF8.GetString(buf, 0, con); doc.WriteLine(lin); } } doc.Close(); doc.Dispose(); } Mensaje_Curto("Arquivos XML carregados no telefone."); }
/// <summary> /// load a stream (maybe from a file) into this snapshot. /// </summary> /// <param name="r"></param> public void load(System.IO.Stream r) { XmlSerializer s = new XmlSerializer(typeof(Revision)); Revision rev = null; string branch = null; MemoryStream strm; _branches.insert(branch); do { strm = _readBytes(r); if (strm != null) { rev = s.Deserialize(strm) as Revision; if (rev != null) { _addRevision(rev); } } } while(strm != null); r.Close(); }
//Common /// <summary> /// Return image that is used as support image, images are build-in /// </summary> /// <param name="name">name of image inside resource</param> /// <returns></returns> private object GetSupportImageRest(string name) { System.IO.Stream image = _impl.GetSupportImage(name); response = new Nancy.Response(); response = Response.FromStream(image, "image/png"); return(response); }
/// <summary> /// Return image with given path /// </summary> /// <param name="path"></param> /// <returns></returns> private object GetImageUsingPathRest(string path) { System.IO.Stream image = _rest.GetImageUsingPath(path); response = new Nancy.Response(); response = Response.FromStream(image, MimeTypes.GetMimeType(path)); return(response); }
/// <summary> /// Return image that is used as support image, images are build-in with given ratio /// </summary> /// <param name="name"></param> /// <param name="ratio"></param> /// <returns></returns> private object GetSupportImageRest(string name, string ratio) { System.IO.Stream image = _rest.GetSupportImage(name, ratio); response = new Nancy.Response(); // This will always be png, so we are ok response = Response.FromStream(image, "image/png"); return(response); }
/// <summary> /// Return thumbnail with given ratio /// </summary> /// <param name="type"></param> /// <param name="id"></param> /// <param name="ratio"></param> /// <returns></returns> private object GetThumbRest(string type, string id, string ratio) { string contentType; System.IO.Stream image = _rest.GetThumb(type, id, ratio, out contentType); response = new Nancy.Response(); response = Response.FromStream(image, contentType); return(response); }
/// <summary> /// Return image with given Id type and information if its should be thumb /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <param name="thumb"></param> /// <returns></returns> private object GetImageRest(string id, string type, bool thumb) { string contentType; System.IO.Stream image = _rest.GetImage(type, id, thumb, out contentType); response = new Nancy.Response(); // This is not always png response = Response.FromStream(image, contentType); return(response); }
public static string ReadJsonFromInternalStorage(System.IO.Stream fileStream) { const long bufferLength = 1024 * 1024 * 20; byte[] jsonBytes = new byte[bufferLength]; fileStream.Read(jsonBytes, 0, jsonBytes.Length); var json = GetString(jsonBytes); return(json); }
public static byte[] ReadFully(System.IO.Stream input) { byte[] buffer = new byte[16 * 1024]; using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { int read; while ((read = input.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); } return(ms.ToArray()); } }
void Initialize(Stream stream, System.Action <string> callback, Encoding encoding, int bufferSize) { if (bufferSize < MIN_BUFFSIZE) { bufferSize = MIN_BUFFSIZE; } this.stream = stream; this.callback = callback; this.encoding = encoding; this.bbuff = new byte[bufferSize]; this.cbuff = new char[encoding.GetMaxCharCount(bufferSize)]; this.decoder = this.encoding.GetDecoder(); this.mtxEof = new Thr::ManualResetEvent(false); }
/// <summary> /// save the current status of this snapshot out to a stream (file?) /// </summary> /// <param name="w"></param> public void save(System.IO.Stream w) { /* create the snapshot */ XmlSerializer s = new XmlSerializer(typeof(Revision)); RevisionIdx.iterator it = this._changesetIdx.begin(); for (; it != this._changesetIdx.end(); ++it) { s.Serialize(w, it.value()); w.Write(MAGIC_BYTES, 0, MAGIC_BYTES.Length); } w.Flush(); w.Close(); }
private void Init(Process process, Stream stream, UserCallBack callback, Encoding encoding, int bufferSize) { this.process = process; this.stream = stream; this.encoding = encoding; this.userCallBack = callback; this.decoder = encoding.GetDecoder(); if (bufferSize < 0x80) { bufferSize = 0x80; } this.byteBuffer = new byte[bufferSize]; this._maxCharsPerBuffer = encoding.GetMaxCharCount(bufferSize); this.charBuffer = new char[this._maxCharsPerBuffer]; this.cancelOperation = false; this.eofEvent = new Thr::ManualResetEvent(false); this.sb = null; this.bLastCarriageReturn = false; }
protected virtual void Dispose(bool disposing) { if (this.stream != null) { if (disposing) { this.stream.Close(); } this.stream = null; this.encoding = null; this.decoder = null; this.byteBuffer = null; this.charBuffer = null; } if (this.eofEvent != null) { this.eofEvent.Close(); this.eofEvent = null; } }
public override ResourceData FromFileToUpdate(System.IO.Stream stream, string extension, ResourceLang currentLang) { return(FromFile(stream, extension)); }
public static void WriteJsonToInternalStorage(System.IO.Stream fileStream, string json) { var jsonBytes = GetBytes(json); fileStream.Write(jsonBytes, 0, jsonBytes.Length); }
public override ResourceData FromFileToAdd(System.IO.Stream stream, string extension, ushort langId, ResourceSource currentSource) { return(FromFile(stream, extension)); }