小编wil*_*lfo的帖子

在 juce 音频应用程序中打印 MIDI 音符编号

我试图在按下时将 MIDI 音符编号打印到 Juce 音频应用程序中的标签中。这是我目前拥有的代码:

在MainComponent头文件中:

class MainComponent   : public Component,
                        public MidiInputCallback

{
public:
    //==============================================================================
    MainComponent();
    ~MainComponent();

    void resized() override;
    void handleIncomingMidiMessage (MidiInput*, const MidiMessage&);


private:
    //==============================================================================
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
    AudioDeviceManager audioDeviceManager;
    Label midiLabel;
};
Run Code Online (Sandbox Code Playgroud)

在 MainComponent.cpp 构造函数中:

MainComponent::MainComponent()
{
    setSize (500, 400);

    audioDeviceManager.setMidiInputEnabled("USB Axiom 49 Port 1", true);
    audioDeviceManager.addMidiInputCallback (String::empty, this);

    //midiLabel
    midiLabel.setText("midiText", sendNotification);
    addAndMakeVisible(midiLabel);
}
Run Code Online (Sandbox Code Playgroud)

最后在handleIncomingMidiMessage函数中:

void MainComponent::handleIncomingMidiMessage(MidiInput*, const MidiMessage&)
{
    DBG("MIDI Message Recieved\n");


    //display label text
    String midiText;
    MidiMessage message;
    if (message.isNoteOnOrOff()) {
        midiText << "NoteOn: Channel …
Run Code Online (Sandbox Code Playgroud)

c++ midi juce

5
推荐指数
1
解决办法
949
查看次数

如何编写一个模板函数,它接受一个数组和一个指定数组大小的int

对于大学练习,我被要求编写一个模板函数"print();",它带有两个参数,1:一个泛型类型的数组,2:一个指定数组大小的int.然后,该函数应将阵列中的每个项目打印到控制台.我在使用函数参数时遇到了一些麻烦.我目前的代码是:

   template <typename Type>
   Type print (Type a, Type b)
    {
        Type items;
        Type array;
        a = array;
        b = items;

        for (int i = 0; i < items; i++) {
        std::cout << std::endl << "The element of the index " << i << " is " << array << std::endl;
        std::cout << std::endl;
    }
Run Code Online (Sandbox Code Playgroud)

并在main()中:

    print(Array[], 10);
Run Code Online (Sandbox Code Playgroud)

显然将Array作为参数放置并不返回值,所以我不知道还能做什么.有任何想法吗?

c++ arrays function template-function

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

c++ ×2

arrays ×1

function ×1

juce ×1

midi ×1

template-function ×1