简体   繁体   English

模块化设计模式

[英]Modular Design Patterns

I've started drawing plugs in Java, like connectors using bezier curves, but just the visual stuff. 我开始使用Java插件,比如使用贝塞尔曲线的连接器,但只是视觉效果。

例

Then I begin wondering about making some kind of modular thing, with inputs and outputs. 然后我开始想知道如何使用输入和输出来制作某种模块化的东西。 However, I'm very confused on decisions about how to implement it. 但是,我对如何实现它的决定感到很困惑。 Let's say for example, a modular synthesizer, or Pure Data / MaxMSP concepts, in which you have modules, and any module has attributes, inputs and outputs. 比方说,例如,模块化合成器或Pure Data / MaxMSP概念,其中有模块,任何模块都有属性,输入和输出。

I wonder if you know what keywords should I use to search something to read about. 我想知道您是否知道我应该使用哪些关键字来搜索要阅读的内容。 I need some basic examples or abstract ideas concerning this kind of interface. 我需要一些关于这种界面的基本例子或抽象概念。 Is there any some design pattern that fits this idea? 有没有适合这个想法的设计模式?

Since you're asking for a keyword real-time design patterns , overly OOP is often a performance bottleneck to real-time applications, since all the objects (and I guess polymorphism to some extent) add overhead. 由于您要求提供关键字实时设计模式 ,因此过度OOP通常是实时应用程序的性能瓶颈,因为所有对象(我认为在某种程度上是多态性)会增加开销。

Why real-time application? 为什么要实时应用? The graph you provided looks very sophisticated, You process the incoming data multiple times in parallel, split it up, merge it and so on. 您提供的图表看起来非常复杂,您可以多次并行处理传入数据,将其拆分,合并等等。

Every node in the graph adds different effects and makes different computations, where some computations may take longer than others - this leads to the conclusion, that in order to have uniform data (sound), you have to keep the data in sync. 图中的每个节点都会添加不同的效果并进行不同的计算,其中一些计算可能需要比其他计算更长的时间 - 这导致结论,为了获得统一的数据(声音),您必须保持数据同步。 This is no trivial task. 这不是一件轻而易举的事。


I guess some other keywords would be: sound processing, filter. 我猜其他一些关键词是:声音处理,过滤器。 Or you could ask companies that work in that area for literature. 或者您可以要求在该领域工作的公司提供文献资料。


Leaving the time sensitivity aside, I constructed a little OOP example, maybe an approach like that is sufficient for less complex scenarios 抛开时间敏感性,我构建了一个小OOP示例,也许这样的方法足以用于不太复杂的场景

public class ConnectionCable implements Runnable, Closeable {
    private final InputLine in;
    private final OutputLine out;

    public ConnectionCable(InputLine in, OutputLine out) {
        this.in = in;
        this.out = out;
        // cable connects open lines and closes them upon connection
        if (in.isOpen() && out.isOpen()) {
            in.close();
            out.close();
        }
    }

    @Override
    public void run() {
        byte[] data = new byte[1024];
        // cable connects output line to input line
        while (out.read(data) > 0)
            in.write(data);
    }

    @Override
    public void close() throws IOException {
        in.open();
        out.open();
    }
}

interface Line {
    void open();
    void close();
    boolean isOpen();
    boolean isClosed();
}

interface InputLine extends Line {
    int write(byte[] data);
}

interface OutputLine extends Line {
    int read(byte[] data);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM