summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2011-12-07 10:38:07 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2011-12-07 10:38:07 +0800
commitbb9e338690b5431102f5c75eb49f9583f408d1e4 (patch)
treeaf337733281c088c1ec553337e8894eab62ecbd7 /src
parent621d7ee3aa3e57c0d61afe34deea08479089d850 (diff)
Added setOrder and getOrder support for the input_mod
Diffstat (limited to 'src')
-rw-r--r--src/input_mod.cpp63
-rw-r--r--src/input_mod.h5
2 files changed, 68 insertions, 0 deletions
diff --git a/src/input_mod.cpp b/src/input_mod.cpp
index fe48c4f..8ca32c1 100644
--- a/src/input_mod.cpp
+++ b/src/input_mod.cpp
@@ -96,9 +96,72 @@ namespace audiere {
}
}
+
+ int
+ MODInputStream::getOrder()
+ {
+ ADR_GUARD("MOD_getOrder");
+ if (m_renderer) {
+ DUMB_IT_SIGRENDERER* itrenderer = duh_get_it_sigrenderer(m_renderer);
+ return dumb_it_sr_get_current_order(itrenderer);
+ }
+ return 0;
+ }
+
+
+ bool
+ MODInputStream::setOrder(int order)
+ {
+ ADR_GUARD("MOD_setOrder");
+ DUH_SIGRENDERER* renderer = dumb_it_start_at_order(m_duh, 2, order);
+ if (!renderer)
+ return false;
+
+ if (m_renderer)
+ duh_end_sigrenderer(m_renderer);
+ m_renderer = renderer;
+
+ DUMB_IT_SIGRENDERER* itrenderer = duh_get_it_sigrenderer(m_renderer);
+ dumb_it_set_loop_callback(itrenderer, &MODInputStream::loopCallback, this);
+ return true;
+ }
+
+
+ float
+ MODInputStream::getChannelVolume(int channel)
+ {
+ ADR_GUARD("MOD_getChannelVolume");
+ if (!m_renderer)
+ return 1.0f;
+
+ if (channel < 0 || channel >= DUMB_IT_N_CHANNELS - 1)
+ return 1.0f;
+
+ DUMB_IT_SIGRENDERER* renderer = duh_get_it_sigrenderer(m_renderer);
+ int volume = dumb_it_sr_get_channel_volume(renderer, channel);
+ return volume / 128.0f;
+ }
+
+ bool
+ MODInputStream::setChannelVolume(int channel, float volume)
+ {
+ ADR_GUARD("MOD_getChannelVolume");
+ if (!m_renderer)
+ return false;
+
+ if (channel < 0 || channel >= DUMB_IT_N_CHANNELS - 1 ||
+ volume < 0.0f || volume > 1.0f)
+ return false;
+
+ DUMB_IT_SIGRENDERER* renderer = duh_get_it_sigrenderer(m_renderer);
+ dumb_it_sr_set_channel_volume(renderer, channel, volume * 128.0f);
+ return true;
+ }
+
int
MODInputStream::doRead(int frame_count, void* buffer) {
+ ADR_GUARD("MOD_doRead");
return duh_render(m_renderer, 16, 0, 1.0f, 65536.0f / 44100,
frame_count, buffer);
}
diff --git a/src/input_mod.h b/src/input_mod.h
index 0146cc3..a1ba5ed 100644
--- a/src/input_mod.h
+++ b/src/input_mod.h
@@ -23,6 +23,11 @@ namespace audiere {
SampleFormat& sample_format);
void ADR_CALL reset();
+ int ADR_CALL getOrder();
+ bool ADR_CALL setOrder(int order);
+ float ADR_CALL getChannelVolume(int channel = 0);
+ bool ADR_CALL setChannelVolume(int channel, float volume);
+
int doRead(int frame_count, void* buffer);
private: