File: xoscillo_s.c

package info (click to toggle)
lebiniou 3.18-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 5,396 kB
  • sloc: ansic: 20,369; sh: 4,169; makefile: 834; awk: 194
file content (95 lines) | stat: -rw-r--r-- 1,977 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 *  Copyright 1994-2012 Olivier Girondel
 *
 *  This file is part of lebiniou.
 *
 *  lebiniou is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  lebiniou is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
 */

#include "oscillo.h"


u_long id = 1089152274;
u_long options = BE_SFX2D|BEQ_HOR;
char dname[] = "X oscillo stereo";
u_long mode = OVERLAY;
char desc[] = "Horizontal stereo oscilloscope";


static Porteuse_t *PL = NULL, *PR = NULL;
static int connect = 1;


static void
init()
{
	int i;
	Transform_t t;

	memset(&t, 0, sizeof(t));

	PL->origin.x = PR->origin.x = 0;

	PL->origin.y = HHEIGHT/2;
	PR->origin.y = MAXY-HHEIGHT/2;
  
	t.v_j_factor = HMAXY * 0.85;
	t.v_i.x = 1.0 / (float)(PL->size - 1) * (float)MAXX;
  
	for (i = 0; i < PL->size; i++)
		PL->trans[i] = PR->trans[i] = t;

	Porteuse_init_alpha(PL);
	Porteuse_init_alpha(PR);
}


void
create(Context_t *ctx)
{
  if (ctx->input != NULL) {
    PL = Porteuse_new(ctx->input->size, A_LEFT);
    PR = Porteuse_new(ctx->input->size, A_RIGHT);
    init();
  } else
    options |= BEQ_DISABLED;
}


void
on_switch_on(__attribute__ ((unused)) Context_t *ctx)
{
  /* connect = b_rand_boolean(); */
}


void
destroy(Context_t *ctx)
{
  if (ctx->input != NULL) {
    Porteuse_delete(PL);
    Porteuse_delete(PR);
  }
}


void
run(Context_t *ctx)
{
  if (ctx->input != NULL) {
    Buffer8_clear(passive_buffer(ctx));
    Porteuse_draw(PL, ctx, connect);
    Porteuse_draw(PR, ctx, connect);
  }
}