-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fce25a
commit c779f97
Showing
7 changed files
with
202 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated Cmake Pico project file | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
|
||
include(pico_sdk_import.cmake) | ||
|
||
project(tone_example C CXX ASM) | ||
|
||
pico_sdk_init() | ||
|
||
# Add executable. Default name is the project name, | ||
add_executable(tone_example tone_example.cpp) | ||
add_subdirectory(../pico-tone build) | ||
|
||
pico_add_extra_outputs(tone_example) | ||
target_link_libraries(tone_example pico_stdlib pico_tone) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake | ||
|
||
# This can be dropped into an external project to help locate this SDK | ||
# It should be include()ed prior to project() | ||
|
||
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) | ||
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) | ||
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") | ||
endif () | ||
|
||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) | ||
set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) | ||
message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") | ||
endif () | ||
|
||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) | ||
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) | ||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") | ||
endif () | ||
|
||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") | ||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") | ||
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") | ||
|
||
if (NOT PICO_SDK_PATH) | ||
if (PICO_SDK_FETCH_FROM_GIT) | ||
include(FetchContent) | ||
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) | ||
if (PICO_SDK_FETCH_FROM_GIT_PATH) | ||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") | ||
endif () | ||
FetchContent_Declare( | ||
pico_sdk | ||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk | ||
GIT_TAG master | ||
) | ||
if (NOT pico_sdk) | ||
message("Downloading Raspberry Pi Pico SDK") | ||
FetchContent_Populate(pico_sdk) | ||
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) | ||
endif () | ||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) | ||
else () | ||
message(FATAL_ERROR | ||
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." | ||
) | ||
endif () | ||
endif () | ||
|
||
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") | ||
if (NOT EXISTS ${PICO_SDK_PATH}) | ||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") | ||
endif () | ||
|
||
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) | ||
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) | ||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") | ||
endif () | ||
|
||
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) | ||
|
||
include(${PICO_SDK_INIT_CMAKE_FILE}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|
||
#include "pico/stdlib.h" | ||
#include "pico/time.h" | ||
#include "pico_tone.hpp" | ||
|
||
|
||
int main() { | ||
|
||
// Thanks to Michal Choma, Slovakya | ||
|
||
int melody[] = { | ||
// notes of the melody followed by the duration. | ||
// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on | ||
// !!negative numbers are used to represent dotted notes, | ||
// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! | ||
|
||
// Mafia theme | ||
// Score available at https://musescore.com/user/2139361/scores/783461 | ||
|
||
NOTE_D4, 4, NOTE_F4, 4, NOTE_E4, 4, NOTE_D4, 4, //1 | ||
NOTE_D4, 4, NOTE_A3, 4, NOTE_G3, 4, NOTE_C4, 4, //2 | ||
NOTE_D4, 4, NOTE_F4, 4, NOTE_E4, 4, NOTE_G4, 4, //3 | ||
NOTE_A4, 1, //4 | ||
NOTE_A4, 4, NOTE_C5, 4, NOTE_G4, 2, //5 | ||
NOTE_G4, -4, NOTE_E4, 8, NOTE_D4, 4, NOTE_C4, 8, NOTE_E4, 16, NOTE_F4, 16, //6 | ||
NOTE_E4, 4, NOTE_C4, 4, NOTE_D4, 2, //7 | ||
|
||
NOTE_D4, -4, NOTE_C4, 8, NOTE_A3, 4, NOTE_G3, 4, //8 | ||
NOTE_A5, 4, NOTE_C6, 4, NOTE_G5, 2, //9 | ||
NOTE_G5, -4, NOTE_E5, 8, NOTE_D5, 4, NOTE_C5, 8, NOTE_E5, 16, NOTE_F5, 16, //10 | ||
NOTE_E5, 4, NOTE_C5, 4, NOTE_D5, 2, //11 | ||
NOTE_D5, -4, NOTE_C5, 8, NOTE_A4, 4, NOTE_G4, 4, //12 | ||
NOTE_D6, 2, NOTE_D6, 8, NOTE_F5, 8, NOTE_A5, 8, NOTE_D6, 8, //13 | ||
|
||
NOTE_G5, 2, NOTE_C6, 8, NOTE_AS5, 4, NOTE_A5, 16, NOTE_AS5, 16, //14 | ||
NOTE_A5, 2, NOTE_E5, 8, NOTE_F5, 8, NOTE_E5, 8, NOTE_C5, 8, //15 | ||
NOTE_D5, 2, NOTE_E5, 8, NOTE_F5, 8, NOTE_E5, 8, NOTE_C5, 8, //16 | ||
NOTE_D6, 2, NOTE_D5, 8, NOTE_F4, 8, NOTE_A4, 8, NOTE_D5, 8, //17 | ||
NOTE_E5, 8, NOTE_F5, 8, NOTE_C5, -2, //18 | ||
|
||
NOTE_D5, 8, NOTE_DS5, 8, NOTE_AS4, -4, NOTE_G4, 8, NOTE_F4, 8, NOTE_DS4, 8, //19 | ||
NOTE_AS4, 8, NOTE_B4, 8, NOTE_DS4, -2, //20 | ||
NOTE_G4, -8, NOTE_GS4, 16, NOTE_GS4, -4, NOTE_G4, -8, NOTE_GS4, 8, //21 -1/16 | ||
NOTE_AS4, -8, NOTE_B4, 16, NOTE_B4, 2, NOTE_C5, 4, //22 | ||
NOTE_G4, -8, NOTE_F4, 16, NOTE_F4, -4, NOTE_G4, -8, NOTE_GS4, 8, //23 -1/16 | ||
|
||
NOTE_E4, -2, NOTE_AS4, 8, //24 -1/8 | ||
NOTE_B4, 8, NOTE_AS4, 16, NOTE_B4, 8, NOTE_AS4, 16, NOTE_B4, 2, //25 -1/8 | ||
NOTE_AS4, -8, NOTE_B4, 2, NOTE_AS4, -8, NOTE_B4, 8, //26 | ||
NOTE_CS5, -8, NOTE_D5, 2, NOTE_DS5, 4, //27 -1/16 | ||
NOTE_AS4, -8, NOTE_GS4, 2, NOTE_AS4, -8, NOTE_B4, 8, //28 | ||
NOTE_G4, -2, NOTE_CS5, 8, //29 -1/8 | ||
|
||
NOTE_D5, 8, NOTE_CS5, 16, NOTE_D5, 8, NOTE_CS5, 16, NOTE_D5, 2, //30 -1/8 | ||
NOTE_CS5, -16, NOTE_E5, -16, NOTE_DS5, -8, NOTE_C6, 32, NOTE_A5, 32, NOTE_B5, 16, NOTE_B5, -16, NOTE_D6, -16, NOTE_CS6, 8, NOTE_A5, -8, //31 | ||
NOTE_CS5, -16, NOTE_E5, -16, NOTE_DS5, -8, NOTE_C6, 32, NOTE_A5, 32, NOTE_B5, 16, NOTE_B5, -16, NOTE_D6, -16, NOTE_CS6, 8, NOTE_A5, -8, //32 | ||
|
||
NOTE_CS5, -16, NOTE_E5, -16, NOTE_DS5, -8, NOTE_C6, 32, NOTE_A5, 32, NOTE_B5, 16, NOTE_B5, -16, NOTE_D6, -16, NOTE_CS6, 8, NOTE_A5, -8, //33 | ||
NOTE_CS5, -16, NOTE_E5, -16, NOTE_DS5, -8, NOTE_C6, 32, NOTE_A5, 32, NOTE_B5, 16, NOTE_B5, -16, NOTE_D6, -16, NOTE_CS6, 8, NOTE_A5, -8, //34 | ||
|
||
NOTE_D5, -4, NOTE_C5, 8, NOTE_D5, 8, NOTE_F4, 8, NOTE_A4, 8, NOTE_D5, 8, //35 | ||
NOTE_G4, 2, NOTE_C5, 8, NOTE_AS4, 4, NOTE_A4, 16, NOTE_AS4, 16, //36 | ||
|
||
NOTE_A4, 4, NOTE_AS4, 4, NOTE_E4, 8, NOTE_F4, 8, NOTE_E4, 8, NOTE_C4, 8, //37 | ||
NOTE_D4, 2, NOTE_E5, 8, NOTE_F5, 8, NOTE_E5, 8, NOTE_C5, 8, //38 | ||
|
||
NOTE_D5, -4, NOTE_C5, 8, NOTE_D5, 8, NOTE_F4, 8, NOTE_A4, 8, NOTE_D5, 8, //39 | ||
NOTE_E5, 8, NOTE_F5, 8, NOTE_C5, 2, //40 | ||
|
||
NOTE_D5, 8, NOTE_DS5, 8, NOTE_AS4, -4, NOTE_G4, 8, NOTE_F4, 8, NOTE_DS4, 8, //41 | ||
NOTE_AS4, 4, NOTE_B4, 4, NOTE_DS4, 2, //42 | ||
NOTE_C5, -4, NOTE_AS4, 8, NOTE_GS4, 4, NOTE_G4, 4, //43 | ||
|
||
NOTE_C5, -4, NOTE_AS4, 8, NOTE_F4, -4, NOTE_DS4, 8, //44 | ||
NOTE_AS4, -4, NOTE_GS4, 8, NOTE_G4, 4, NOTE_GS4, 4, //45 | ||
NOTE_F4, 1, //46 | ||
NOTE_C5, -4, NOTE_AS4, 8, NOTE_GS4, 4, NOTE_G4, 4, //47 | ||
NOTE_C5, -4, NOTE_AS4, 8, NOTE_F4, -4, NOTE_DS4, 8, //48 | ||
NOTE_AS4, -4, NOTE_GS4, 8, NOTE_G4, 4, NOTE_GS4, 4, //49 | ||
NOTE_F4, 1, //50 | ||
}; | ||
|
||
Tone myPlayer(15,50,0,20,0,20,0,10); | ||
myPlayer.init(TONE_NON_BLOCKING) ; | ||
|
||
|
||
while (true) { | ||
|
||
myPlayer.play_melody(T_ADAGIO,sizeof(melody)/(sizeof(melody[0])*2),melody); | ||
|
||
sleep_ms(4000); | ||
|
||
}; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters