목록C++ (102)
음악, 삶, 개발
요약 - 연산자별로 규칙과 주의사항이 틀리니, 다 따로 공부해야한다. - =, (), [ ], -> 연산자는 반드시 멤버 함수여야한다. - 멤버 함수일때는 한 개의 인자, 전역 함수일때는 2개의 인자가 필요하다. (3개 이상은 가질수없음) - + 연산자는 교환법칙이 성립해도록 (예 : myClass + 1 또는 1 + myClass) 멤버 함수, 전역 함수 둘다 정의되어야함. (코드 참조) - + 연산자는 좌측 피연산자, 우측 피연산자, return type 모두 읽기만 하기때문에 모두 const. 따라서 함수도 () const {} - + 연산자는 return type은 const, 인자는 const reference - 연산자 오버로딩 함수 구현시, 생성자를 활용한다. - 오버로딩 함수의 피연산자중 ..
https://stackoverflow.com/questions/2446142/how-to-differentiate-two-constructors-with-the-same-parameters http://tcpschool.com/cpp/cpp_conDestructor_defaultConstructor
VST3 를 컴파일할수있는 가장 기본적인 코드. 이 코드를 기본으로 깔고, 기능을 만들어가면됨. #include class MainProcessor : public juce::AudioProcessor { public: MainProcessor() : AudioProcessor(BusesProperties().withOutput("Output", juce::AudioChannelSet::stereo(), true)) { } ~MainProcessor() override { } bool hasEditor() const override { return true; } juce::AudioProcessorEditor* createEditor() override; const juce::String getName(..
코드 class Arp : public juce::AudioProcessor { public : void prepareToPlay(double sampleRate, int maximumExpectedSamplesPerBlock) override { notes.clear(); // [1]: First, we empty the SortedSet of MIDI note numbers. currentNote = 0; // [2]: The currentNote variable temporarily holds the current index for the SortedSet of notes. lastNoteValue = -1; // [3]: The lastNoteValue variable temporarily hol..
코드 void transposeByInterval(juce::MidiBuffer& midiBuffer, int interval) { juce::MidiBuffer transposedMidi; for (const auto metaData : midiBuffer) { auto midiMessage { metaData.getMessage() }; if (midiMessage.isNoteOnOrOff()) { midiMessage.setNoteNumber(midiMessage.getNoteNumber() + interval); transposedMidi.addEvent(midiMessage, metaData.samplePosition); } } midiBuffer.swapWith(transposedMidi); ..

juce 의 Random 클래스로 객체를 생성후 습관적으로 앞에 const 를 붙였더니, 아래와 같은 에러가 발생하였다. 에러 메세지 : "the object has type qualifiers that are not compatible with the member function" 즉, "이 객체의 type 지정자는 멤버 함수와 호환되지않습니다" 그래서, juce::Random 앞에 const 를 제거했더니, 정상적으로 컴파일 되었다. 이 부분에 대해 의문이 생겨, 위 에러 메세지로 stackoverflow 에 검색을 해보았더니, 역시나, 나와같은 궁금증을 가진 사람이 있었고, 아래와 같은 답변이 있었다. 핵심은.. "You cannot call a non-const method with a const..
https://www.sourcetrail.com/blog/const_friend_or_foe_in_cpp/ https://www.studytonight.com/cpp/const-keyword.php https://www.cprogramming.com/tutorial/const_correctness.html https://docs.microsoft.com/en-us/cpp/cpp/const-cpp?view=vs-2019 https://dydtjr1128.github.io/cpp/2020/01/08/Cpp-const.html https://www.cppkorea.org/CppCoreGuidelines/Const/ https://m.blog.naver.com/PostView.nhn?blogId=taeil34..

소개 Chapter 2 에서 다루었던 내장 type 들에 추가하여, C++ 는 추상 데이터 type 에 대한 풍부한 라이브러리를 제공한다. 이중 가장 중요한 라이브러리 type 은, 가변길이의 문자열을 제공하는 string 과 가변 크기의 컬렉션을 정의하는 vector 이다. string및 vector와 관련된 것은 iterator라고하는 동반자 (companion) type으로, string의 문자 또는 vector의 요소에 액세스하는 데 사용된다. 라이브러리에 의해 정의된 string 과 vector type들은 원시적인 내장 array type 의 추상화 (abstraction) 이다. 이 Chapter 에서는 array 를 다루고, 라이브러리 vector 와 string type 을 소개한다. C..

소개 type 은 모든 프로그램의 기본이 되는것이다. type 은 우리의 데이터가 무엇을 의미한지, 이 데이타가 어떤 operation 이 가능한지 말해준다. C++ 는 type 에 대한 광범위한 support 를 제공한다. C++ 언어 자체가 몇가지 원시 type (문자, 정수, 소수 등..) 을 정의하고, 사용자가 직접 type 을 정의할수있는 메카니즘을 제공한다. library 는 이 메카니즘을 사용하여 가변 길이의 string 이나 vector 와 같은 복잡한 type 을 정의한다. 이 챕터에서는 built-in type 들과, C++ 가 어떻게 더 복잡한 type 들을 지원하는지에대해 다룰것이다. type 은 우리의 프로그램안에서 데이터의 의미와 operation 을 결정한다. i ..
Contents Chapter 2 Variables and Basic Types Chapter 3 Strings, Vector, and Arrays Chapter 4 Expressions Chapter 5 Statements Chapter 6 Functions Chapter 7 Classes 널리 사용되는 모든 프로그래밍 언어는 공통의 기능들을 제공한다. (세부적으로 서로 차이가있지만) 언어가 제공하는 이 기능들의 detail 을 이해하는것은 언어를 이해하기위한 첫번째 step 이다. 이 공통된 기능들중 가장 근본적인것들은 아래와 같다. Built-in types : 정수 (integer), 문자 (character) 와 같은 것. Variables (변수) : 우리가 사용하는 객체에 이름을 지어줄수있게..