xref: /haiku/src/apps/cortex/addons/Flanger/FlangerAddOn.cpp (revision 1a76488fc88584bf66b9751d7fb9b6527ac20d87)
1 /*
2  * Copyright (c) 1999-2000, Eric Moon.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions, and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 
32 // FlangerAddOn.cpp
33 // e.moon 16jun99
34 
35 #include "FlangerNode.h"
36 #include "FlangerAddOn.h"
37 #include <Catalog.h>
38 #include <Entry.h>
39 #include <Debug.h>
40 #include <cstring>
41 #include <cstdlib>
42 
43 #undef B_TRANSLATION_CONTEXT
44 #define B_TRANSLATION_CONTEXT "CortexAddOnsFlanger"
45 
46 // instantiation function
47 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image);
48 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) {
49 	return new FlangerAddOn(image);
50 }
51 
52 // -------------------------------------------------------- //
53 // ctor/dtor
54 // -------------------------------------------------------- //
55 
56 FlangerAddOn::~FlangerAddOn() {
57 	PRINT(("~FlangerAddOn()\n"));
58 }
59 FlangerAddOn::FlangerAddOn(image_id image) :
60 	BMediaAddOn(image) {}
61 
62 // -------------------------------------------------------- //
63 // BMediaAddOn impl
64 // -------------------------------------------------------- //
65 
66 status_t FlangerAddOn::InitCheck(
67 	const char** out_failure_text) {
68 	return B_OK;
69 }
70 
71 int32 FlangerAddOn::CountFlavors() {
72 	return 1;
73 }
74 
75 status_t FlangerAddOn::GetFlavorAt(
76 	int32 n,
77 	const flavor_info** out_info) {
78 	if(n)
79 		return B_ERROR;
80 
81 	flavor_info* pInfo = new flavor_info;
82 	pInfo->internal_id = n;
83 	pInfo->name = B_TRANSLATE("Flanger");
84 	pInfo->info = B_TRANSLATE("An add-on version of FlangerNode.\n"
85 		"by Eric Moon (16 June, 1999)");
86 	pInfo->kinds = B_BUFFER_CONSUMER | B_BUFFER_PRODUCER | B_CONTROLLABLE;
87 	pInfo->flavor_flags = 0;
88 	pInfo->possible_count = 0;
89 
90 	pInfo->in_format_count = 1;
91 	media_format* pFormat = new media_format;
92 	pFormat->type = B_MEDIA_RAW_AUDIO;
93 	pFormat->u.raw_audio = media_raw_audio_format::wildcard;
94 	pFormat->u.raw_audio.format = media_raw_audio_format::B_AUDIO_FLOAT;
95 	pInfo->in_formats = pFormat;
96 
97 	pInfo->out_format_count = 1;
98 	pFormat = new media_format;
99 	pFormat->type = B_MEDIA_RAW_AUDIO;
100 	pFormat->u.raw_audio = media_raw_audio_format::wildcard;
101 	pFormat->u.raw_audio.format = media_raw_audio_format::B_AUDIO_FLOAT;
102 	pInfo->out_formats = pFormat;
103 
104 	*out_info = pInfo;
105 	return B_OK;
106 }
107 
108 BMediaNode* FlangerAddOn::InstantiateNodeFor(
109 	const flavor_info* info,
110 	BMessage* config,
111 	status_t* out_error) {
112 
113 	FlangerNode* pNode = new FlangerNode(this);
114 	return pNode;
115 }
116 
117 status_t FlangerAddOn::GetConfigurationFor(
118 	BMediaNode* your_node,
119 	BMessage* into_message) {
120 
121 	// no config yet
122 	return B_OK;
123 }
124 
125 // END -- FlangerAddOn.h --
126