Skip to content

Commit c9fcfd8

Browse files
committed
Move private headers to "internal", document that.
1 parent fec5394 commit c9fcfd8

24 files changed

+79
-20
lines changed

Mozzi.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Mozzi.h
3+
*
4+
* Copyright 2023, Thomas Combriat and the Mozzi team
5+
*
6+
* This file is part of Mozzi.
7+
*
8+
* Mozzi is licensed under a Creative Commons
9+
* Attribution-NonCommercial-ShareAlike 4.0 International License.
10+
*
11+
*/
12+
13+
/** @ingroup core
14+
* @file Mozzi.h
15+
*
16+
* This is the main include file in Mozzi. Almost all sketches using Mozzi will want to include this file @em exactly once.
17+
*
18+
* Should your sketch require \ref core Mozzi functions in more than one translation unit (i.e. you have more than one .cpp-file
19+
* in your sketch itself), only *one* of these shall include this file, while any others shall include \ref MozziHeadersOnly instead.
20+
* (Failing to heed this advice will lead to "duplicate definition" errors.)
21+
*/
22+
23+
#ifndef MOZZI_H_
24+
#define MOZZI_H_
25+
26+
#include "MozziGuts.h"
27+
28+
#endif

MozziGuts.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
#ifndef MOZZIGUTS_H_
1313
#define MOZZIGUTS_H_
1414

15-
#include "Arduino.h"
15+
#include "Arduino.h"
16+
17+
#include "MozziConfigValues.h"
18+
19+
#if !(defined(MOZZI_H_) || defined(MOZZI_HEADERS_ONLY_H_))
20+
#warning Direct inclusion of MozziGuts.h is deprecated. Use Mozzi.h, instead, and read about porting to Mozzi 2.0
21+
#define MOZZI_COMPATIBILITY_LEVEL MOZZI_COMPATIBILITY_1_1
22+
#endif
1623

1724
#include "hardware_defines.h"
1825
#include "mozzi_config.h"
@@ -82,7 +89,7 @@ forked version of Mozzi on github, so sound production can continue while
8289
reading sensors.
8390
8491
As it is, stopMozzi restores all the Timers used by Mozzi to their previous
85-
settings. Another scenario which could be easily hacked in MozziGuts.cpp could
92+
settings. Another scenario which could be easily hacked in MozziGuts.hpp could
8693
involve individually saving and restoring particular Timer registers depending
8794
on which one(s) are required for other tasks.
8895
@@ -173,8 +180,8 @@ is output, so the resolution is 1/AUDIO_RATE microseconds (61 microseconds when
173180
*/
174181
unsigned long mozziMicros();
175182

176-
#ifndef MOZZI_HEADER_ONLY
177-
#include "MozziGuts.hpp"
183+
#ifndef _MOZZI_HEADER_ONLY
184+
#include "internal/MozziGuts.hpp"
178185
#endif
179186

180187
#endif /* MOZZIGUTS_H_ */

MozziHeadersOnly.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Mozzi.h
3+
*
4+
* Copyright 2023, Thomas Combriat and the Mozzi team
5+
*
6+
* This file is part of Mozzi.
7+
*
8+
* Mozzi is licensed under a Creative Commons
9+
* Attribution-NonCommercial-ShareAlike 4.0 International License.
10+
*
11+
*/
12+
13+
/** @ingroup core
14+
* @file MozziHeadersOnly.h
15+
*
16+
* This file provides declarations of the \ref core Mozzi functions, but no implementation. Use this only, if you have more than one
17+
* translation unit in your project (i.e. you have more than one .cpp-file in your sketch itself). Otherwise include \ref Mozzi.h, instead.
18+
*
19+
* (Failure to head this advice will lead to "symbol XY undefined" errors.).
20+
*/
21+
22+
#ifndef MOZZI_HEADERS_ONLY_H_
23+
#define MOZZI_HEADERS_ONLY_H_
24+
25+
#define _MOZZI_HEADER_ONLY
26+
#include "MozziGuts.h"
27+
28+
#endif

Readme_Mozzi_2_0.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ all new
2828
general:
2929
- Added many config sanity checks. Some may be too strict, if so please mention
3030

31-
Other removed stuff:
31+
Other removed stuff:
3232
- pauseMozzi() - was still declared but not defined -> not usable, anyway
3333
- unpauseMozzi() - was still declared but not defined -> not usable, anyway
3434
- Teensy3/4: channel2sc1a -> thought to be unused, removed
3535
- Teensy2: adc_mapping -> hidden away; use adcPinToChannelNum(), as on all other platforms, instead
36+
- removed inclusion of "WProgram.h". If using Arduino versions < 1.0, you need to update, seriously ;-)
37+
38+
Moved headers:
39+
- Header files not meant for user inclusion have been moved to "internal"
40+
- New sketches should include "Mozzi.h", rather than "MozziGuts.h", thereby documenting, they have been written for Mozzi 2.0+
3641

3742
Documentation bits that still need to find a new home (many other bits were moved around, many, many duplicates merged into a common place, and seom obsoleted bits discarded):
3843

examples/01.Basics/Skeleton_Multi/Skeleton_Multi.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Unless you have good reason to do this, it is recommended to base your sketch on the
55
* single-file "Skeleton" example, instead. */
66

7-
#include <MozziGuts.h> // at the top of your sketch
7+
#include <Mozzi.h> // at the top of your sketch
88

99
void setup() {
1010
startMozzi(64);

examples/01.Basics/Skeleton_Multi/Skeleton_Multi_Unit2.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// This file, too, will have to include the Mozzi headers, but in order to avoid "multiple definition" errors,
2-
// all secondary .cpp files in the sketch must set MOZZI_HEADER_ONLY before including any Mozzi headers.
3-
// TODO: Maybe that is not even the final word, and this will be required in the end, but it seems a useful intermediate step
4-
#define MOZZI_HEADER_ONLY
5-
#include <MozziGuts.h>
1+
#include <MozziHeadersOnly.h> // <Mozzi.h> should be included only once in the whole program. Sketches needing
2+
// core Mozzi functions in more than one .cpp file, shall include MozziHeadersOnly.h
3+
// in all but one.
64

75
AudioOutput_t updateAudio() {
86
return MonoOutput::from8Bit(0); // just a dummy
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)