1 #include "mainprogress.h"
2 #include "reverseaudio.h"
8 #define _(String) gettext(String)
9 #define gettext_noop(String) String
10 #define N_(String) gettext_noop (String)
13 PluginClient* new_plugin(PluginServer *server)
15 return new ReverseAudio(server);
18 ReverseAudio::ReverseAudio(PluginServer *server)
19 : PluginAClient(server)
23 ReverseAudio::~ReverseAudio()
27 char* ReverseAudio::plugin_title() { return _("Reverse audio"); }
29 int ReverseAudio::is_realtime() { return 0; }
31 VFrame* ReverseAudio::new_picon()
36 int ReverseAudio::start_loop()
38 //printf("ReverseAudio::start_loop 1\n");
39 if(PluginClient::interactive)
41 char string[BCTEXTLEN];
42 sprintf(string, "%s...", plugin_title());
43 progress = start_progress(string,
44 (PluginClient::end - PluginClient::start));
47 current_position = PluginClient::end;
49 //printf("ReverseAudio::start_loop 2\n");
54 int ReverseAudio::stop_loop()
56 if(PluginClient::interactive)
58 progress->stop_progress();
64 int ReverseAudio::process_loop(double *buffer, int64_t &write_length)
68 //printf("ReverseAudio::process_loop 1\n");
70 fragment_len = PluginClient::in_buffer_size;
71 //printf("ReverseAudio::process_loop 2\n");
72 if(current_position - fragment_len < PluginClient::start)
74 fragment_len = current_position - PluginClient::start;
77 //printf("ReverseAudio::process_loop 3 %d %d\n", current_position, fragment_len);
79 read_samples(buffer, current_position - fragment_len, fragment_len);
81 //printf("ReverseAudio::process_loop 4 %p\n", buffer);
82 for(int j = 0; j < fragment_len / 2; j++)
84 double sample = buffer[j];
85 buffer[j] = buffer[fragment_len - 1 - j];
86 buffer[fragment_len - 1 -j] = sample;
88 //printf("ReverseAudio::process_loop 5 %d\n", current_position);
90 current_position -= fragment_len;
91 //printf("ReverseAudio::process_loop 6 %d\n", current_position);
92 total_written += fragment_len;
93 write_length = fragment_len;
94 if(PluginClient::interactive) result = progress->update(total_written);
95 //printf("ReverseAudio::process_loop 7 %d\n", current_position);