nybble: Get the high or low nybble of a raw value

View source: R/01supporting_functions.r

nybbleR Documentation

Get the high or low nybble of a raw value

Description

Get the high or low nybble of a raw value and return as integer value [0,15].

Usage

nybble(raw_dat, which = c("low", "high"))

loNybble(raw_dat)

hiNybble(raw_dat)

Arguments

raw_dat

A vector of class raw from which the high or low nybble value needs to be extracted.

which

A character string indicating whether the high or low nybble should be returnd. It should either be "low" (default) or "high".

Details

A raw is basically a byte, composed of 8 bits (zeros and ones). A nybble is a 4 bit value. Hence, a raw value (or byte) is composed of two nybbles. The leftmost nybble of a raw value is refered to as the high nybble, the rightmost nybble is referred to as the low nybble. These functions return either the high or low nybbles of raw data as integer values [0,15]. As ProTracker stores some information as nybbles this function can be used to retrieve this info.

Value

A vector of the same length as raw_dat holding integer values.

Author(s)

Pepijn de Vries

See Also

Other nybble.functions: nybbleToSignedInt(), signedIntToNybble()

Other raw.operations: as.raw(), nybbleToSignedInt(), rawToCharNull(), rawToPTModule(), rawToSignedInt(), rawToUnsignedInt(), signedIntToNybble(), signedIntToRaw(), unsignedIntToRaw()

Other integer.operations: nybbleToSignedInt(), rawToSignedInt(), rawToUnsignedInt(), signedIntToNybble(), signedIntToRaw(), unsignedIntToRaw(), waveform()

Examples

## this will return 0x0f:
hiNybble(as.raw(0xf3))

## which is the same as:
nybble(as.raw(0xf3), "high")

## this will return 0x03:
loNybble(as.raw(0xf3))

## which is the same as:
nybble(as.raw(0xf3), "low")

ProTrackR documentation built on Aug. 23, 2023, 1:07 a.m.