/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
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
<?php

interface RESAMPLERInterface {
 function Resample($data, $flags = 0);
};

abstract class RESAMPLER implements RESAMPLERInterface {
  var $options;
  
  function __construct(REQUEST $req  = NULL, array $options = NULL , $sampling = false) {
    $this->options = $options?$options:array();
  }

 function GetOption($opt, $default = false) {
    if (isset($this->options[$opt])) return $this->options[$opt];
    return $default;
 }

  function GetNumberOfChannels($data) {
	// We can compute later
    return $data['info']['n_channels'];
  }

  static function IsApplicable($sampling = false) {
    if ($sampling) 
	return false;

    return true;
  }

  static function GetResampler(REQUEST $req  = NULL, $resampler, $sampling = false) {
    global $ADEI_RESAMPLERS;

    $cfg = $ADEI_RESAMPLERS[$resampler];
    if (!$cfg) throw new ADEIException(translate("Unsupported resampler (%s) is configured", $resampler));

    ADEI::RequireClass("resamplers/" . strtolower($cfg['handler']), true);
    $r = new $cfg['handler']($req, $cfg['opts'], $sampling);
    return $r;
 }

 static function GetSelectList($sampling = false) {
    global $ADEI;
    global $ADEI_RESAMPLERS;

    $res = array();
    foreach ($ADEI_RESAMPLERS as $name => $cfg) {
	ADEI::RequireClass("resamplers/" . strtolower($cfg['handler']), true);

        if ($cfg['handler']::IsApplicable($sampling)) {
	    array_push($res, array(
		'value' => $name,
		'label' => $cfg['title'],
	    ));
	}
    }
    return $res;
  }

/*
  static function GetMethods() {
    global $ADEI_RESAMPLERS;

    $root = ADEI::GetRootDir();
    $setup = ADEI::GetSetupDir();

    $names = array_merge(glob("$setup/classes/resamplers/*.php"), glob("$root/classes/resamplers/*.php"));
    foreach ($names as &$name) {
	$name = basename($name, ".php");
    }
    $names = array_uniq($names);

    foreach $names as $name {
	ADEI::RequireClass("resamplers/$name");
    }
*/
}

?>