diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/Configuration.java b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/Configuration.java index bf813e203..71a8f861f 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/Configuration.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/Configuration.java @@ -902,6 +902,7 @@ public class GuiLabelConfig{ public static final String ENABLE_ERROR_LEDS_RTC = "RTC Error LEDs"; public static final String ENABLE_ERROR_LEDS_SD = "SD Error LEDs"; public static final String LOW_POWER_AUTOSTOP = "Low-power Autostop"; + public static final String RAW_AUDIO = "Store Raw Audio"; public static final String KINEMATIC_LPM = "Kinematic Sensors Low-Power Mode";//XXX-RS-LSM-SensorClass? What about HighResolutionMode?! public static final String CALIBRATION_ALL = AbstractSensor.GuiLabelConfigCommon.CALIBRATION_ALL; @@ -2002,6 +2003,13 @@ public static class CompatibilityInfoForMaps{ ConfigOptionDetailsSensor.GUI_COMPONENT_TYPE.CHECKBOX, Arrays.asList(new ShimmerVerObject(FW_ID.LOGANDSTREAM, 0, 9, 6), new ShimmerVerObject(FW_ID.SDLOG, 0, 17, 3))); + + /** Bench audio recorder (audiorec9): also store the microphone WAV beside the fingerprint. */ + public static final ConfigOptionDetailsSensor configOptionRawAudio = new ConfigOptionDetailsSensor( + Configuration.Shimmer3.GuiLabelConfig.RAW_AUDIO, + ShimmerDevice.DatabaseConfigHandle.RAW_AUDIO, + ConfigOptionDetailsSensor.GUI_COMPONENT_TYPE.CHECKBOX, + Arrays.asList(new ShimmerVerObject(HW_ID.SHIMMER_3R, FW_ID.LOGANDSTREAM, 1, 1, 21))); public static final Map mConfigOptionsMapRef; static { @@ -2275,6 +2283,7 @@ public static class CompatibilityInfoForMaps{ CompatibilityInfoForMaps.listOfCompatibleVersionInfoAnyExpBoardAndFw)); aMap.put(Configuration.Shimmer3.GuiLabelConfig.LOW_POWER_AUTOSTOP, configOptionLowPowerAutoStop); + aMap.put(Configuration.Shimmer3.GuiLabelConfig.RAW_AUDIO, configOptionRawAudio); mConfigOptionsMapRef3r = Collections.unmodifiableMap(aMap); } diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java index e606e38ac..30d1b09ef 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java @@ -324,6 +324,7 @@ public static final class DatabaseConfigHandle{ public static final String TRIAL_ID = "Trial_Id"; public static final String N_SHIMMER = "NShimmer"; public static final String LOW_POWER_AUTOSTOP = "Low_Power_Autostop"; + public static final String RAW_AUDIO = "Raw_Audio"; public static final String SHIMMER_VERSION = "Shimmer_Version"; public static final String FW_VERSION = "FW_ID"; diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java index 2679bc312..99bba5bee 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java @@ -574,6 +574,9 @@ public String toString() { private boolean isOverrideShowErrorLedsSd = false; private int mShowErrorLedsSd = 0; private boolean mLowBattAutoStop = false; + private boolean mRawAudio = false; + /** Only internal apps may switch raw audio on; any other app writes it off. */ + private static boolean sIsRawAudioAllowed = false; protected int mTrialId = 0; protected int mTrialNumberOfShimmers = 0; @@ -4989,6 +4992,7 @@ public void setDefaultShimmerConfiguration() { setSingleTouch(false); setTCXO(false); setLowBattAutoStop(false); + setRawAudio(false); setPacketSize(0); mConfigByte0=0; @@ -5160,6 +5164,10 @@ public void configBytesParse(byte[] configBytes, COMMUNICATION_TYPE commType) { if(isVerCompatibleWithAnyOf(Configuration.Shimmer3.configOptionLowPowerAutoStop.mListOfCompatibleVersionInfo)) { setLowBattAutoStop((configBytes[configByteLayoutCast.idxSDExperimentConfig1] >> configByteLayoutCast.bitShiftLowBattStop) & configByteLayoutCast.maskLowBattStop); } + + if(isVerCompatibleWithAnyOf(Configuration.Shimmer3.configOptionRawAudio.mListOfCompatibleVersionInfo)) { + setRawAudio(((configBytes[configByteLayoutCast.idxSDExperimentConfig1] >> configByteLayoutCast.bitShiftRawAudio) & configByteLayoutCast.maskRawAudio) > 0); + } byte[] macIdBytes = new byte[configByteLayoutCast.lengthMacIdBytes]; System.arraycopy(configBytes, configByteLayoutCast.idxMacAddress, macIdBytes, 0 , configByteLayoutCast.lengthMacIdBytes); @@ -5419,6 +5427,10 @@ public byte[] configBytesGenerate(boolean generateForWritingToShimmer, COMMUNICA mConfigBytes[configByteLayoutCast.idxSDExperimentConfig1] |= (byte) ((isLowBattAutoStop()?1:0 & configByteLayoutCast.maskLowBattStop) << configByteLayoutCast.bitShiftLowBattStop); } + if(isVerCompatibleWithAnyOf(Configuration.Shimmer3.configOptionRawAudio.mListOfCompatibleVersionInfo)) { + mConfigBytes[configByteLayoutCast.idxSDExperimentConfig1] |= (byte) ((((sIsRawAudioAllowed && isRawAudio())?1:0) & configByteLayoutCast.maskRawAudio) << configByteLayoutCast.bitShiftRawAudio); + } + if(getFirmwareIdentifier()==FW_ID.LOGANDSTREAM || getFirmwareIdentifier()==FW_ID.SDLOG || getFirmwareIdentifier()==FW_ID.STROKARE) { if(generateForWritingToShimmer) { // MAC address - set to all 0xFF (i.e. invalid MAC) so that Firmware will know to check for MAC from Bluetooth transceiver @@ -6207,6 +6219,18 @@ private boolean isLowBattAutoStop() { return mLowBattAutoStop; } + public void setRawAudio(boolean state) { + mRawAudio = state; + } + + public boolean isRawAudio() { + return mRawAudio; + } + + public static void setRawAudioAllowed(boolean isAllowed) { + sIsRawAudioAllowed = isAllowed; + } + /** * @return the mTrialNumberOfShimmers */ @@ -9735,6 +9759,9 @@ public Object getConfigValueUsingConfigLabel(String identifier, String configLab case(Configuration.Shimmer3.GuiLabelConfig.LOW_POWER_AUTOSTOP): returnValue = isLowBattAutoStop(); break; + case(Configuration.Shimmer3.GuiLabelConfig.RAW_AUDIO): + returnValue = isRawAudio(); + break; case(Configuration.Shimmer3.GuiLabelConfig.BLUETOOTH_BAUD_RATE): returnValue = getBluetoothBaudRate(); @@ -9903,6 +9930,9 @@ public Object setConfigValueUsingConfigLabel(String identifier, String configLab case(Configuration.Shimmer3.GuiLabelConfig.LOW_POWER_AUTOSTOP): setLowBattAutoStop((boolean)valueToSet); break; + case(Configuration.Shimmer3.GuiLabelConfig.RAW_AUDIO): + setRawAudio((boolean)valueToSet && isVerCompatibleWithAnyOf(Configuration.Shimmer3.configOptionRawAudio.mListOfCompatibleVersionInfo)); + break; case(Configuration.Shimmer3.GuiLabelConfig.BLUETOOTH_BAUD_RATE): setBluetoothBaudRate((int)valueToSet); @@ -10151,6 +10181,7 @@ public LinkedHashMap generateConfigMap(COMMUNICATION_TYPE commTy configMapForDb.put(DatabaseConfigHandleShimmerObject.TRIAL_DURATION_MAXIMUM, (double) getTrialDurationMaximumInSecs()); configMapForDb.put(ShimmerDevice.DatabaseConfigHandle.LOW_POWER_AUTOSTOP, (double) (isLowBattAutoStop()? 1:0)); + configMapForDb.put(ShimmerDevice.DatabaseConfigHandle.RAW_AUDIO, (double) (isRawAudio()? 1:0)); //Now handled in the algorithm class in super /** @@ -10200,6 +10231,9 @@ public void parseConfigMap(ShimmerVerObject svo, LinkedHashMap m if(mapOfConfigPerShimmer.containsKey(DatabaseConfigHandle.LOW_POWER_AUTOSTOP)){ setLowBattAutoStop(((Double) mapOfConfigPerShimmer.get(DatabaseConfigHandle.LOW_POWER_AUTOSTOP))>0? true:false); } + if(mapOfConfigPerShimmer.containsKey(DatabaseConfigHandle.RAW_AUDIO)){ + setRawAudio(((Double) mapOfConfigPerShimmer.get(DatabaseConfigHandle.RAW_AUDIO))>0); + } //EXG Configuration byte[] exg1Bytes = SensorEXG.parseExgConfigFromDb(mapOfConfigPerShimmer, EXG_CHIP_INDEX.CHIP1, diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/shimmer2r3/ConfigByteLayoutShimmer3.java b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/shimmer2r3/ConfigByteLayoutShimmer3.java index b9d1aa436..7e10724d4 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/shimmer2r3/ConfigByteLayoutShimmer3.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/shimmer2r3/ConfigByteLayoutShimmer3.java @@ -281,6 +281,9 @@ public class ConfigByteLayoutShimmer3 extends ConfigByteLayout implements Serial public int bitShiftLowBattStop = 0; public int maskLowBattStop = 0x01; + public int bitShiftRawAudio = 1; + public int maskRawAudio = 0x01; + public int bitShiftTCX0 = 4; public int maskTimeTCX0 = 0x01;