Jelajahi Sumber

Rename _voice_count to _polyphony in SamplePlayer to be consistent with SamplePlayer2D

Rémi Verschelde 10 tahun lalu
induk
melakukan
3bf24eeb6b
3 mengubah file dengan 14 tambahan dan 12 penghapusan
  1. 1 1
      scene/2d/sample_player_2d.cpp
  2. 11 9
      scene/audio/sample_player.cpp
  3. 2 2
      scene/audio/sample_player.h

+ 1 - 1
scene/2d/sample_player_2d.cpp

@@ -214,7 +214,7 @@ void SamplePlayer2D::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer2D::set_sample_library);
 	ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer2D::get_sample_library);
 
-	ObjectTypeDB::bind_method(_MD("set_polyphony","voices"),&SamplePlayer2D::set_polyphony);
+	ObjectTypeDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer2D::set_polyphony);
 	ObjectTypeDB::bind_method(_MD("get_polyphony"),&SamplePlayer2D::get_polyphony);
 
 	ObjectTypeDB::bind_method(_MD("play","sample","voice"),&SamplePlayer2D::play,DEFVAL(NEXT_VOICE));

+ 11 - 9
scene/audio/sample_player.cpp

@@ -48,8 +48,8 @@ bool SamplePlayer::_set(const StringName& p_name, const Variant& p_value) {
 		}
 	} else if (name=="config/samples")
 		set_sample_library(p_value);
-	else if (name=="config/voices")
-		set_voice_count(p_value);
+	else if (name=="config/polyphony")
+		set_polyphony(p_value);
 	else if (name.begins_with("default/")) {
 
 		String what=name.right(8);
@@ -95,8 +95,8 @@ bool SamplePlayer::_get(const StringName& p_name,Variant &r_ret) const {
 
 	if (name=="play/play") {
 		r_ret=played_back;
-	} else if (name=="config/voices") {
-		r_ret= get_voice_count();
+	} else if (name=="config/polyphony") {
+		r_ret= get_polyphony();
 	} else if (name=="config/samples") {
 
 		r_ret= get_sample_library();
@@ -153,7 +153,7 @@ void SamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const {
 	}
 
 	p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR));
-	p_list->push_back( PropertyInfo( Variant::INT, "config/voices", PROPERTY_HINT_RANGE, "1,256,1"));
+	p_list->push_back( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,256,1"));
 	p_list->push_back( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary"));
 	p_list->push_back( PropertyInfo( Variant::REAL, "default/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"));
 	p_list->push_back( PropertyInfo( Variant::REAL, "default/pitch_scale", PROPERTY_HINT_RANGE, "0.01,48,0.01"));
@@ -203,14 +203,14 @@ SamplePlayer::Voice::~Voice() {
 }
 
 
-void SamplePlayer::set_voice_count(int p_voice_count) {
+void SamplePlayer::set_polyphony(int p_voice_count) {
 
 	ERR_FAIL_COND( p_voice_count <1 || p_voice_count >0xFFFE );
 
 	voices.resize(p_voice_count);
 }
 
-int SamplePlayer::get_voice_count() const {
+int SamplePlayer::get_polyphony() const {
 
 	return voices.size();
 }
@@ -606,8 +606,8 @@ void SamplePlayer::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer::set_sample_library );
 	ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer::get_sample_library );
 
-	ObjectTypeDB::bind_method(_MD("set_voice_count","max_voices"),&SamplePlayer::set_voice_count );
-	ObjectTypeDB::bind_method(_MD("get_voice_count"),&SamplePlayer::get_voice_count );
+	ObjectTypeDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer::set_polyphony );
+	ObjectTypeDB::bind_method(_MD("get_polyphony"),&SamplePlayer::get_polyphony );
 
 	ObjectTypeDB::bind_method(_MD("play","name","unique"),&SamplePlayer::play, DEFVAL(false) );
 	ObjectTypeDB::bind_method(_MD("stop","voice"),&SamplePlayer::stop );
@@ -677,6 +677,8 @@ void SamplePlayer::_bind_methods() {
 	BIND_CONSTANT( REVERB_LARGE  );
 	BIND_CONSTANT( REVERB_HALL );
 
+	BIND_CONSTANT( INVALID_VOICE_ID );
+
 }
 
 

+ 2 - 2
scene/audio/sample_player.h

@@ -130,8 +130,8 @@ public:
 	void set_sample_library(const Ref<SampleLibrary>& p_library);
 	Ref<SampleLibrary> get_sample_library() const;
 
-	void set_voice_count(int p_voice_count);
-	int get_voice_count() const;	
+	void set_polyphony(int p_voice_count);
+	int get_polyphony() const;
 
 	VoiceID play(const String& p_name,bool unique=false);
 	void stop(VoiceID p_voice);