mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-03-04 11:55:14 +00:00
Added tone to string and string to tone
This commit is contained in:
parent
a7370ee95d
commit
5d5865eefb
@ -104,8 +104,30 @@ void tone_keys_populate(OptionsField& field) {
|
|||||||
field.set_options(tone_key_options);
|
field.set_options(tone_key_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
float tone_key_frequency(const uint32_t index) {
|
float tone_key_frequency(const tone_index index) {
|
||||||
return tone_keys[index].second;
|
return tone_keys[index].second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string tone_key_string( tone_index index ) {
|
||||||
|
if( index < 0 || (unsigned)index >= tone_keys . size() )
|
||||||
|
return std::string( "" );
|
||||||
|
return tone_keys[ index ] .first ;
|
||||||
|
}
|
||||||
|
|
||||||
|
tone_index tone_key_index_by_string( char *str ) {
|
||||||
|
if( !str )
|
||||||
|
return -1 ;
|
||||||
|
for( tone_index index = 0 ; (unsigned)index < tone_keys . size() ; index ++ )
|
||||||
|
{
|
||||||
|
if( tone_keys[ index ] . first . compare( str ) >= 0 )
|
||||||
|
return index ;
|
||||||
|
}
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* tone_index tone_key_index_by_value( int32_t freq )
|
||||||
|
{
|
||||||
|
return -1 ;
|
||||||
|
} */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,18 @@ using namespace ui;
|
|||||||
|
|
||||||
namespace tonekey {
|
namespace tonekey {
|
||||||
|
|
||||||
|
typedef int16_t tone_index ;
|
||||||
|
|
||||||
using tone_key_t = std::vector<std::pair<std::string, float>>;
|
using tone_key_t = std::vector<std::pair<std::string, float>>;
|
||||||
|
|
||||||
extern const tone_key_t tone_keys;
|
extern const tone_key_t tone_keys;
|
||||||
|
|
||||||
void tone_keys_populate(OptionsField& field);
|
void tone_keys_populate(OptionsField& field);
|
||||||
float tone_key_frequency(const uint32_t index);
|
float tone_key_frequency(const tone_index index);
|
||||||
|
|
||||||
|
std::string tone_key_string( const tone_index index );
|
||||||
|
tone_index tone_key_index_by_string( char *str );
|
||||||
|
// tone_index tone_key_index_by_value( int32_t freq );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user