diff --git a/OpenBCI_GUI/OpenBCI_GUI.pde b/OpenBCI_GUI/OpenBCI_GUI.pde index 137930d..f81c273 100644 --- a/OpenBCI_GUI/OpenBCI_GUI.pde +++ b/OpenBCI_GUI/OpenBCI_GUI.pde @@ -38,6 +38,7 @@ import netP5.*; // for OSC import oscP5.*; // for OSC import hypermedia.net.*; //for UDP import java.nio.ByteBuffer; //for UDP +import edu.ucsd.sccn.LSL; //for LSL import gifAnimation.*; diff --git a/OpenBCI_GUI/W_networking.pde b/OpenBCI_GUI/W_networking.pde index c1dc6ca..1c9433d 100644 --- a/OpenBCI_GUI/W_networking.pde +++ b/OpenBCI_GUI/W_networking.pde @@ -938,7 +938,7 @@ class Stream extends Thread{ int start = dataBuffY_filtY_uV[0].length-11; int end = dataBuffY_filtY_uV[0].length-1; int bufferLen = end-start; - float[] dataToSend = new float[numChan]; + float[] dataToSend = new float[numChan*bufferLen]; //OSC Objects OscP5 osc; @@ -1158,12 +1158,12 @@ class Stream extends Thread{ } // LSL }else if (this.protocol.equals("LSL")){ - for(int i=0;i 1 year) for timeout values. @@ -41,31 +41,31 @@ /** * Data format of a channel (each transmitted sample holds an array of channels). - */ + */ public class ChannelFormat { public static final int float32 = 1; /** For up to 24-bit precision measurements in the appropriate physical unit * (e.g., microvolts). Integers from -16777216 to 16777216 are represented accurately. */ - public static final int double64 = 2; /** For universal numeric data as long as permitted by network & disk budget. + public static final int double64 = 2; /** For universal numeric data as long as permitted by network & disk budget. * The largest representable integer is 53-bit. */ public static final int string = 3; /** For variable-length ASCII strings or data blobs, such as video frames, * complex event descriptions, etc. */ - public static final int int32 = 4; /** For high-rate digitized formats that require 32-bit precision. Depends critically on + public static final int int32 = 4; /** For high-rate digitized formats that require 32-bit precision. Depends critically on * meta-data to represent meaningful units. Useful for application event codes or other coded data. */ - public static final int int16 = 5; /** For very high rate signals (40KHz+) or consumer-grade audio + public static final int int16 = 5; /** For very high rate signals (40KHz+) or consumer-grade audio * (for professional audio float is recommended). */ - public static final int int8 = 6; /** For binary signals or other coded data. + public static final int int8 = 6; /** For binary signals or other coded data. * Not recommended for encoding string data. */ - public static final int int64 = 7; /** For now only for future compatibility. Support for this type is not yet exposed in all languages. + public static final int int64 = 7; /** For now only for future compatibility. Support for this type is not yet exposed in all languages. * Also, some builds of liblsl will not be able to send or receive data of this type. */ public static final int undefined = 0; /** Can not be transmitted. */ } - + /** * Protocol version. * The major version is protocol_version() / 100; * The minor version is protocol_version() % 100; - * Clients with different minor versions are protocol-compatible with each other + * Clients with different minor versions are protocol-compatible with each other * while clients with different major versions will refuse to work together. */ public static int protocol_version() { return inst.lsl_protocol_version(); } @@ -79,13 +79,13 @@ /** * Obtain a local system time stamp in seconds. The resolution is better than a millisecond. - * This reading can be used to assign time stamps to samples as they are being acquired. - * If the "age" of a sample is known at a particular time (e.g., from USB transmission - * delays), it can be used as an offset to local_clock() to obtain a better estimate of + * This reading can be used to assign time stamps to samples as they are being acquired. + * If the "age" of a sample is known at a particular time (e.g., from USB transmission + * delays), it can be used as an offset to local_clock() to obtain a better estimate of * when a sample was actually captured. See stream_outlet::push_sample() for a use case. */ public static double local_clock() { return inst.lsl_local_clock(); } - + // ========================== // === Stream Declaration === @@ -98,25 +98,25 @@ * b) core information (stream name, content type, sampling rate) * c) optional meta-data about the stream content (channel labels, measurement units, etc.) * - * Whenever a program wants to provide a new stream on the lab network it will typically first + * Whenever a program wants to provide a new stream on the lab network it will typically first * create a stream_info to describe its properties and then construct a stream_outlet with it to create * the stream on the network. Recipients who discover the outlet can query the stream_info; it is also * written to disk when recording the stream (playing a similar role as a file header). - */ + */ public static class StreamInfo { /** * Construct a new stream_info object. * Core stream information is specified here. Any remaining meta-data can be added later. - * @param name Name of the stream. Describes the device (or product series) that this stream makes available + * @param name Name of the stream. Describes the device (or product series) that this stream makes available * (for use by programs, experimenters or data analysts). Cannot be empty. * @param type Content type of the stream. Please see Table of Content Types in the documentation for naming recommendations. * The content type is the preferred way to find streams (as opposed to searching by name). * @param channel_count Number of channels per sample. This stays constant for the lifetime of the stream. * @param nominal_srate The sampling rate (in Hz) as advertised by the data source, if regular (otherwise set to IRREGULAR_RATE). - * @param channel_format Format/type of each channel. If your channels have different formats, consider supplying + * @param channel_format Format/type of each channel. If your channels have different formats, consider supplying * multiple streams or use the largest type that can hold them all (such as cf_double64). - * @param source_id Unique identifier of the device or source of the data, if available (such as the serial number). - * This is critical for system robustness since it allows recipients to recover from failure even after the + * @param source_id Unique identifier of the device or source of the data, if available (such as the serial number). + * This is critical for system robustness since it allows recipients to recover from failure even after the * serving app, device or computer crashes (just by finding a stream with the same source id on the network again). * Therefore, it is highly recommended to always try to provide whatever information can uniquely identify the data source itself. */ @@ -126,16 +126,16 @@ public StreamInfo(String name, String type, int channel_count) { obj = inst.lsl_create_streaminfo(name, type, channel_count, IRREGULAR_RATE, ChannelFormat.float32, ""); } public StreamInfo(String name, String type) { obj = inst.lsl_create_streaminfo(name, type, 1, IRREGULAR_RATE, ChannelFormat.float32, ""); } public StreamInfo(Pointer handle) { obj = handle; } - + /** Destroy a previously created StreamInfo object. */ public void destroy() { inst.lsl_destroy_streaminfo(obj); } - + // ======================== // === Core Information === // ======================== // (these fields are assigned at construction) - + /** * Name of the stream. This is a human-readable name. For streams * offered by device modules, it refers to the type of device or product @@ -191,13 +191,13 @@ * online. */ public String source_id() { return inst.lsl_get_source_id(obj); } - - + + // ====================================== // === Additional Hosting Information === // ====================================== // (these fields are implicitly assigned once bound to an outlet/inlet) - + /** * Protocol version used to deliver the stream. */ @@ -232,20 +232,20 @@ /** * Hostname of the providing machine. */ - public String hostname() { return inst.lsl_get_hostname(obj); } - + public String hostname() { return inst.lsl_get_hostname(obj); } + // ======================== // === Data Description === // ======================== /** * Extended description of the stream. - * It is highly recommended that at least the channel labels are described here. - * See code examples in the documentation. Other information, such as amplifier settings, - * measurement units if deviating from defaults, setup information, subject information, etc., + * It is highly recommended that at least the channel labels are described here. + * See code examples in the documentation. Other information, such as amplifier settings, + * measurement units if deviating from defaults, setup information, subject information, etc., * can be specified here, as well. See Meta-Data Recommendations in the docs. * - * Important: if you use a stream content type for which meta-data recommendations exist, please + * Important: if you use a stream content type for which meta-data recommendations exist, please * try to lay out your meta-data in agreement with these recommendations for compatibility with other applications. */ public XMLElement desc() { return new XMLElement(inst.lsl_get_desc(obj)); } @@ -264,15 +264,15 @@ * Get access to the underlying native handle. */ public Pointer handle() { return obj; } - + private Pointer obj; } - - + + // ======================= // ==== Stream Outlet ==== // ======================= - + /** * A stream outlet. * Outlets are used to make streaming data (and the meta-data) available on the lab network. @@ -281,10 +281,10 @@ /** * Establish a new stream outlet. This makes the stream discoverable. * @param info The stream information to use for creating this stream. Stays constant over the lifetime of the outlet. - * @param chunk_size Optionally the desired chunk granularity (in samples) for transmission. If unspecified, + * @param chunk_size Optionally the desired chunk granularity (in samples) for transmission. If unspecified, * each push operation yields one chunk. Inlets can override this setting. - * @param max_buffered Optionally the maximum amount of data to buffer (in seconds if there is a nominal - * sampling rate, otherwise x100 in samples). The default is 6 minutes of data. + * @param max_buffered Optionally the maximum amount of data to buffer (in seconds if there is a nominal + * sampling rate, otherwise x100 in samples). The default is 6 minutes of data. */ public StreamOutlet(StreamInfo info, int chunk_size, int max_buffered) { obj = inst.lsl_create_outlet(info.handle(), chunk_size, max_buffered); } public StreamOutlet(StreamInfo info, int chunk_size) { obj = inst.lsl_create_outlet(info.handle(), chunk_size, 360); } @@ -293,16 +293,16 @@ /** * Close the outlet. * The stream will no longer be discoverable after closure and all paired inlets will stop delivering data. - */ + */ public void close() { inst.lsl_destroy_outlet(obj); } - - + + // ======================================== // === Pushing a sample into the outlet === // ======================================== /** - * Push an array of values as a sample into the outlet. + * Push an array of values as a sample into the outlet. * Each entry in the vector corresponds to one channel. * @param data An array of values to push (one for each channel). * @param timestamp Optionally the capture time of the sample, in agreement with local_clock(); if omitted, the current time is used. @@ -326,8 +326,8 @@ public void push_sample(byte[] data) { inst.lsl_push_sample_ctp(obj, data, 0.0, 1); } public void push_sample(String[] data, double timestamp, boolean pushthrough) { inst.lsl_push_sample_strtp(obj, data, timestamp, pushthrough ? 1 : 0); } public void push_sample(String[] data, double timestamp) { inst.lsl_push_sample_strtp(obj, data, timestamp, 1); } - public void push_sample(String[] data) { inst.lsl_push_sample_strtp(obj, data, 0.0, 1); } - + public void push_sample(String[] data) { inst.lsl_push_sample_strtp(obj, data, 0.0, 1); } + // =============================================================== // === Pushing an chunk of multiplexed samples into the outlet === @@ -377,7 +377,7 @@ public void push_chunk(short[] data, double[] timestamps) { inst.lsl_push_chunk_stnp(obj, data, (long)data.length, timestamps, 1); } public void push_chunk(byte[] data, double[] timestamps, boolean pushthrough) { inst.lsl_push_chunk_ctnp(obj, data, (long)data.length, timestamps, pushthrough ? 1 : 0); } public void push_chunk(byte[] data, double[] timestamps) { inst.lsl_push_chunk_ctnp(obj, data, (long)data.length, timestamps, 1); } - public void push_chunk(String[] data, double[] timestamps, boolean pushthrough) { inst.lsl_push_chunk_strtnp(obj, data, (long)data.length, timestamps, pushthrough ? 1 : 0); } + public void push_chunk(String[] data, double[] timestamps, boolean pushthrough) { inst.lsl_push_chunk_strtnp(obj, data, (long)data.length, timestamps, pushthrough ? 1 : 0); } public void push_chunk(String[] data, double[] timestamps) { inst.lsl_push_chunk_strtnp(obj, data, (long)data.length, timestamps, 1); } @@ -400,13 +400,13 @@ /** * Retrieve the stream info provided by this outlet. * This is what was used to create the stream (and also has the Additional Network Information fields assigned). - */ + */ public StreamInfo info() { return new StreamInfo(inst.lsl_get_info(obj)); } - + private Pointer obj; } - - + + // =========================== // ==== Resolve Functions ==== // =========================== @@ -414,15 +414,15 @@ /** * Resolve all streams on the network. * This function returns all currently available streams from any outlet on the network. - * The network is usually the subnet specified at the local router, but may also include + * The network is usually the subnet specified at the local router, but may also include * a multicast group of machines (given that the network supports it), or list of hostnames. - * These details may optionally be customized by the experimenter in a configuration file + * These details may optionally be customized by the experimenter in a configuration file * (see Configuration File in the documentation). * This is the default mechanism used by the browsing programs and the recording program. * @param wait_time The waiting time for the operation, in seconds, to search for streams. - * Warning: If this is too short (less than 0.5s) only a subset (or none) of the + * Warning: If this is too short (less than 0.5s) only a subset (or none) of the * outlets that are present on the network may be returned. - * @return An array of stream info objects (excluding their desc field), any of which can + * @return An array of stream info objects (excluding their desc field), any of which can * subsequently be used to open an inlet. The full info can be retrieve from the inlet. */ public static StreamInfo[] resolve_streams(double wait_time) @@ -443,7 +443,7 @@ * @param minimum Optionally return at least this number of streams. * @param timeout Optionally a timeout of the operation, in seconds (default: no timeout). * If the timeout expires, less than the desired number of streams (possibly none) will be returned. - * @return An array of matching stream info objects (excluding their meta-data), any of + * @return An array of matching stream info objects (excluding their meta-data), any of * which can subsequently be used to open an inlet. */ public static StreamInfo[] resolve_stream(String prop, String value, int minimum, double timeout) @@ -459,13 +459,13 @@ /** * Resolve all streams that match a given predicate. - * Advanced query that allows to impose more conditions on the retrieved streams; the given String is an XPath 1.0 + * Advanced query that allows to impose more conditions on the retrieved streams; the given String is an XPath 1.0 * predicate for the node (omitting the surrounding []'s), see also http://en.wikipedia.org/w/index.php?title=XPath_1.0&oldid=474981951. * @param pred The predicate String, e.g. "name='BioSemi'" or "type='EEG' and starts-with(name,'BioSemi') and count(info/desc/channel)=32" * @param minimum Return at least this number of streams. * @param timeout Optionally a timeout of the operation, in seconds (default: no timeout). * If the timeout expires, less than the desired number of streams (possibly none) will be returned. - * @return An array of matching stream info objects (excluding their meta-data), any of + * @return An array of matching stream info objects (excluding their meta-data), any of * which can subsequently be used to open an inlet. */ public static StreamInfo[] resolve_stream(String pred, int minimum, double timeout) @@ -478,8 +478,8 @@ } public static StreamInfo[] resolve_stream(String pred, int minimum) { return resolve_stream(pred, minimum, FOREVER); } public static StreamInfo[] resolve_stream(String pred) { return resolve_stream(pred, 1, FOREVER); } - - + + // ====================== // ==== Stream Inlet ==== // ====================== @@ -487,26 +487,26 @@ /** * A stream inlet. * Inlets are used to receive streaming data (and meta-data) from the lab network. - */ + */ public static class StreamInlet { /** * Construct a new stream inlet from a resolved stream info. * @param info A resolved stream info object (as coming from one of the resolver functions). - * Note: the stream_inlet may also be constructed with a fully-specified stream_info, - * if the desired channel format and count is already known up-front, but this is - * strongly discouraged and should only ever be done if there is no time to resolve the + * Note: the stream_inlet may also be constructed with a fully-specified stream_info, + * if the desired channel format and count is already known up-front, but this is + * strongly discouraged and should only ever be done if there is no time to resolve the * stream up-front (e.g., due to limitations in the client program). - * @param max_buflen Optionally the maximum amount of data to buffer (in seconds if there is a nominal - * sampling rate, otherwise x100 in samples). Recording applications want to use a fairly - * large buffer size here, while real-time applications would only buffer as much as + * @param max_buflen Optionally the maximum amount of data to buffer (in seconds if there is a nominal + * sampling rate, otherwise x100 in samples). Recording applications want to use a fairly + * large buffer size here, while real-time applications would only buffer as much as * they need to perform their next calculation. - * @param max_chunklen Optionally the maximum size, in samples, at which chunks are transmitted + * @param max_chunklen Optionally the maximum size, in samples, at which chunks are transmitted * (the default corresponds to the chunk sizes used by the sender). - * Recording applications can use a generous size here (leaving it to the network how + * Recording applications can use a generous size here (leaving it to the network how * to pack things), while real-time applications may want a finer (perhaps 1-sample) granularity. * If left unspecified (=0), the sender determines the chunk granularity. - * @param recover Try to silently recover lost streams that are recoverable (=those that that have a source_id set). - * In all other cases (recover is false or the stream is not recoverable) functions may throw a + * @param recover Try to silently recover lost streams that are recoverable (=those that that have a source_id set). + * In all other cases (recover is false or the stream is not recoverable) functions may throw a * LostException if the stream's source is lost (e.g., due to an app or computer crash). */ public StreamInlet(StreamInfo info, int max_buflen, int max_chunklen, boolean recover) { obj = inst.lsl_create_inlet(info.handle(), max_buflen, max_chunklen, recover?1:0); } @@ -514,7 +514,7 @@ public StreamInlet(StreamInfo info, int max_buflen) { obj = inst.lsl_create_inlet(info.handle(), max_buflen, 0, 1); } public StreamInlet(StreamInfo info) { obj = inst.lsl_create_inlet(info.handle(), 360, 0, 1); } - /** + /** * Disconnect and close the inlet. */ public void close() { inst.lsl_destroy_inlet(obj); } @@ -530,21 +530,21 @@ /** * Subscribe to the data stream. - * All samples pushed in at the other end from this moment onwards will be queued and - * eventually be delivered in response to pull_sample() or pull_chunk() calls. + * All samples pushed in at the other end from this moment onwards will be queued and + * eventually be delivered in response to pull_sample() or pull_chunk() calls. * Pulling a sample without some preceding open_stream is permitted (the stream will then be opened implicitly). * @param timeout Optional timeout of the operation (default: no timeout). * @throws TimeoutException (if the timeout expires), or LostException (if the stream source has been lost). */ public void open_stream(double timeout) throws Exception { int[] ec = {0}; inst.lsl_open_stream(obj, timeout, ec); check_error(ec); } public void open_stream() throws Exception { open_stream(FOREVER); } - + /** * Drop the current data stream. - * All samples that are still buffered or in flight will be dropped and transmission - * and buffering of data for this inlet will be stopped. If an application stops being - * interested in data from a source (temporarily or not) but keeps the outlet alive, - * it should call close_stream() to not waste unnecessary system and network + * All samples that are still buffered or in flight will be dropped and transmission + * and buffering of data for this inlet will be stopped. If an application stops being + * interested in data from a source (temporarily or not) but keeps the outlet alive, + * it should call close_stream() to not waste unnecessary system and network * resources. */ public void close_stream() { inst.lsl_close_stream(obj); } @@ -555,13 +555,13 @@ * Subsequent calls are instantaneous (and rely on periodic background updates). * The precision of these estimates should be below 1 ms (empirically within +/-0.2 ms). * @timeout Timeout to acquire the first time-correction estimate (default: no timeout). - * @return The time correction estimate. This is the number that needs to be added to a time stamp + * @return The time correction estimate. This is the number that needs to be added to a time stamp * that was remotely generated via lsl_local_clock() to map it into the local clock domain of this machine. * @throws TimeoutException (if the timeout expires), or LostException (if the stream source has been lost). */ public double time_correction(double timeout) throws Exception { int[] ec = {0}; double res = inst.lsl_time_correction(obj, timeout, ec); check_error(ec); return res; } public double time_correction() throws Exception { return time_correction(FOREVER); } - + // ======================================= // === Pulling a sample from the inlet === // ======================================= @@ -571,12 +571,12 @@ * Handles type checking & conversion. * @param sample An array to hold the resulting values. * @param timeout The timeout for this operation, if any. Use 0.0 to make the function non-blocking. - * @return The capture time of the sample on the remote machine, or 0.0 if no new sample was available. - * To remap this time stamp to the local clock, add the value returned by .time_correction() to it. + * @return The capture time of the sample on the remote machine, or 0.0 if no new sample was available. + * To remap this time stamp to the local clock, add the value returned by .time_correction() to it. * @throws LostException (if the stream source has been lost). */ public double pull_sample(float[] sample, double timeout) throws Exception { int[] ec = {0}; double res = inst.lsl_pull_sample_f(obj, sample, sample.length, timeout, ec); check_error(ec); return res; } - public double pull_sample(float[] sample) throws Exception { return pull_sample(sample, FOREVER); } + public double pull_sample(float[] sample) throws Exception { return pull_sample(sample, FOREVER); } public double pull_sample(double[] sample, double timeout) throws Exception { int[] ec = {0}; double res = inst.lsl_pull_sample_d(obj, sample, sample.length, timeout, ec); check_error(ec); return res; } public double pull_sample(double[] sample) throws Exception { return pull_sample(sample, FOREVER); } public double pull_sample(int[] sample, double timeout) throws Exception { int[] ec = {0}; double res = inst.lsl_pull_sample_i(obj, sample, sample.length, timeout, ec); check_error(ec); return res; } @@ -587,7 +587,7 @@ public double pull_sample(byte[] sample) throws Exception { return pull_sample(sample, FOREVER); } public double pull_sample(String[] sample, double timeout) throws Exception { int[] ec = {0}; double res = inst.lsl_pull_sample_str(obj, sample, sample.length, timeout, ec); check_error(ec); return res; } public double pull_sample(String[] sample) throws Exception { return pull_sample(sample, FOREVER); } - + // ============================================================= @@ -597,14 +597,14 @@ /** * Pull a chunk of data from the inlet. * @param data_buffer A pre-allocated buffer where the channel data shall be stored. - * @param timestamp_buffer A pre-allocated buffer where time stamps shall be stored. - * @param timeout Optionally the timeout for this operation, if any. When the timeout expires, the function - * may return before the entire buffer is filled. The default value of 0.0 will retrieve only + * @param timestamp_buffer A pre-allocated buffer where time stamps shall be stored. + * @param timeout Optionally the timeout for this operation, if any. When the timeout expires, the function + * may return before the entire buffer is filled. The default value of 0.0 will retrieve only * data available for immediate pickup. * @return samples_written Number of samples written to the data and timestamp buffers. * @throws LostException (if the stream source has been lost). */ - public int pull_chunk(float[] data_buffer, double[] timestamp_buffer, double timeout) throws Exception { int[] ec = {0}; long res = inst.lsl_pull_chunk_f(obj, data_buffer, timestamp_buffer, (long)data_buffer.length, (long)timestamp_buffer.length, timeout, ec); check_error(ec); return (int)res; } + public int pull_chunk(float[] data_buffer, double[] timestamp_buffer, double timeout) throws Exception { int[] ec = {0}; long res = inst.lsl_pull_chunk_f(obj, data_buffer, timestamp_buffer, (long)data_buffer.length, (long)timestamp_buffer.length, timeout, ec); check_error(ec); return (int)res; } public int pull_chunk(float[] data_buffer, double[] timestamp_buffer) throws Exception { return pull_chunk(data_buffer, timestamp_buffer, 0.0); } public int pull_chunk(double[] data_buffer, double[] timestamp_buffer, double timeout) throws Exception { int[] ec = {0}; long res = inst.lsl_pull_chunk_d(obj, data_buffer, timestamp_buffer, (long)data_buffer.length, (long)timestamp_buffer.length, timeout, ec); check_error(ec); return (int)res; } public int pull_chunk(double[] data_buffer, double[] timestamp_buffer) throws Exception { return pull_chunk(data_buffer, timestamp_buffer, 0.0); } @@ -619,24 +619,24 @@ /** * Query whether samples are currently available for immediate pickup. - * Note that it is not a good idea to use samples_available() to determine whether + * Note that it is not a good idea to use samples_available() to determine whether * a pull_*() call would block: to be sure, set the pull timeout to 0.0 or an acceptably - * low value. If the underlying implementation supports it, the value will be the number of + * low value. If the underlying implementation supports it, the value will be the number of * samples available (otherwise it will be 1 or 0). */ public int samples_available() { return (int)inst.lsl_samples_available(obj); } /** * Query whether the clock was potentially reset since the last call to was_clock_reset(). - * This is a rarely-used function that is only useful to applications that combine multiple time_correction - * values to estimate precise clock drift; it allows to tolerate cases where the source machine was + * This is a rarely-used function that is only useful to applications that combine multiple time_correction + * values to estimate precise clock drift; it allows to tolerate cases where the source machine was * hot-swapped or restarted in between two measurements. */ public boolean was_clock_reset() { return (int)inst.lsl_was_clock_reset(obj)!=0; } - + private Pointer obj; } - + // ===================== // ==== XML Element ==== @@ -748,23 +748,23 @@ /** Remove a specified child element. */ public void remove_child(XMLElement e) { inst.lsl_remove_child(obj, e.obj); } - + private Pointer obj; } - - + + // =========================== // === Continuous Resolver === // =========================== - /** - * A convenience class that resolves streams continuously in the background throughout - * its lifetime and which can be queried at any time for the set of streams that are currently + /** + * A convenience class that resolves streams continuously in the background throughout + * its lifetime and which can be queried at any time for the set of streams that are currently * visible on the network. */ public static class ContinuousResolver { /** - * Construct a new continuous_resolver that resolves all streams on the network. + * Construct a new continuous_resolver that resolves all streams on the network. * This is analogous to the functionality offered by the free function resolve_streams(). * @param forget_after When a stream is no longer visible on the network (e.g., because it was shut down), * this is the time in seconds after which it is no longer reported by the resolver. @@ -793,31 +793,31 @@ public ContinuousResolver(String pred, double forget_after) { obj = inst.lsl_create_continuous_resolver_bypred(pred, forget_after); } public ContinuousResolver(String pred) { obj = inst.lsl_create_continuous_resolver_bypred(pred, 5.0); } - /** + /** * Close the resolver and stop sending queries. - * It is recommended to close a resolver once not needed any more to avoid spamming + * It is recommended to close a resolver once not needed any more to avoid spamming * the network with resolve queries. */ void close() { inst.lsl_destroy_continuous_resolver(obj); } - + /** * Obtain the set of currently present streams on the network (i.e. resolve result). - * @return An array of matching stream info objects (excluding their meta-data), any of + * @return An array of matching stream info objects (excluding their meta-data), any of * which can subsequently be used to open an inlet. */ public StreamInfo[] results() { - Pointer[] buf = new Pointer[1024]; + Pointer[] buf = new Pointer[1024]; int num = inst.lsl_resolver_results(obj,buf,buf.length); StreamInfo[] res = new StreamInfo[num]; for (int k = 0; k < num; k++) res[k] = new StreamInfo(buf[k]); return res; } - + private Pointer obj; // the underlying native handle } - - + + // ======================= // === Exception Types === // ======================= @@ -828,7 +828,7 @@ public static class TimeoutException extends Exception { public TimeoutException(String message) { super(message); } } - + /** * Exception class that indicates that a stream inlet's source has been irrecoverably lost. */ @@ -842,14 +842,14 @@ public static class ArgumentException extends Exception { public ArgumentException(String message) { super(message); } } - + /** * Exception class that indicates that an internal error has occurred inside liblsl. */ public static class InternalException extends Exception { public InternalException(String message) { super(message); } } - + /** * Check an error condition and throw an exception if appropriate. */ @@ -864,10 +864,10 @@ static void check_error(int[] ec) throws Exception { } } - - /** + + /** * Internal: C library interface. - */ + */ public interface dll extends Library { int lsl_protocol_version(); int lsl_library_version(); @@ -898,7 +898,7 @@ static void check_error(int[] ec) throws Exception { int lsl_push_sample_buftp(Pointer obj, byte[][] data, int[] lengths, double timestamp, int pushthrough); int lsl_push_chunk_ftp(Pointer obj, float[] data, long data_elements, double timestamp, int pushthrough); int lsl_push_chunk_ftnp(Pointer obj, float[] data, long data_elements, double[] timestamps, int pushthrough); - int lsl_push_chunk_dtp(Pointer obj, double[] data, long data_elements, double timestamp, int pushthrough); + int lsl_push_chunk_dtp(Pointer obj, double[] data, long data_elements, double timestamp, int pushthrough); int lsl_push_chunk_dtnp(Pointer obj, double[] data, long data_elements, double[] timestamps, int pushthrough); int lsl_push_chunk_itp(Pointer obj, int[] data, long data_elements, double timestamp, int pushthrough); int lsl_push_chunk_itnp(Pointer obj, int[] data, long data_elements, double[] timestamps, int pushthrough); @@ -908,8 +908,8 @@ static void check_error(int[] ec) throws Exception { int lsl_push_chunk_ctnp(Pointer obj, byte[] data, long data_elements, double[] timestamps, int pushthrough); int lsl_push_chunk_strtp(Pointer obj, String[] data, long data_elements, double timestamp, int pushthrough); int lsl_push_chunk_strtnp(Pointer obj, String[] data, long data_elements, double[] timestamps, int pushthrough); - int lsl_push_chunk_buftp(Pointer obj, byte[][] data, long[] lengths, long data_elements, double timestamp, int pushthrough); - int lsl_push_chunk_buftnp(Pointer obj, byte[][] data, long[] lengths, long data_elements, double[] timestamps, int pushthrough); + int lsl_push_chunk_buftp(Pointer obj, byte[][] data, long[] lengths, long data_elements, double timestamp, int pushthrough); + int lsl_push_chunk_buftnp(Pointer obj, byte[][] data, long[] lengths, long data_elements, double[] timestamps, int pushthrough); int lsl_have_consumers(Pointer obj); int lsl_wait_for_consumers(Pointer obj); Pointer lsl_get_info(Pointer obj); @@ -928,7 +928,7 @@ static void check_error(int[] ec) throws Exception { double lsl_pull_sample_s(Pointer obj, short[] buffer, int buffer_elements, double timeout, int[] ec); double lsl_pull_sample_c(Pointer obj, byte[] buffer, int buffer_elements, double timeout, int[] ec); double lsl_pull_sample_str(Pointer obj, String[] buffer, int buffer_elements, double timeout, int[] ec); - double lsl_pull_sample_buf(Pointer obj, byte[][] buffer, long[] buffer_lengths, int buffer_elements, double timeout, int[] ec); + double lsl_pull_sample_buf(Pointer obj, byte[][] buffer, long[] buffer_lengths, int buffer_elements, double timeout, int[] ec); long lsl_pull_chunk_f(Pointer obj, float[] data_buffer, double[] timestamp_buffer, long data_buffer_elements, long timestamp_buffer_elements, double timeout, int[] ec); long lsl_pull_chunk_d(Pointer obj, double[] data_buffer, double[] timestamp_buffer, long data_buffer_elements, long timestamp_buffer_elements, double timeout, int[] ec); long lsl_pull_chunk_i(Pointer obj, int[] data_buffer, double[] timestamp_buffer, long data_buffer_elements, long timestamp_buffer_elements, double timeout, int[] ec); @@ -968,11 +968,11 @@ static void check_error(int[] ec) throws Exception { Pointer lsl_create_continuous_resolver_bypred(String pred, double forget_after); int lsl_resolver_results(Pointer obj, Pointer[] buffer, int buffer_elements); void lsl_destroy_continuous_resolver(Pointer obj); - + } - + static dll inst; - static { + static { switch (Platform.getOSType()) { case Platform.WINDOWS: inst = (dll)Native.loadLibrary((Platform.is64Bit() ? "liblsl64.dll" : "liblsl32.dll"),dll.class); @@ -993,8 +993,8 @@ static void check_error(int[] ec) throws Exception { static { String libname; if (Platform.isWindows()) { - + } else { } }*/ -} \ No newline at end of file +} diff --git a/libraries/LSLLink/src/main/resources/liblsl32.dylib b/libraries/LSLLink/src/main/resources/darwin/liblsl32.dylib similarity index 100% rename from libraries/LSLLink/src/main/resources/liblsl32.dylib rename to libraries/LSLLink/src/main/resources/darwin/liblsl32.dylib diff --git a/libraries/LSLLink/src/main/resources/liblsl64.dylib b/libraries/LSLLink/src/main/resources/darwin/liblsl64.dylib similarity index 100% rename from libraries/LSLLink/src/main/resources/liblsl64.dylib rename to libraries/LSLLink/src/main/resources/darwin/liblsl64.dylib diff --git a/libraries/LSLLink/src/main/resources/linux-x86-64/liblsl64.so b/libraries/LSLLink/src/main/resources/linux-x86-64/liblsl64.so new file mode 100644 index 0000000..cb503d3 Binary files /dev/null and b/libraries/LSLLink/src/main/resources/linux-x86-64/liblsl64.so differ diff --git a/libraries/LSLLink/src/main/resources/liblsl32.dll b/libraries/LSLLink/src/main/resources/win32-amd64/liblsl32.dll similarity index 100% rename from libraries/LSLLink/src/main/resources/liblsl32.dll rename to libraries/LSLLink/src/main/resources/win32-amd64/liblsl32.dll diff --git a/libraries/LSLLink/src/main/resources/liblsl64.dll b/libraries/LSLLink/src/main/resources/win32-amd64/liblsl64.dll similarity index 100% rename from libraries/LSLLink/src/main/resources/liblsl64.dll rename to libraries/LSLLink/src/main/resources/win32-amd64/liblsl64.dll diff --git a/libraries/LSLLink/src/main/resources/win32-x86-64/liblsl32.dll b/libraries/LSLLink/src/main/resources/win32-x86-64/liblsl32.dll new file mode 100644 index 0000000..ed3e9e7 Binary files /dev/null and b/libraries/LSLLink/src/main/resources/win32-x86-64/liblsl32.dll differ diff --git a/libraries/LSLLink/src/main/resources/win32-x86-64/liblsl64.dll b/libraries/LSLLink/src/main/resources/win32-x86-64/liblsl64.dll new file mode 100644 index 0000000..611e75c Binary files /dev/null and b/libraries/LSLLink/src/main/resources/win32-x86-64/liblsl64.dll differ