SFML community forums

General => SFML projects => Topic started by: amhndu on July 01, 2016, 10:08:18 am

Title: A simple musical Notes player
Post by: amhndu on July 01, 2016, 10:08:18 am
Notes
Notes is a simple graphical musical notes player. Within the window use the keyboard to play. The numeric row and alphabetical rows are used.Using each row is equivalent, thus 1, Q, A and Z all play the same note. The notes get higher from left to right

Github link
https://github.com/amhndu/Notes

Command line options:

Usage ./notes [OPTIONS]
--help, -h                        Display this text and exit
--note-duration, -d <duration>    Set the note duration in milliseconds
                                  (default: 300)
--sample-rate, -r <rate>          Set the sample in samples per second, higher
                                  means higher quality but also higher load time
                                  (default: 441000)
--namednotesinput, -n             Input/play notes by their names instead.
                                  Available notes: C D E F G A B
                                  Don't use this option if you want more notes
                                  or the positional input (the default)

Compiling
Dependencies

SFML 2+
Build system: cmake 3.1+

On Linux/OS X:

cd Notes                        #Go the the project directory
mkdir build/ && cd build/
cmake -DCMAKE_BUILD_TYPE=Release .. && make
./notes                         #Launch
Similar steps for Windows.

Songs
Try these tunes!

Twinkle Twinkle
 
QQTTYYT RREEWWQ TTRREEW TTRREEW QQTTYYT RREEWWQ

Happy Birthday
 
1-1-2-1-4-3- -1-1-2-1-5-4- -1-1-8-6-4-3-2- -8-8-7-4-5-4

Harry Potter theme
 
E-Y-I-U-Y-P-O-U-Y-I-U-Y-U-E

Mary had a little lamb
In named input method, launch with -n (./notes -n)
 
EDCDEEE DDDEEE EDCDEEE EDDEDC
Title: Re: A simple musical Notes player
Post by: eXpl0it3r on July 01, 2016, 12:55:06 pm
Cool! :)

Can you create some binaries and add them as release on GitHub?
Title: Re: A simple musical Notes player
Post by: amhndu on July 01, 2016, 01:27:14 pm
On what platform are you suggesting ? I can only make binaries for Linux, should I make it static ?
As my thinking goes, different distributions might be incompatible.
For other platforms, I'll probably ask a friend with Mac and another with Windows for help.
Title: Re: A simple musical Notes player
Post by: eXpl0it3r on July 01, 2016, 01:31:22 pm
Ah okay. Yeah for Linux it's always a bit tricky. Guess I'll build it myself then. :)
Title: Re: A simple musical Notes player
Post by: Mario on July 01, 2016, 05:26:43 pm
Modified your CMakeLists.txt a bit to properly include include directories and SFML dependencies:

cmake_minimum_required(VERSION 3.1)
project(notes)

find_package(SFML 2 COMPONENTS graphics window audio system REQUIRED)

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
        set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -g")
        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()

file(GLOB SOURCES
    "${PROJECT_SOURCE_DIR}/*.cpp"
)

include_directories(${SFML_INCLUDE_DIR})
add_executable(notes ${SOURCES})
target_link_libraries(notes ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})

set_property(TARGET notes PROPERTY CXX_STANDARD 11)
set_property(TARGET notes PROPERTY CXX_STANDARD_REQUIRED ON)

install(TARGETS notes RUNTIME DESTINATION bin)
 
Title: Re: A simple musical Notes player
Post by: Hapax on July 01, 2016, 07:15:04 pm
Good to see people actually interested in musical things with SFML  :D

I once made a virtual keyboard too (I use it in a music editor that I'm casually working on). I would suggest that you also include sharp/flat notes. I mean, they're needed for that Harry Potter theme! :P

The keyboard is layed out rather nicely to place them on alternate rows. For example:
23 567 90 = (C# D# F# G# A# C# D# F#)
QWERTYUIOP[] (CDEFGABCDEFG)
SD GHJ L; (C# D# F# G# A# C# D#)
ZXCVBNM,./ (CDEFGABCDE)
Title: Re: A simple musical Notes player
Post by: amhndu on July 02, 2016, 06:07:44 am
@Mario
Thanks, I forgot about the headers!
I installed SFML under /usr/ so I didn't need to mention the header location for my system


Good to see people actually interested in musical things with SFML  :D

I once made a virtual keyboard too (I use it in a music editor that I'm casually working on). I would suggest that you also include sharp/flat notes. I mean, they're needed for that Harry Potter theme! :P

The keyboard is layed out rather nicely to place them on alternate rows. For example:
23 567 90 = (C# D# F# G# A# C# D# F#)
QWERTYUIOP[] (CDEFGABCDEFG)
SD GHJ L; (C# D# F# G# A# C# D#)
ZXCVBNM,./ (CDEFGABCDE)


Good idea, I'll probably implement them too