buffer

Playing Audio in .Net / C#

两盒软妹~` 提交于 2019-12-20 10:23:38
问题 I'm an experienced MFC programmer of many years, who for the more recent years has been developing commercial apps in Objective C for Mac and iOS - I'm trying to get up to speed with .Net and C# (as I'm soon going to be required to convert one of my commercial apps from Mac to PC). I've now worked my way through a couple of books and as an exercise to get more familiar with .Net (and C#) I've decided to have a go at converting one of my none commercial apps to .Net as a learning exercise and

Android AudioTrack buffering problems

天大地大妈咪最大 提交于 2019-12-20 08:49:27
问题 Ok so I have a frequency generator which uses AudioTrack to send PCM data to the hardware. Here's the code I'm using for that: private class playSoundTask extends AsyncTask<Void, Void, Void> { float frequency; float increment; float angle = 0; short samples[] = new short[1024]; @Override protected void onPreExecute() { int minSize = AudioTrack.getMinBufferSize( 44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT ); track = new AudioTrack( AudioManager.STREAM_MUSIC,

C++ return string keeps getting junk

我与影子孤独终老i 提交于 2019-12-20 05:56:20
问题 Why does the return string here have all sorts of junk on it? string getChunk(ifstream &in){ char buffer[5]; for(int x = 0; x < 5; x++){ buffer[x] = in.get(); cout << x << " " << buffer[x] << endl; } cout << buffer << endl; return buffer; } ifstream openFile; openFile.open ("Bacon.txt"); chunk = getChunk(openFile); cout << chunk; I get a load of junk in the string where it has junk on the end of it, even though my debug says that my buffer is being filled with the correct characters. Thanks,

OpenGL - add vertices

浪尽此生 提交于 2019-12-20 05:47:53
问题 I have a subfunction that reads a data stream and creates an array of vertex data based on that. The main function calls this subfunction repeatedly and updates the vertex data array, which is then bound to a buffer and drawn. So far, so good. However, I cannot figure out how to add vertices. C++ does not let you reassign or resize entire arrays. I can't use vectors because the OpenGL functions take in arrays, not vectors. 回答1: You can use vectors to populate an OpenGL vertex buffer. The

php echo the result while iterating through the loop

旧巷老猫 提交于 2019-12-20 04:15:19
问题 I am execution loop and inside loop there is data processing function inside loop. for($i = 0 ; $i <=680 ; $i = $i + 40) { $url = 'http://www.yelp.com/biz/franchino-san-francisco?start=80'; $root = yelp($url); var_dump($root); } This loop takes long time to execute, and results are echoed at the end when entire loop completes. How can I echo the result during each iteration? Actually what happens here? does to result are stored in buffer and at the end echoed or what? 回答1: PHP buffers the

buffering a set of lines from a file and storing it in an array in C

纵饮孤独 提交于 2019-12-20 04:13:55
问题 This might be a very inefficient way to do it, but its sort of working This code reads through a file, stores 8 line of text at a time in a global array (Would like a better option to do this if possible ) and dispatches for further processing. here's the code int count = 0; //global char *array_buffer[8]; //global void line(char *line_char) { int lent = strlen(line_char); array_buffer[count] = line_char; printf("%d\n",count); if (count == 8) { int row,col; for(row = 0; row<count; row++){

Convert byte array to generic value type?

不问归期 提交于 2019-12-20 04:09:58
问题 I have a Stream where I'd like to read data from (as value type segments) and move the position according to the size of the given type (declared as generics). My current approach: public byte ReadUInt8(Stream stream) { return (byte)stream.ReadByte(); } public ushort ReadUInt16(Stream stream) { return (ushort)((ReadUInt8() << 8) | ReadUInt8()); } ... What I'd like to achieve: public TValue Read<TValue>(Stream stream) where TValue : struct { var bufferSize = Marshal.SizeOf(typeof(TValue)); var

Javascript - How to convert buffer to a string?

蓝咒 提交于 2019-12-20 04:08:51
问题 This is example of converting String to a Buffer and back to String: let bufferOne = Buffer.from('This is a buffer example.'); console.log(bufferOne); // Output: <Buffer 54 68 69 73 20 69 73 20 61 20 62 75 66 66 65 72 20 65 78 61 6d 70 6c 65 2e> let json = JSON.stringify(bufferOne); let bufferOriginal = Buffer.from(JSON.parse(json).data); console.log(bufferOriginal.toString('utf8')); // Output: This is a buffer example. Now imagine someone just give you only this string as a starting point:

Flush output of child process

蹲街弑〆低调 提交于 2019-12-20 03:27:37
问题 I created a child process via IPC::Open2 . I need to read from the stdout of this child process line by line. Problem is, as the stdout of the child process is not connected to a terminal, it's fully buffered and I can't read from it until the process terminates. How can I flush the output of the child process without modifying its code ? child process code while (<STDIN>) { print "Received : $_"; } parent process code: use IPC::Open2; use Symbol; my $in = gensym(); my $out = gensym(); my

Buffer a large file; BufferedInputStream limited to 2gb; Arrays limited to 2^31 bytes

只谈情不闲聊 提交于 2019-12-20 03:19:12
问题 I am sequentially processing a large file and I'd like to keep a large chunk of it in memory, 16gb ram available on a 64 bit system. A quick and dirty way is to do this, is simply wrap the input stream into a buffered input stream, unfortunately, this only gives me a 2gb buffer. I'd like to have more of it in memory, what alternatives do I have? 回答1: How about letting the OS deal with the buffering of the file? Have you checked what the performance impact of not copying the whole file into