Skip to content

Commit e09deca

Browse files
authored
Merge pull request #34 from gpstar81/v109
Rapid Track System
2 parents 6a4500c + c23f1dd commit e09deca

6 files changed

Lines changed: 47 additions & 5 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ Example code to demonstrate some of the GPStar Audio's features can be found in
4747

4848
**GPStarAudio.trackPlayPoly(uint16_t trk, bool lock, uint16_t i_trk_start_delay, uint16_t trk2, bool loop_trk2, uint16_t trk2_start_time)** - Same as above with the following addition: Setting `trk2` allows you to "queue" a second audio file to play once the first finishes playing, allowing seamless transition between tracks. `loop_trk2` defines whether the second track will loop forever, and `trk2_start_time` specifies how many milliseconds before the end of the first track the second track will begin playing. `Requires GPStar Audio Firmware v1.04 or higher.`
4949

50+
**GPStarAudio.trackRapidPlay(uint16_t trk, uint16_t i_rapid_delay)** - This will tell GPStar Audio to take two channels with the same track, locks them and sets them to repeat. The first channel plays first and when the rapid delay timer ends, it will trigger the second channel to start playing, while channel 1 still continues to play. When the timer for channel 2 ends, it will tell channel 1 to rewind and play again. This process will continue until you tell the track to stop or turn off track looping for the track which allows the channels to finish playing out. `Requires GPStar Audio Firmware v1.09 or higher.`
51+
52+
**GPStarAudio.trackRapidDelay(uint16_t trk, uint16_t i_rapid_delay)** - This updates the rapid delay timers for the track that is using trackRapidPlay. `Requires GPStar Audio Firmware v1.09 or higher.`
53+
5054
**GPStarAudio.trackQueueClear()** - If `GPStarAudio.trackPlaySolo()` or `GPStarAudio.trackPlayPoly()` are called with the `trk2` parameters, calling this afterwards will clear out the queue to prevent the second track from playing when the first track finishes playback. `Requires GPStar Audio Firmware v1.04 or higher.`
5155

5256
**GPStarAudio.trackStop(uint16_t trk)** - This stops the provided track number if it is currently playing and frees the channel it was using.
@@ -106,6 +110,8 @@ Example code to demonstrate some of the GPStar Audio's features can be found in
106110

107111
**GPStarAudio.getVersion(char\* version)** - Returns a `bool` for whether the `RSP_VERSION_STRING` packet was received. Pass a `char` array of size `VERSION_STRING_LEN` as the parameter to store the version string value. `This is no longer used by GPStar Audio.`
108112

113+
**GPStarAudio.setTriggerBank(uint8_t bank)** - Provided for backwards compatibility with existing polyphonic audio boards, but has no effect on GPStar Audio (which does not support creation of audio banks).
114+
109115
## <img src='images/gpstar_logo.png' width=50 align="left"/>GPStar Audio - Connection Details
110116

111117
![](images/GPStarAudioPCB.png)

examples/BasicExample/BasicExample.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void setup() {
4545
delay(1000);
4646

4747
// Please note: GPStar Audio uses 57600 baudrate by default. You can configure this by adding the setting to the Micro SD Card ini configuration file. Please see the README.MD file for more information.
48-
4948
altSerial.begin(57600); // When using AltSoftSerial.
5049
gpstar.start(altSerial);
5150

@@ -57,7 +56,7 @@ void setup() {
5756
// Allow time for hello command and other data to respond.
5857
gpstar.hello();
5958

60-
delay(400);
59+
delay(500);
6160

6261
if(gpstar.gpstarAudioHello()) {
6362
// Stop all tracks.
@@ -70,7 +69,7 @@ void setup() {
7069
}
7170
}
7271

73-
void loop() {
72+
void loop() {
7473
if(b_gpstar_audio_found == true) {
7574
// Play track 1 at 100% volume and set it to loop.
7675
gpstar.trackGain(1, 0);
@@ -95,6 +94,7 @@ void loop() {
9594

9695
// Pause track 1
9796
gpstar.trackPause(1);
97+
9898
delay(5000);
9999

100100
// Stop track 2

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "GPStar Audio Serial Library",
3-
"version": "1.3.4",
3+
"version": "1.3.5",
44
"description": "A serial communication control library for the GPStar Audio and GPStar Audio XL series of audio boards from GPStar Technologies.",
55
"keywords": "audio, serial, music, wav",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=GPStar Audio Serial Library
2-
version=1.3.4
2+
version=1.3.5
33
author=Michael Rajotte
44
license=GPL-3.0-or-later
55
maintainer=Michael Rajotte <michael.rajotte@gpstartechnologies.com>

src/GPStarAudio.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,38 @@ void gpstarAudio::trackLoop(uint16_t trk, bool enable) {
359359
}
360360
}
361361

362+
void gpstarAudio::trackRapidPlay(uint16_t trk, uint16_t i_rapid_delay) {
363+
uint8_t txbuf[10];
364+
365+
txbuf[0] = SOM1;
366+
txbuf[1] = SOM2;
367+
txbuf[2] = 0x0a;
368+
txbuf[3] = CMD_TRACK_CONTROL;
369+
txbuf[4] = TRK_RAPID_PLAY;
370+
txbuf[5] = (uint8_t)trk;
371+
txbuf[6] = (uint8_t)(trk >> 8);
372+
txbuf[7] = (uint8_t)i_rapid_delay;
373+
txbuf[8] = (uint8_t)(i_rapid_delay >> 8);
374+
txbuf[9] = EOM;
375+
GPStarSerial->write(txbuf, 10);
376+
}
377+
378+
void gpstarAudio::trackRapidDelay(uint16_t trk, uint16_t i_rapid_delay) {
379+
uint8_t txbuf[10];
380+
381+
txbuf[0] = SOM1;
382+
txbuf[1] = SOM2;
383+
txbuf[2] = 0x0a;
384+
txbuf[3] = CMD_TRACK_CONTROL;
385+
txbuf[4] = TRK_RAPID_DELAY;
386+
txbuf[5] = (uint8_t)trk;
387+
txbuf[6] = (uint8_t)(trk >> 8);
388+
txbuf[7] = (uint8_t)i_rapid_delay;
389+
txbuf[8] = (uint8_t)(i_rapid_delay >> 8);
390+
txbuf[9] = EOM;
391+
GPStarSerial->write(txbuf, 10);
392+
}
393+
362394
void gpstarAudio::trackControl(uint16_t trk, uint8_t code) {
363395
uint8_t txbuf[8];
364396

src/GPStarAudio.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
#define TRK_LOOP_ON 5
5858
#define TRK_LOOP_OFF 6
5959
#define TRK_LOAD 7
60+
#define TRK_RAPID_PLAY 8
61+
#define TRK_RAPID_DELAY 9
6062

6163
#define RSP_VERSION_STRING 129
6264
#define RSP_SYSTEM_INFO 130
@@ -98,6 +100,8 @@ class gpstarAudio
98100
void trackPlayPoly(uint16_t trk, bool lock);
99101
void trackPlayPoly(uint16_t trk, bool lock, uint16_t i_trk_start_delay);
100102
void trackPlayPoly(uint16_t trk, bool lock, uint16_t i_trk_start_delay, uint16_t trk2, bool loop_trk2, uint16_t trk2_start_time);
103+
void trackRapidPlay(uint16_t trk, uint16_t i_rapid_delay);
104+
void trackRapidDelay(uint16_t trk, uint16_t i_rapid_delay);
101105
void trackQueueClear(void);
102106
void trackLoad(uint16_t trk);
103107
void trackLoad(uint16_t trk, bool lock);

0 commit comments

Comments
 (0)