Skip to content

Commit ea7f924

Browse files
Improved WavPlayer and Extra Utilities (#677)
* working on WAV playback improvements within example before transplanting into the lib * integrated new WavPlayer, WavParser, FileReader, and FileTable into library (minor whitespace changes to a few aux. files, and vscode config) * added FileReader FileTable WavParser and WavPlayer to util folder. * update namespaces for objects that moved into lib * fixed style issues, and Makefile build to always include FatFS FileReader * cmake: removed old wavplayer src file, and added define for FATFS FileReader * Added example for FileTable, and fixed a bug with endswith behavior. * simplified WavPlayer example to be a basic looping demo, and reduced loop.wav size to 1s of audio * added some basic usage for the FileTable example * fixed styling, and added WavParser example.
1 parent c6887c6 commit ea7f924

File tree

23 files changed

+1747
-422
lines changed

23 files changed

+1747
-422
lines changed

.vscode/launch.json

Lines changed: 92 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,93 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"name": "Launch Tests Locally",
6-
"type": "cppdbg",
7-
"request": "launch",
8-
"program": "${workspaceFolder}/tests/build/bin/libDaisy_gtest",
9-
"stopAtEntry": false,
10-
"cwd": "${workspaceFolder}/tests/build/bin",
11-
"environment": [],
12-
"externalConsole": false,
13-
"logging": {
14-
"engineLogging": false
15-
},
16-
"preLaunchTask": "build-libDaisy-tests",
17-
"osx": {
18-
"MIMode": "lldb",
19-
},
20-
"windows": {
21-
"MIMode": "gdb",
22-
}
23-
},
24-
{
25-
"name": "Debug",
26-
"configFiles": [
27-
"interface/stlink.cfg",
28-
"target/stm32h7x.cfg"
29-
],
30-
"cwd": "${workspaceFolder}",
31-
"debuggerArgs": [
32-
"-d",
33-
"${workspaceRoot}"
34-
],
35-
// Here's where you can put the path to the program you want to debug:
36-
//"executable": "${workspaceRoot}/examples/SDMMC_HelloWorld/build/SDMMC_HelloWorld.elf",
37-
"executable": "${workspaceRoot}/examples/uart/Dma_Receive/build/Dma_Receive.elf",
38-
"interface": "swd",
39-
"openOCDLaunchCommands": [
40-
"init",
41-
"reset init",
42-
"gdb_breakpoint_override hard"
43-
],
44-
"preRestartCommands": [
45-
"load",
46-
"enable breakpoint",
47-
"monitor reset"
48-
],
49-
"request": "launch",
50-
"runToEntryPoint": "true",
51-
"servertype": "openocd",
52-
"showDevDebugOutput": "none",
53-
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
54-
"type": "cortex-debug"
55-
}
56-
]
57-
}
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch Tests Locally",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/tests/build/bin/libDaisy_gtest",
9+
"stopAtEntry": false,
10+
"cwd": "${workspaceFolder}/tests/build/bin",
11+
"environment": [],
12+
"externalConsole": false,
13+
"logging": {
14+
"engineLogging": false
15+
},
16+
"preLaunchTask": "build-libDaisy-tests",
17+
"osx": {
18+
"MIMode": "lldb",
19+
},
20+
"windows": {
21+
"MIMode": "gdb",
22+
}
23+
},
24+
{
25+
"name": "Debug",
26+
"configFiles": [
27+
"interface/stlink.cfg",
28+
"target/stm32h7x.cfg"
29+
],
30+
"cwd": "${workspaceFolder}",
31+
"debuggerArgs": [
32+
"-d",
33+
"${workspaceRoot}"
34+
],
35+
// Here's where you can put the path to the program you want to debug:
36+
//"executable": "${workspaceRoot}/examples/SDMMC_HelloWorld/build/SDMMC_HelloWorld.elf",
37+
"executable": "${workspaceRoot}/examples/uart/Dma_Receive/build/Dma_Receive.elf",
38+
"interface": "swd",
39+
"openOCDLaunchCommands": [
40+
"init",
41+
"reset init",
42+
"gdb_breakpoint_override hard"
43+
],
44+
"preRestartCommands": [
45+
"load",
46+
"enable breakpoint",
47+
"monitor reset"
48+
],
49+
"request": "launch",
50+
"runToEntryPoint": "true",
51+
"servertype": "openocd",
52+
"showDevDebugOutput": "none",
53+
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
54+
"type": "cortex-debug"
55+
},
56+
{
57+
"name": "Debug (J-Link)",
58+
"cwd": "${workspaceRoot}",
59+
"device": "STM32H750IB",
60+
"executable": "${workspaceRoot}/examples/WavPlayer/build/WavPlayer.elf",
61+
"interface": "swd",
62+
"osx": {
63+
"armToolchainPath": "/Applications/ArmGNUToolchain/12.3.rel1/arm-none-eabi/bin",
64+
"serverpath": "/Applications/SEGGER/JLink/JLinkGDBServerCLExe"
65+
},
66+
// "preLaunchTask": "Build Project",
67+
"request": "launch",
68+
"rttConfig": {
69+
"address": "auto",
70+
"decoders": [
71+
{
72+
"port": 0.000000,
73+
"type": "console"
74+
}
75+
],
76+
"enabled": true
77+
},
78+
"runToEntryPoint": "main",
79+
"serialNumber": "",
80+
"servertype": "jlink",
81+
"svdFile": "${workspaceFolder}/.vscode/STM32H750x.svd",
82+
"type": "cortex-debug",
83+
"liveWatch": {
84+
"enabled": true,
85+
"samplesPerSecond": 4
86+
},
87+
"windows": {
88+
"armToolchainPath": "${workspaceFolder}/tools/cortex_m_gcc13_win/bin",
89+
"serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL.exe"
90+
}
91+
},
92+
]
93+
}

.vscode/settings.json

Lines changed: 107 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,108 @@
11
{
2-
"cortex-debug.enableTelemetry": false,
3-
"files.associations": {
4-
"*.tcc": "cpp",
5-
"unordered_map": "cpp",
6-
"fstream": "cpp",
7-
"istream": "cpp",
8-
"numeric": "cpp",
9-
"ostream": "cpp",
10-
"sstream": "cpp",
11-
"array": "cpp",
12-
"atomic": "cpp",
13-
"bit": "cpp",
14-
"cctype": "cpp",
15-
"clocale": "cpp",
16-
"cmath": "cpp",
17-
"cstdarg": "cpp",
18-
"cstddef": "cpp",
19-
"cstdint": "cpp",
20-
"cstdio": "cpp",
21-
"cstdlib": "cpp",
22-
"cstring": "cpp",
23-
"cwchar": "cpp",
24-
"cwctype": "cpp",
25-
"deque": "cpp",
26-
"vector": "cpp",
27-
"exception": "cpp",
28-
"algorithm": "cpp",
29-
"functional": "cpp",
30-
"iterator": "cpp",
31-
"memory": "cpp",
32-
"memory_resource": "cpp",
33-
"optional": "cpp",
34-
"random": "cpp",
35-
"string": "cpp",
36-
"string_view": "cpp",
37-
"system_error": "cpp",
38-
"tuple": "cpp",
39-
"type_traits": "cpp",
40-
"utility": "cpp",
41-
"initializer_list": "cpp",
42-
"iosfwd": "cpp",
43-
"limits": "cpp",
44-
"new": "cpp",
45-
"stdexcept": "cpp",
46-
"streambuf": "cpp",
47-
"typeinfo": "cpp",
48-
"complex": "cpp",
49-
"bitset": "cpp",
50-
"cinttypes": "cpp",
51-
"ctime": "cpp",
52-
"iomanip": "cpp",
53-
"iostream": "cpp",
54-
"any": "cpp",
55-
"chrono": "cpp",
56-
"condition_variable": "cpp",
57-
"forward_list": "cpp",
58-
"list": "cpp",
59-
"map": "cpp",
60-
"set": "cpp",
61-
"unordered_set": "cpp",
62-
"ratio": "cpp",
63-
"regex": "cpp",
64-
"shared_mutex": "cpp",
65-
"variant": "cpp"
66-
},
67-
"editor.tokenColorCustomizations": {
68-
"textMateRules": [
69-
{
70-
"scope": "googletest.failed",
71-
"settings": {
72-
"foreground": "#f00"
73-
}
74-
},
75-
{
76-
"scope": "googletest.passed",
77-
"settings": {
78-
"foreground": "#0f0"
79-
}
80-
},
81-
{
82-
"scope": "googletest.run",
83-
"settings": {
84-
"foreground": "#0f0"
85-
}
86-
}
87-
]
88-
},
89-
"testMate.cpp.test.executables": "tests/build/bin/*",
90-
"cmake.sourceDirectory": [
91-
"${workspaceFolder}",
92-
"${workspaceFolder}/tests",
93-
],
94-
"cmake.buildDirectory": "${sourceDirectory}/build",
95-
}
2+
"cortex-debug.enableTelemetry": false,
3+
"files.associations": {
4+
"*.tcc": "cpp",
5+
"unordered_map": "cpp",
6+
"fstream": "cpp",
7+
"istream": "cpp",
8+
"numeric": "cpp",
9+
"ostream": "cpp",
10+
"sstream": "cpp",
11+
"array": "cpp",
12+
"atomic": "cpp",
13+
"bit": "cpp",
14+
"cctype": "cpp",
15+
"clocale": "cpp",
16+
"cmath": "cpp",
17+
"cstdarg": "cpp",
18+
"cstddef": "cpp",
19+
"cstdint": "cpp",
20+
"cstdio": "cpp",
21+
"cstdlib": "cpp",
22+
"cstring": "cpp",
23+
"cwchar": "cpp",
24+
"cwctype": "cpp",
25+
"deque": "cpp",
26+
"vector": "cpp",
27+
"exception": "cpp",
28+
"algorithm": "cpp",
29+
"functional": "cpp",
30+
"iterator": "cpp",
31+
"memory": "cpp",
32+
"memory_resource": "cpp",
33+
"optional": "cpp",
34+
"random": "cpp",
35+
"string": "cpp",
36+
"string_view": "cpp",
37+
"system_error": "cpp",
38+
"tuple": "cpp",
39+
"type_traits": "cpp",
40+
"utility": "cpp",
41+
"initializer_list": "cpp",
42+
"iosfwd": "cpp",
43+
"limits": "cpp",
44+
"new": "cpp",
45+
"stdexcept": "cpp",
46+
"streambuf": "cpp",
47+
"typeinfo": "cpp",
48+
"complex": "cpp",
49+
"bitset": "cpp",
50+
"cinttypes": "cpp",
51+
"ctime": "cpp",
52+
"iomanip": "cpp",
53+
"iostream": "cpp",
54+
"any": "cpp",
55+
"chrono": "cpp",
56+
"condition_variable": "cpp",
57+
"forward_list": "cpp",
58+
"list": "cpp",
59+
"map": "cpp",
60+
"set": "cpp",
61+
"unordered_set": "cpp",
62+
"ratio": "cpp",
63+
"regex": "cpp",
64+
"shared_mutex": "cpp",
65+
"variant": "cpp",
66+
"__bit_reference": "cpp",
67+
"__config": "cpp",
68+
"__hash_table": "cpp",
69+
"__locale": "cpp",
70+
"__node_handle": "cpp",
71+
"__tree": "cpp",
72+
"compare": "cpp",
73+
"__memory": "cpp",
74+
"filesystem": "cpp",
75+
"ios": "cpp",
76+
"locale": "cpp",
77+
"mutex": "cpp",
78+
"__split_buffer": "cpp"
79+
},
80+
"editor.tokenColorCustomizations": {
81+
"textMateRules": [
82+
{
83+
"scope": "googletest.failed",
84+
"settings": {
85+
"foreground": "#f00"
86+
}
87+
},
88+
{
89+
"scope": "googletest.passed",
90+
"settings": {
91+
"foreground": "#0f0"
92+
}
93+
},
94+
{
95+
"scope": "googletest.run",
96+
"settings": {
97+
"foreground": "#0f0"
98+
}
99+
}
100+
]
101+
},
102+
"testMate.cpp.test.executables": "tests/build/bin/*",
103+
"cmake.sourceDirectory": [
104+
"${workspaceFolder}",
105+
"${workspaceFolder}/tests",
106+
],
107+
"cmake.buildDirectory": "${sourceDirectory}/build",
108+
}

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ add_library(daisy STATIC
6868
${MODULE_DIR}/hid/usb_host.cpp
6969
${MODULE_DIR}/hid/usb_midi.cpp
7070
${MODULE_DIR}/hid/usb.cpp
71-
${MODULE_DIR}/hid/wavplayer.cpp
7271
${MODULE_DIR}/per/adc.cpp
7372
${MODULE_DIR}/per/dac.cpp
7473
${MODULE_DIR}/per/gpio.cpp
@@ -115,6 +114,11 @@ target_link_libraries(daisy PUBLIC
115114
FatFs
116115
)
117116

117+
# There is a abstract `IReader` interface that allows that can be swappped out
118+
# for other i/o, but libDaisy assumes FatFS will always be present.
119+
# It may make sense for this to move to better facillitate testing, etc.
120+
add_compile_definitions(FILEIO_ENABLE_FATFS_READER)
121+
118122
target_compile_options(daisy PRIVATE
119123
-Wall
120124

@@ -126,13 +130,15 @@ target_compile_options(daisy PRIVATE
126130
$<$<CXX_COMPILER_ID:GNU>:-Wno-missing-attributes>
127131
)
128132

133+
129134
set_target_properties(daisy PROPERTIES
130135
CXX_STANDARD 14
131136
CXX_STANDARD_REQUIRED
132137
C_STANDARD 11
133138
C_STANDARD_REQUIRED
134139
)
135140

141+
136142
# Don't add examples if we're being included in another project
137143
if(PROJECT_IS_TOP_LEVEL)
138144
add_subdirectory(examples EXCLUDE_FROM_ALL)

0 commit comments

Comments
 (0)