Main Content

Bluetooth LE Auracast Broadcast Audio Simulation Using LC3 Encoded Audio

Since R2024b

This example shows how to simulate Bluetooth® low energy (LE) Auracast™ broadcast audio by using low complexity communication codec (LC3) encoded data bytes of an audio file in an audio sharing network scenario.

Using this example, you can:

  • Create, configure, and simulate a Bluetooth LE Auracast broadcast audio network in an audio sharing network scenario.

  • Add application traffic and a custom path loss model between the Bluetooth LE nodes.

  • Transmit the LC3 encoded audio data from the isochronous Broadcaster to the synchronized Receivers.

  • Run the simulation and visualize the packet communication and state transitions of Bluetooth LE nodes over time.

  • Capture and visualize the received LE audio application data at the synchronized Receivers.

  • Retrieve the statistics and key performance indicators (KPIs) at each Receiver.

Optional Product: This example also shows you how to add WLAN signal interference by using WLAN Toolbox™ . For more information, see Add WLAN Signal Interference.

Auracast™ Broadcast Audio

Auracast™, introduced by the Bluetooth Special Interest Group (SIG) [1], facilitates simultaneous audio broadcasting from a single source to multiple listeners. Previously known as Bluetooth audio sharing, Auracast™ enhances personalized listening experiences across diverse environments, including public venues such as museums and airports, as well as private surroundings like gatherings and fitness classes. Auracast™ ensures compatibility with a broad spectrum of devices, enabling extensive adoption. It revolutionizes audio interaction in shared and public spaces by delivering a more inclusive and personalized auditory experience.

The Bluetooth Core Specification 5.4 [2], defined by the Bluetooth Special Interest Group (SIG), enhances LE audio technology by enabling you to broadcast one or more audio streams to an unlimited number of audio receiver nodes in an LE audio network. To implement this functionality, the Bluetooth Core Specification 5.4 [2] defines a new state, isochronous broadcasting, to the link layer (LL) state machine. In the isochronous broadcasting state, the LL transmits the isochronous data packets on an isochronous physical channel. A Bluetooth LE node in the isochronous broadcasting state is called an isochronous Broadcaster.

To realize connectionless broadcast isochronous communication, the Bluetooth Core Specification 5.4 [2] defines broadcast isochronous streams (BIS) and broadcast isochronous group (BIG) events. A BIS is a logical transport that enables a Bluetooth LE node to transfer isochronous data (framed or unframed). A BIG contains one or more BISes that have the same isochronous interval.

For more information about BIS and BIG events, see Bluetooth LE Audio.

LC3 Codec

LE audio includes a new high-quality, low-power codec, known as LC3. It supports a wide range of sample rates, bit rates, and frame rates giving the product developers maximum flexibility to optimize their products to deliver the best possible audio experience to end users. Compared to the subband codec (SBC) implemented by classic audio, LC3 is much more efficient in processing and delivering audio. A comparison between LC3 and SBC related to the standard stereo listening test [1] verifies that LC3 delivers high-quality audio at low data rates. The results in [1] show that even at half of the bit rate, LC3 provides a superior audio experience to SBC. The intrinsic shortcomings of SBC resulted in manufacturers of audio equipment, such as Bluetooth headphones, turning to proprietary solutions such as audio codec 3 (AC3) and AptX. These proprietary solutions need specific hardware support and add costs over standards-based implementations. The introduction of LC3 removes the dependency on proprietary solutions, reducing the manufacturing costs of devices. The high-quality, low-power characteristics of LC3 provide an efficient tradeoff between sound quality and power consumption, enabling the product developers to optimize the longevity of the device battery [4].

Audio Sharing Scenario and Simulation Workflow

This example enables you to create, configure, and simulate this audio sharing scenario in a home environment.

Bluetooth LE Auracast Broadcast Audio Simple Audio Sharing Scenario

The scenario consists of a TV (Auracast transmitter) transmitting a standard quality (SQ) public broadcast audio stream [5] to two headphones (Auracast receivers 1 and 4) and two earphones (Auracast receivers 2 and 3). A WLAN signal acts as interference in the Auracast scenario. This scenario implements a custom home path loss model [8].

This figure shows the complete workflow of this example.

Workflow of Bluetooth LE Auracast Broadcast Audio Simulation with LC3 Encoded Bytes

Check for Support Package Installation

Check if the Communications Toolbox Wireless Network Simulation Library support package is installed. If the support package is not installed, MATLAB® returns an error with a link to download and install the support package.

wirelessnetworkSupportPackageCheck

Load LC3 Encoded Audio Data

Load the LC3 encoded audio packets from the LC3EncodedPackets MAT file. The MAT file includes an audio signal (speech) encoded using the LC3 encoder. According to the configuration specified in Set Name 16_2_1, Table 6.4 in [3] and Set Name 16_2_1, Table 2.4 in [5], the LC3 encoder uses these values to encode the audio packets.

  • Sample rate — 16 KHz.

  • Number of external bytes (nbytes) used to encode the frame for each channel within the audio — 40.

  • Frame duration — 10 ms

This configuration enables the Auracast™ transmitter to send a speech signal in an SQ public broadcast audio stream suited for low-latency applications [5]. Each packet in the MAT file represents a row that contains nbytes bytes of the audio data, using the uint8 data type. Note that this example is designed to support only a mono audio stream.

load("LC3EncodedPackets.mat","lc3EncodedPackets")
nbytes = size(lc3EncodedPackets{1},2);
numPackets = size(lc3EncodedPackets,1);

System-Level Simulation and Results

Set the seed for the random number generator to default to ensure repeatability of results. The seed value controls the pattern of random number generation. For high-fidelity simulation results, change the seed value and average the results over multiple simulations.

rng("default")

Create a wireless network simulator object.

networkSimulator = wirelessNetworkSimulator.init;

Create Broadcaster and Receiver Nodes

Create a Bluetooth LE node, specifying the role as isochronous-broadcaster. Specify the name, position, and transmit power of the isochronous Broadcaster node.

broadcasterNode = bluetoothLENode("isochronous-broadcaster", ...
    Position=[0 0 2], ...                                    % x-, y-, and z- coordinates in meters
    Name="Broadcaster Node", ...
    TransmitterPower=0);                                     % In dBm

Specify the number of receiver nodes and their respective positions.

numReceivers = 4;
receiverPositions = [2 0 2; 3 2 0; 4 5 3; 10 5 1];

Create Bluetooth LE nodes, specifying the roles as synchronized-receiver. Specify the names and positions of the synchronized Receivers.

receiverNodes = bluetoothLENode("synchronized-receiver", ...
    Name="ReceiverNode"+(1:numReceivers), ...
    Position=receiverPositions);

Create Bluetooth LE BIG configuration object. Specify the link layer (LL) parameters for the Auracast broadcast audio stream according to the Set Name 16_2_1 configuration in [2], [3], [5], and [6]. To demonstrate reception failures, set the RepetitionCount to 1. For a better packet delivery ratio (PDR), increase the RepetitionCount value. Specify the SubInterval and BISSpacing values such that the subevents fit within the ISO interval. This example supports only one BIS.

cfgBIG = bluetoothLEBIGConfig( ...
    ISOInterval=0.01, ...           % In seconds
    NumSubevents=5, ...
    BurstNumber=1, ...
    RepetitionCount=1, ...
    PretransmissionOffset=2, ...
    SubInterval=1.03e-3, ...        % In seconds
    BISSpacing=5.15e-3, ...         % In seconds
    MaxPDU=nbytes, ...              % In octets
    NumBIS=1);

Set the BIG offset to initiate a BurstNumber volume of traffic at the beginning of every BIG event.

cfgBIG.BIGOffset = (cfgBIG.ISOInterval/cfgBIG.BurstNumber)*(cfgBIG.BurstNumber>1);

Assign the specified BIG configuration to the Broadcaster and Receiver nodes.

configureBIG(cfgBIG,broadcasterNode,receiverNodes);

Compute the simulation time from the specified BIG configuration and total number of packets.

simulationTime = ceil((cfgBIG.ISOInterval/cfgBIG.BurstNumber)*numPackets);

Create a Bluetooth LE audio network consisting of the Broadcaster and Receiver nodes.

addNodes(networkSimulator,[broadcasterNode receiverNodes])

Add Application Traffic

Create periodic application traffic with LC3 encoded data by using the helperPeriodicNetworkTraffic helper object. Configure the periodic application traffic pattern by specifying the application periodicity, packet size, and application data. Set the periodicity for sending the number of payloads associated with this BIS event. To achieve periodic transmission, configure the system to send a specified number of packets for each BIS event. Increase the periodicity to enable PTO transmissions, enabling the system to send future voice packets in previous BIG events. Add application traffic to the Broadcaster.

traffic = helperPeriodicNetworkTraffic( ...
    Periodicity=cfgBIG.ISOInterval/cfgBIG.BurstNumber, ...
    PacketSize=nbytes, ...
    ApplicationData=[lc3EncodedPackets{:,1}]);
addTrafficSource(broadcasterNode,traffic)

Setup LE Audio Data Reception

To capture the received application layer (APP) packets, create a helperReceiveAppData helper object for each Receiver. The ReceivedPackets property of the helperReceiveAppData helper object stores the received application packets according to the payload numbers.

receivedAudioData = helperReceiveAppData(receiverNodes,numPackets);

Add WLAN Signal Interference

To add WLAN signal interference, set the enableWLANInterference flag to true.

enableWLANInterference = true;

Specify the source of WLAN interference by using one of these options.

  • "Generated" — To add a WLAN Toolbox™ signal to interfere with the communication between Bluetooth LE nodes, select this option.

  • "BasebandFile" — To add a WLAN signal from a baseband file with the.bb extension to interfere with the communication between Bluetooth nodes. You can specify the filename using the BasebandFile input argument of the helperInterferingWLANNode helper object . If you do not specify a baseband file, the example adds the default file WLANHESUBandwidth20.bb to the WLAN signal.

To add WLAN interference in the network, create a WLAN node by using the helperInterferingWLANNode helper object.

if enableWLANInterference
    interferingWlanNode = helperInterferingWLANNode;
    interferingWlanNode.WaveformSource = "BasebandFile";
    interferingWlanNode.Name = "WLAN node";
    interferingWlanNode.Position = [12 5 2];               % x-, y-, and z- coordinates in meters
    interferingWlanNode.TransmitterPower = 20;             % In dBm
    interferingWlanNode.CenterFrequency = 2.442e9;         % In Hz
    interferingWlanNode.Bandwidth = 20e6;                  % In Hz
    interferingWlanNode.SignalPeriodicity = 0.0029;        % In seconds
    addNodes(networkSimulator,interferingWlanNode)
end

Add Custom Path Loss Model

To add a custom path loss model, enable the enableCustomPathloss flag. If you set this flag to false, the example uses the free-space path loss model.

enableCustomPathloss = true;

To determine the path loss between the nodes, this example uses the NIST PAP02-Task 6 [8] path loss model.

Create a path loss model by using the bluetoothPathLossConfig object and bluetoothPathLoss function. Set the signal propagation environment to home. The applyPathLoss function creates a path loss model function handle. Add the path loss model to the network simulator by using the addChannelModel object function. This custom path loss model is applicable for only the 2.4 GHz frequency band.

if enableCustomPathloss
    pathlossCfg = bluetoothPathLossConfig(Environment="Home");
    pathlossHandle = @(rxInfo,txData) applyPathLoss(rxInfo,txData,pathlossCfg); % Path loss function
    addChannelModel(networkSimulator,pathlossHandle)
end

Visualize Packet Communication

To visualize packet communication in the network, set the enablePacketVisualization flag to true. The visualization shows the packet communication and state transitions of Bluetooth LE nodes over time. At the end of the simulation, you can visualize packets at any time instance.

enablePacketVisualization = true;

Initialize the visualization by using the helperPlotPacketTransitions helper object.

if enablePacketVisualization
    helperPlotPacketTransitions(networkSimulator.Nodes,simulationTime);
end

Run the Simulation

Run the simulation for the calculated simulation time.

run(networkSimulator,simulationTime)

Figure Packet Communication Over Time And Frequency contains 2 axes objects and another object of type uigridlayout. Axes object 1 with title Packet Communication over Frequency, xlabel Time (seconds), ylabel Frequency (MHz) contains 3 objects of type patch, constantline. Axes object 2 with title State Transitions of Nodes, xlabel Time (seconds), ylabel Node Names contains 4 objects of type patch, constantline.

Results

Retrieve the statistics of all the Bluetooth nodes. For more information about the statistics, see Bluetooth LE Node Statistics.

broadcasterStats = statistics(broadcasterNode);
receiverStats = statistics(receiverNodes);

Compute the KPIs, such as packet delivery ratio (PDR) and APP latency (in seconds), by using the kpi object function of the bluetoothLENode object.

pdr = kpi(broadcasterNode,receiverNodes,"PDR",Layer="App")
pdr = 1×4

    1.0000    0.9124    0.8144    0.7887

latency = kpi(broadcasterNode,receiverNodes,"latency",Layer="App")
latency = 1×4
10-3 ×

    0.4010    0.4010    0.4010    0.4010

Visualize Received LE Audio Application Data

Retreive the received LC3 encoded application data at the Receivers.

receivedPackets = [receivedAudioData.ReceivedPacket];

Visualize the packets lost during communication and their corresponding packet loss ratio (PLR) at each Receiver node. The visualization contains plots that display the packets not received at the APP and the PLR, respectively, at each Receiver node. To view the lost packet number for a point in the scatter plot, click it. The plot shows the packets that fail to reach the APP, and assumes all other packets reached the APP successfully. WLAN interference and channel conditions affect Bluetooth LE communication, causing packet loss at the Receiver. Adjust node positions or power to observe their impact on packet reception.

helperReceiveAppData.visualizeLostPacketsAndPLR(broadcasterNode,receiverNodes,receivedPackets)

Figure Visualize Lost Packets And PLR contains 2 axes objects. Axes object 1 with title APP Packets Lost At Each Receiver, xlabel Packet Numbers, ylabel Receiver Node Name contains 4 objects of type scatter. Axes object 2 with title APP Packet Loss Ratio At Each Receiver, xlabel Receiver Node Name, ylabel PLR contains an object of type bar.

Further Exploration

You can use this example to further explore these capabilities.

Simulate a Bluetooth LE Connected Isochronous Stream (CIS) Network Using LC3 Encoded Audio Data

You can simulate a Bluetooth LE audio CIS network with LC3 encoded audio data and retrieve statistics such as PDR, PLR, latency, and throughput. To simulate the CIS network, uncomment this code and run the below example script.

% helperSimulateLEMultiStreamWithEncodedAudioData

Appendix

The example uses these helpers:

  • helperInterferingWLANNode — Configure and simulate interfering WLAN node.

  • helperPlotPacketTransitions — Visualize the state transition for all the nodes and the coexistence of packets.

  • helperPeriodicNetworkTraffic — Configure and generate periodic application traffic pattern.

  • helperReceiveAppData — Initialize and store LE audio application data received in each node.

  • helperSimulateLEMultiStreamWithEncodedAudioData — Simulate a Bluetooth LE audio CIS network with encoded audio data.

References

[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology”. Accessed June 01, 2024. https://www.bluetooth.com/.

[2] Bluetooth Core Specifications Working Group. "Bluetooth Core Specification" v5.4. Accessed June 01, 2024. https://www.bluetooth.com/specifications/specs/.

[3] Generic Audio Working Group. "Basic Audio Profile" v1.0.1. Accessed June 01, 2024. https://www.bluetooth.com/specifications/specs/.

[4] Low Complexity Communication Codec. Accessed June 01, 2024. https://www.bluetooth.com/specifications/specs/.

[5] Auracast™ Simple Transmitter Best Practices Guide. Accessed June 01, 2024. https://www.bluetooth.com/bluetooth-resources/auracast-simple-transmitter-best-practices-guide/.

[6] How to Build an Auracast™ Transmitter. Accessed June 01, 2024. https://www.bluetooth.com/bluetooth-resources/how-to-build-an-auracast-transmitter/.

[7] How to Design Auracast™ Earbuds. Accessed June 01, 2024. https://www.bluetooth.com/bluetooth-resources/how-to-design-auracast-earbuds/.

[8] NIST Smart Grid Interoperability Panel Priority Action Plan 2: Guidelines for Assessing Wireless Standards for Smart Grid Applications. National Institute of Standards and Technology, U.S. Department of Commerce, 2014.

Local Functions

Custom Path Loss Model

Create a custom path loss model by using the bluetoothPathLoss function, and attach it to the wireless network simulator.

function rxData = applyPathLoss(rxInfo,txData,pathlossCfg)

    % Apply path loss and update output signal
    rxData = txData;
    % Calculate distance between transmitter and receiver in meters
    distance = norm(rxData.TransmitterPosition - rxInfo.Position);
    pathloss = bluetoothPathLoss(distance,pathlossCfg);
    rxData.Power = rxData.Power-pathloss;                           % In dBm
    scale = 10.^(-pathloss/20);
    [numSamples,~] = size(rxData.Data);
    rxData.Data(1:numSamples,:) = rxData.Data(1:numSamples,:)*scale;
end

See Also

Objects

Related Topics