Skip to content

Commit a5320a7

Browse files
committed
apps: add Auracast USB sample with LC3 codec
This adds sample that acts as USB sound device. Audio signal is coded using LC3 and broadacasted using Auracast package.
1 parent 65fcd42 commit a5320a7

File tree

9 files changed

+1868
-0
lines changed

9 files changed

+1868
-0
lines changed

apps/auracast_usb/include/tusb_config.h

Lines changed: 445 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef H_USB_AUDIO_
21+
#define H_USB_AUDIO_
22+
23+
#include <stdint.h>
24+
25+
typedef void (* usb_audio_sample_rate_cb_t)(uint32_t);
26+
27+
/* Set default sample rate, should only be used before USB is initialized */
28+
void usb_desc_sample_rate_set(uint32_t sample_rate);
29+
30+
#endif /* H_USB_AUDIO_ */

apps/auracast_usb/pkg.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
pkg.name: apps/auracast_usb
20+
pkg.type: app
21+
pkg.description: Auracast sample application.
22+
23+
pkg.author: "Krzysztof Kopyściński"
24+
pkg.email: "[email protected]"
25+
pkg.homepage: "http://mynewt.apache.org/"
26+
pkg.keywords:
27+
28+
pkg.deps:
29+
- "@apache-mynewt-core/sys/config"
30+
- nimble/host
31+
- nimble/host/util
32+
- nimble/host/services/gap
33+
- nimble/host/store/config
34+
- "@apache-mynewt-core/kernel/os"
35+
- "@apache-mynewt-core/sys/console"
36+
- "@apache-mynewt-core/sys/log"
37+
- "@apache-mynewt-core/sys/stats"
38+
- "@apache-mynewt-core/sys/sysinit"
39+
- "@apache-mynewt-core/sys/id"
40+
- "@apache-mynewt-core/hw/usb/tinyusb"
41+
- "@apache-mynewt-nimble/nimble/host/audio/services/auracast"
42+
- "@apache-mynewt-nimble/ext/liblc3"
43+
- "@apache-mynewt-nimble/ext/libsamplerate"
44+
45+
pkg.init:
46+
audio_usb_init: 402

apps/auracast_usb/src/app_priv.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef H_APP_PRIV_
21+
#define H_APP_PRIV_
22+
23+
#include <syscfg/syscfg.h>
24+
25+
#ifndef MIN
26+
#define MIN(a,b) ((a) < (b) ? (a) : (b))
27+
#endif
28+
29+
#define AUDIO_CHANNELS MYNEWT_VAL(AURACAST_CHAN_NUM)
30+
#define AUDIO_SAMPLE_SIZE sizeof(int16_t)
31+
#define AUDIO_PCM_SAMPLE_RATE MYNEWT_VAL(USB_AUDIO_OUT_SAMPLE_RATE)
32+
33+
#define LC3_FRAME_DURATION (MYNEWT_VAL(LC3_FRAME_DURATION))
34+
#define LC3_SAMPLING_FREQ (MYNEWT_VAL(LC3_SAMPLING_FREQ))
35+
#define LC3_BITRATE (MYNEWT_VAL(LC3_BITRATE))
36+
#define LC3_FPDT (LC3_SAMPLING_FREQ * LC3_FRAME_DURATION / 1000000)
37+
#define BIG_NUM_BIS (MIN(AUDIO_CHANNELS, MYNEWT_VAL(BIG_NUM_BIS)))
38+
39+
struct chan {
40+
void *encoder;
41+
uint16_t handle;
42+
};
43+
44+
extern struct chan chans[AUDIO_CHANNELS];
45+
#endif /* H_APP_PRIV_ */

0 commit comments

Comments
 (0)