id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
33,951
utf_old.h
supercollider_supercollider/external_libraries/icu/unicode/utf_old.h
/* ******************************************************************************* * * Copyright (C) 2002-2004, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: utf.h * encoding: US-ASCII * tab size: 8 (not used) * indentation:4 * * created on: 2002sep21 * created by: Markus W. Scherer */ /** * \file * The macros in utf_old.h are all deprecated and their use discouraged. * Some of the design principles behind the set of UTF macros * have changed or proved impractical. * Almost all of the old "UTF macros" are at least renamed. * If you are looking for a new equivalent to an old macro, please see the * comment at the old one. * * utf_old.h is included by utf.h after unicode/umachine.h * and some common definitions, to not break old code. * * Brief summary of reasons for deprecation: * - Switch on UTF_SIZE (selection of UTF-8/16/32 default string processing) * was impractical. * - Switch on UTF_SAFE etc. (selection of unsafe/safe/strict default string processing) * was of little use and impractical. * - Whole classes of macros became obsolete outside of the UTF_SIZE/UTF_SAFE * selection framework: UTF32_ macros (all trivial) * and UTF_ default and intermediate macros (all aliases). * - The selection framework also caused many macro aliases. * - Change in Unicode standard: "irregular" sequences (3.0) became illegal (3.2). * - Change of language in Unicode standard: * Growing distinction between internal x-bit Unicode strings and external UTF-x * forms, with the former more lenient. * Suggests renaming of UTF16_ macros to U16_. * - The prefix "UTF_" without a width number confused some users. * - "Safe" append macros needed the addition of an error indicator output. * - "Safe" UTF-8 macros used legitimate (if rarely used) code point values * to indicate error conditions. * - The use of the "_CHAR" infix for code point operations confused some users. * * More details: * * Until ICU 2.2, utf.h theoretically allowed to choose among UTF-8/16/32 * for string processing, and among unsafe/safe/strict default macros for that. * * It proved nearly impossible to write non-trivial, high-performance code * that is UTF-generic. * Unsafe default macros would be dangerous for default string processing, * and the main reason for the "strict" versions disappeared: * Between Unicode 3.0 and 3.2 all "irregular" UTF-8 sequences became illegal. * The only other conditions that "strict" checked for were non-characters, * which are valid during processing. Only during text input/output should they * be checked, and at that time other well-formedness checks may be * necessary or useful as well. * This can still be done by using U16_NEXT and U_IS_UNICODE_NONCHAR * or U_IS_UNICODE_CHAR. * * The old UTF8_..._SAFE macros also used some normal Unicode code points * to indicate malformed sequences. * The new UTF8_ macros without suffix use negative values instead. * * The entire contents of utf32.h was moved here without replacement * because all those macros were trivial and * were meaningful only in the framework of choosing the UTF size. * * See Jitterbug 2150 and its discussion on the ICU mailing list * in September 2002. * * <hr> * * <em>Obsolete part</em> of pre-ICU 2.4 utf.h file documentation: * * <p>The original concept for these files was for ICU to allow * in principle to set which UTF (UTF-8/16/32) is used internally * by defining UTF_SIZE to either 8, 16, or 32. utf.h would then define the UChar type * accordingly. UTF-16 was the default.</p> * * <p>This concept has been abandoned. * A lot of the ICU source code &#8212; especially low-level code like * conversion, normalization, and collation &#8212; assumes UTF-16, * utf.h enforces the default of UTF-16. * The UTF-8 and UTF-32 macros remain for now for completeness and backward compatibility.</p> * * <p>Accordingly, utf.h defines UChar to be an unsigned 16-bit integer. If this matches wchar_t, then * UChar is defined to be exactly wchar_t, otherwise uint16_t.</p> * * <p>UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit * Unicode code point (Unicode scalar value, 0..0x10ffff). * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as * the definition of UChar. For details see the documentation for UChar32 itself.</p> * * <p>utf.h also defines a number of C macros for handling single Unicode code points and * for using UTF Unicode strings. It includes utf8.h, utf16.h, and utf32.h for the actual * implementations of those macros and then aliases one set of them (for UTF-16) for general use. * The UTF-specific macros have the UTF size in the macro name prefixes (UTF16_...), while * the general alias macros always begin with UTF_...</p> * * <p>Many string operations can be done with or without error checking. * Where such a distinction is useful, there are two versions of the macros, "unsafe" and "safe" * ones with ..._UNSAFE and ..._SAFE suffixes. The unsafe macros are fast but may cause * program failures if the strings are not well-formed. The safe macros have an additional, boolean * parameter "strict". If strict is FALSE, then only illegal sequences are detected. * Otherwise, irregular sequences and non-characters are detected as well (like single surrogates). * Safe macros return special error code points for illegal/irregular sequences: * Typically, U+ffff, or values that would result in a code unit sequence of the same length * as the erroneous input sequence.<br> * Note that _UNSAFE macros have fewer parameters: They do not have the strictness parameter, and * they do not have start/length parameters for boundary checking.</p> * * <p>Here, the macros are aliased in two steps: * In the first step, the UTF-specific macros with UTF16_ prefix and _UNSAFE and _SAFE suffixes are * aliased according to the UTF_SIZE to macros with UTF_ prefix and the same suffixes and signatures. * Then, in a second step, the default, general alias macros are set to use either the unsafe or * the safe/not strict (default) or the safe/strict macro; * these general macros do not have a strictness parameter.</p> * * <p>It is possible to change the default choice for the general alias macros to be unsafe, safe/not strict or safe/strict. * The default is safe/not strict. It is not recommended to select the unsafe macros as the basis for * Unicode string handling in ICU! To select this, define UTF_SAFE, UTF_STRICT, or UTF_UNSAFE.</p> * * <p>For general use, one should use the default, general macros with UTF_ prefix and no _SAFE/_UNSAFE suffix. * Only in some cases it may be necessary to control the choice of macro directly and use a less generic alias. * For example, if it can be assumed that a string is well-formed and the index will stay within the bounds, * then the _UNSAFE version may be used. * If a UTF-8 string is to be processed, then the macros with UTF8_ prefixes need to be used.</p> * * <hr> * * @deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead. */ #ifndef __UTF_OLD_H__ #define __UTF_OLD_H__ #ifndef U_HIDE_DEPRECATED_API /* utf.h must be included first. */ #ifndef __UTF_H__ # include "utf.h" #endif /* Formerly utf.h, part 1 --------------------------------------------------- */ #ifdef U_USE_UTF_DEPRECATES /** * Unicode string and array offset and index type. * ICU always counts Unicode code units (UChars) for * string offsets, indexes, and lengths, not Unicode code points. * * @obsolete ICU 2.6. Use int32_t directly instead since this API will be removed in that release. */ typedef int32_t UTextOffset; #endif /** Number of bits in a Unicode string code unit - ICU uses 16-bit Unicode. @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF_SIZE 16 /** * The default choice for general Unicode string macros is to use the ..._SAFE macro implementations * with strict=FALSE. * * @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF_SAFE /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #undef UTF_UNSAFE /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #undef UTF_STRICT /** * <p>UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8, * which need 1 or 2 bytes in UTF-8:<br> * U+0015 = NAK = Negative Acknowledge, C0 control character<br> * U+009f = highest C1 control character</p> * * <p>These are used by UTF8_..._SAFE macros so that they can return an error value * that needs the same number of code units (bytes) as were seen by * a macro. They should be tested with UTF_IS_ERROR() or UTF_IS_VALID().</p> * * @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF8_ERROR_VALUE_1 0x15 /** * See documentation on UTF8_ERROR_VALUE_1 for details. * * @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF8_ERROR_VALUE_2 0x9f /** * Error value for all UTFs. This code point value will be set by macros with error * checking if an error is detected. * * @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF_ERROR_VALUE 0xffff /** * Is a given 32-bit code an error value * as returned by one of the macros for any UTF? * * @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF_IS_ERROR(c) \ (((c)&0xfffe)==0xfffe || (c)==UTF8_ERROR_VALUE_1 || (c)==UTF8_ERROR_VALUE_2) /** * This is a combined macro: Is c a valid Unicode value _and_ not an error code? * * @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF_IS_VALID(c) \ (UTF_IS_UNICODE_CHAR(c) && \ (c)!=UTF8_ERROR_VALUE_1 && (c)!=UTF8_ERROR_VALUE_2) /** * Is this code unit or code point a surrogate (U+d800..U+dfff)? * @deprecated ICU 2.4. Renamed to U_IS_SURROGATE and U16_IS_SURROGATE, see utf_old.h. */ #define UTF_IS_SURROGATE(uchar) (((uchar)&0xfffff800)==0xd800) /** * Is a given 32-bit code point a Unicode noncharacter? * * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_NONCHAR, see utf_old.h. */ #define UTF_IS_UNICODE_NONCHAR(c) \ ((c)>=0xfdd0 && \ ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \ (uint32_t)(c)<=0x10ffff) /** * Is a given 32-bit value a Unicode code point value (0..U+10ffff) * that can be assigned a character? * * Code points that are not characters include: * - single surrogate code points (U+d800..U+dfff, 2048 code points) * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points) * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points) * - the highest Unicode code point value is U+10ffff * * This means that all code points below U+d800 are character code points, * and that boundary is tested first for performance. * * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_CHAR, see utf_old.h. */ #define UTF_IS_UNICODE_CHAR(c) \ ((uint32_t)(c)<0xd800 || \ ((uint32_t)(c)>0xdfff && \ (uint32_t)(c)<=0x10ffff && \ !UTF_IS_UNICODE_NONCHAR(c))) /* Formerly utf8.h ---------------------------------------------------------- */ /** * Count the trail bytes for a UTF-8 lead byte. * @deprecated ICU 2.4. Renamed to U8_COUNT_TRAIL_BYTES, see utf_old.h. */ #define UTF8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte]) /** * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value. * @deprecated ICU 2.4. Renamed to U8_MASK_LEAD_BYTE, see utf_old.h. */ #define UTF8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1) /** Is this this code point a single code unit (byte)? @deprecated ICU 2.4. Renamed to U8_IS_SINGLE, see utf_old.h. */ #define UTF8_IS_SINGLE(uchar) (((uchar)&0x80)==0) /** Is this this code unit the lead code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_LEAD, see utf_old.h. */ #define UTF8_IS_LEAD(uchar) ((uint8_t)((uchar)-0xc0)<0x3e) /** Is this this code unit a trailing code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_TRAIL, see utf_old.h. */ #define UTF8_IS_TRAIL(uchar) (((uchar)&0xc0)==0x80) /** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U8_LENGTH or test ((uint32_t)(c)>0x7f) instead, see utf_old.h. */ #define UTF8_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0x7f) /** * Given the lead character, how many bytes are taken by this code point. * ICU does not deal with code points >0x10ffff * unless necessary for advancing in the byte stream. * * These length macros take into account that for values >0x10ffff * the UTF8_APPEND_CHAR_SAFE macros would write the error code point 0xffff * with 3 bytes. * Code point comparisons need to be in uint32_t because UChar32 * may be a signed type, and negative values must be recognized. * * @deprecated ICU 2.4. Use U8_LENGTH instead, see utf_old.h. */ #if 1 # define UTF8_CHAR_LENGTH(c) \ ((uint32_t)(c)<=0x7f ? 1 : \ ((uint32_t)(c)<=0x7ff ? 2 : \ ((uint32_t)((c)-0x10000)>0xfffff ? 3 : 4) \ ) \ ) #else # define UTF8_CHAR_LENGTH(c) \ ((uint32_t)(c)<=0x7f ? 1 : \ ((uint32_t)(c)<=0x7ff ? 2 : \ ((uint32_t)(c)<=0xffff ? 3 : \ ((uint32_t)(c)<=0x10ffff ? 4 : \ ((uint32_t)(c)<=0x3ffffff ? 5 : \ ((uint32_t)(c)<=0x7fffffff ? 6 : 3) \ ) \ ) \ ) \ ) \ ) #endif /** The maximum number of bytes per code point. @deprecated ICU 2.4. Renamed to U8_MAX_LENGTH, see utf_old.h. */ #define UTF8_MAX_CHAR_LENGTH 4 /** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF8_ARRAY_SIZE(size) ((5*(size))/2) /** @deprecated ICU 2.4. Renamed to U8_GET_UNSAFE, see utf_old.h. */ #define UTF8_GET_CHAR_UNSAFE(s, i, c) { \ int32_t _utf8_get_char_unsafe_index=(int32_t)(i); \ UTF8_SET_CHAR_START_UNSAFE(s, _utf8_get_char_unsafe_index); \ UTF8_NEXT_CHAR_UNSAFE(s, _utf8_get_char_unsafe_index, c); \ } /** @deprecated ICU 2.4. Use U8_GET instead, see utf_old.h. */ #define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ int32_t _utf8_get_char_safe_index=(int32_t)(i); \ UTF8_SET_CHAR_START_SAFE(s, start, _utf8_get_char_safe_index); \ UTF8_NEXT_CHAR_SAFE(s, _utf8_get_char_safe_index, length, c, strict); \ } /** @deprecated ICU 2.4. Renamed to U8_NEXT_UNSAFE, see utf_old.h. */ #define UTF8_NEXT_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[(i)++]; \ if((uint8_t)((c)-0xc0)<0x35) { \ uint8_t __count=UTF8_COUNT_TRAIL_BYTES(c); \ UTF8_MASK_LEAD_BYTE(c, __count); \ switch(__count) { \ /* each following branch falls through to the next one */ \ case 3: \ (c)=((c)<<6)|((s)[(i)++]&0x3f); \ case 2: \ (c)=((c)<<6)|((s)[(i)++]&0x3f); \ case 1: \ (c)=((c)<<6)|((s)[(i)++]&0x3f); \ /* no other branches to optimize switch() */ \ break; \ } \ } \ } /** @deprecated ICU 2.4. Renamed to U8_APPEND_UNSAFE, see utf_old.h. */ #define UTF8_APPEND_CHAR_UNSAFE(s, i, c) { \ if((uint32_t)(c)<=0x7f) { \ (s)[(i)++]=(uint8_t)(c); \ } else { \ if((uint32_t)(c)<=0x7ff) { \ (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \ } else { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \ } else { \ (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \ (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \ } \ (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \ } \ (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \ } \ } /** @deprecated ICU 2.4. Renamed to U8_FWD_1_UNSAFE, see utf_old.h. */ #define UTF8_FWD_1_UNSAFE(s, i) { \ (i)+=1+UTF8_COUNT_TRAIL_BYTES((s)[i]); \ } /** @deprecated ICU 2.4. Renamed to U8_FWD_N_UNSAFE, see utf_old.h. */ #define UTF8_FWD_N_UNSAFE(s, i, n) { \ int32_t __N=(n); \ while(__N>0) { \ UTF8_FWD_1_UNSAFE(s, i); \ --__N; \ } \ } /** @deprecated ICU 2.4. Renamed to U8_SET_CP_START_UNSAFE, see utf_old.h. */ #define UTF8_SET_CHAR_START_UNSAFE(s, i) { \ while(UTF8_IS_TRAIL((s)[i])) { --(i); } \ } /** @deprecated ICU 2.4. Use U8_NEXT instead, see utf_old.h. */ #define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ (c)=(s)[(i)++]; \ if((c)>=0x80) { \ if(UTF8_IS_LEAD(c)) { \ (c)=utf8_nextCharSafeBody(s, &(i), (int32_t)(length), c, strict); \ } else { \ (c)=UTF8_ERROR_VALUE_1; \ } \ } \ } /** @deprecated ICU 2.4. Use U8_APPEND instead, see utf_old.h. */ #define UTF8_APPEND_CHAR_SAFE(s, i, length, c) { \ if((uint32_t)(c)<=0x7f) { \ (s)[(i)++]=(uint8_t)(c); \ } else { \ (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(length), c, NULL); \ } \ } /** @deprecated ICU 2.4. Renamed to U8_FWD_1, see utf_old.h. */ #define UTF8_FWD_1_SAFE(s, i, length) U8_FWD_1(s, i, length) /** @deprecated ICU 2.4. Renamed to U8_FWD_N, see utf_old.h. */ #define UTF8_FWD_N_SAFE(s, i, length, n) U8_FWD_N(s, i, length, n) /** @deprecated ICU 2.4. Renamed to U8_SET_CP_START, see utf_old.h. */ #define UTF8_SET_CHAR_START_SAFE(s, start, i) U8_SET_CP_START(s, start, i) /** @deprecated ICU 2.4. Renamed to U8_PREV_UNSAFE, see utf_old.h. */ #define UTF8_PREV_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[--(i)]; \ if(UTF8_IS_TRAIL(c)) { \ uint8_t __b, __count=1, __shift=6; \ \ /* c is a trail byte */ \ (c)&=0x3f; \ for(;;) { \ __b=(s)[--(i)]; \ if(__b>=0xc0) { \ UTF8_MASK_LEAD_BYTE(__b, __count); \ (c)|=(UChar32)__b<<__shift; \ break; \ } else { \ (c)|=(UChar32)(__b&0x3f)<<__shift; \ ++__count; \ __shift+=6; \ } \ } \ } \ } /** @deprecated ICU 2.4. Renamed to U8_BACK_1_UNSAFE, see utf_old.h. */ #define UTF8_BACK_1_UNSAFE(s, i) { \ while(UTF8_IS_TRAIL((s)[--(i)])) {} \ } /** @deprecated ICU 2.4. Renamed to U8_BACK_N_UNSAFE, see utf_old.h. */ #define UTF8_BACK_N_UNSAFE(s, i, n) { \ int32_t __N=(n); \ while(__N>0) { \ UTF8_BACK_1_UNSAFE(s, i); \ --__N; \ } \ } /** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT_UNSAFE, see utf_old.h. */ #define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) { \ UTF8_BACK_1_UNSAFE(s, i); \ UTF8_FWD_1_UNSAFE(s, i); \ } /** @deprecated ICU 2.4. Use U8_PREV instead, see utf_old.h. */ #define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) { \ (c)=(s)[--(i)]; \ if((c)>=0x80) { \ if((c)<=0xbf) { \ (c)=utf8_prevCharSafeBody(s, start, &(i), c, strict); \ } else { \ (c)=UTF8_ERROR_VALUE_1; \ } \ } \ } /** @deprecated ICU 2.4. Renamed to U8_BACK_1, see utf_old.h. */ #define UTF8_BACK_1_SAFE(s, start, i) U8_BACK_1(s, start, i) /** @deprecated ICU 2.4. Renamed to U8_BACK_N, see utf_old.h. */ #define UTF8_BACK_N_SAFE(s, start, i, n) U8_BACK_N(s, start, i, n) /** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT, see utf_old.h. */ #define UTF8_SET_CHAR_LIMIT_SAFE(s, start, i, length) U8_SET_CP_LIMIT(s, start, i, length) /* Formerly utf16.h --------------------------------------------------------- */ /** Is uchar a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h. */ #define UTF_IS_FIRST_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xd800) /** Is uchar a second/trail surrogate? @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h. */ #define UTF_IS_SECOND_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xdc00) /** Assuming c is a surrogate, is it a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_SURROGATE_LEAD and U16_IS_SURROGATE_LEAD, see utf_old.h. */ #define UTF_IS_SURROGATE_FIRST(c) (((c)&0x400)==0) /** Helper constant for UTF16_GET_PAIR_VALUE. @deprecated ICU 2.4. Renamed to U16_SURROGATE_OFFSET, see utf_old.h. */ #define UTF_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000) /** Get the UTF-32 value from the surrogate code units. @deprecated ICU 2.4. Renamed to U16_GET_SUPPLEMENTARY, see utf_old.h. */ #define UTF16_GET_PAIR_VALUE(first, second) \ (((first)<<10UL)+(second)-UTF_SURROGATE_OFFSET) /** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */ #define UTF_FIRST_SURROGATE(supplementary) (UChar)(((supplementary)>>10)+0xd7c0) /** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */ #define UTF_SECOND_SURROGATE(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00) /** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */ #define UTF16_LEAD(supplementary) UTF_FIRST_SURROGATE(supplementary) /** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */ #define UTF16_TRAIL(supplementary) UTF_SECOND_SURROGATE(supplementary) /** @deprecated ICU 2.4. Renamed to U16_IS_SINGLE, see utf_old.h. */ #define UTF16_IS_SINGLE(uchar) !UTF_IS_SURROGATE(uchar) /** @deprecated ICU 2.4. Renamed to U16_IS_LEAD, see utf_old.h. */ #define UTF16_IS_LEAD(uchar) UTF_IS_FIRST_SURROGATE(uchar) /** @deprecated ICU 2.4. Renamed to U16_IS_TRAIL, see utf_old.h. */ #define UTF16_IS_TRAIL(uchar) UTF_IS_SECOND_SURROGATE(uchar) /** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead, see utf_old.h. */ #define UTF16_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0xffff) /** @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h. */ #define UTF16_CHAR_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2) /** @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h. */ #define UTF16_MAX_CHAR_LENGTH 2 /** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF16_ARRAY_SIZE(size) (size) /** * Get a single code point from an offset that points to any * of the code units that belong to that code point. * Assume 0<=i<length. * * This could be used for iteration together with * UTF16_CHAR_LENGTH() and UTF_IS_ERROR(), * but the use of UTF16_NEXT_CHAR[_UNSAFE]() and * UTF16_PREV_CHAR[_UNSAFE]() is more efficient for that. * @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */ #define UTF16_GET_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[i]; \ if(UTF_IS_SURROGATE(c)) { \ if(UTF_IS_SURROGATE_FIRST(c)) { \ (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)+1]); \ } else { \ (c)=UTF16_GET_PAIR_VALUE((s)[(i)-1], (c)); \ } \ } \ } /** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */ #define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ (c)=(s)[i]; \ if(UTF_IS_SURROGATE(c)) { \ uint16_t __c2; \ if(UTF_IS_SURROGATE_FIRST(c)) { \ if((i)+1<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)+1])) { \ (c)=UTF16_GET_PAIR_VALUE((c), __c2); \ /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \ } else if(strict) {\ /* unmatched first surrogate */ \ (c)=UTF_ERROR_VALUE; \ } \ } else { \ if((i)-1>=(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \ (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \ /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \ } else if(strict) {\ /* unmatched second surrogate */ \ (c)=UTF_ERROR_VALUE; \ } \ } \ } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \ (c)=UTF_ERROR_VALUE; \ } \ } /** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */ #define UTF16_NEXT_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[(i)++]; \ if(UTF_IS_FIRST_SURROGATE(c)) { \ (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)++]); \ } \ } /** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */ #define UTF16_APPEND_CHAR_UNSAFE(s, i, c) { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else { \ (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \ (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ } \ } /** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */ #define UTF16_FWD_1_UNSAFE(s, i) { \ if(UTF_IS_FIRST_SURROGATE((s)[(i)++])) { \ ++(i); \ } \ } /** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */ #define UTF16_FWD_N_UNSAFE(s, i, n) { \ int32_t __N=(n); \ while(__N>0) { \ UTF16_FWD_1_UNSAFE(s, i); \ --__N; \ } \ } /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */ #define UTF16_SET_CHAR_START_UNSAFE(s, i) { \ if(UTF_IS_SECOND_SURROGATE((s)[i])) { \ --(i); \ } \ } /** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */ #define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ (c)=(s)[(i)++]; \ if(UTF_IS_FIRST_SURROGATE(c)) { \ uint16_t __c2; \ if((i)<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)])) { \ ++(i); \ (c)=UTF16_GET_PAIR_VALUE((c), __c2); \ /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \ } else if(strict) {\ /* unmatched first surrogate */ \ (c)=UTF_ERROR_VALUE; \ } \ } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \ /* unmatched second surrogate or other non-character */ \ (c)=UTF_ERROR_VALUE; \ } \ } /** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */ #define UTF16_APPEND_CHAR_SAFE(s, i, length, c) { \ if((uint32_t)(c)<=0xffff) { \ (s)[(i)++]=(uint16_t)(c); \ } else if((uint32_t)(c)<=0x10ffff) { \ if((i)+1<(length)) { \ (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \ (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ } else /* not enough space */ { \ (s)[(i)++]=UTF_ERROR_VALUE; \ } \ } else /* c>0x10ffff, write error value */ { \ (s)[(i)++]=UTF_ERROR_VALUE; \ } \ } /** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */ #define UTF16_FWD_1_SAFE(s, i, length) U16_FWD_1(s, i, length) /** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */ #define UTF16_FWD_N_SAFE(s, i, length, n) U16_FWD_N(s, i, length, n) /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */ #define UTF16_SET_CHAR_START_SAFE(s, start, i) U16_SET_CP_START(s, start, i) /** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */ #define UTF16_PREV_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[--(i)]; \ if(UTF_IS_SECOND_SURROGATE(c)) { \ (c)=UTF16_GET_PAIR_VALUE((s)[--(i)], (c)); \ } \ } /** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */ #define UTF16_BACK_1_UNSAFE(s, i) { \ if(UTF_IS_SECOND_SURROGATE((s)[--(i)])) { \ --(i); \ } \ } /** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */ #define UTF16_BACK_N_UNSAFE(s, i, n) { \ int32_t __N=(n); \ while(__N>0) { \ UTF16_BACK_1_UNSAFE(s, i); \ --__N; \ } \ } /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */ #define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) { \ if(UTF_IS_FIRST_SURROGATE((s)[(i)-1])) { \ ++(i); \ } \ } /** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */ #define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) { \ (c)=(s)[--(i)]; \ if(UTF_IS_SECOND_SURROGATE(c)) { \ uint16_t __c2; \ if((i)>(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \ --(i); \ (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \ /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \ } else if(strict) {\ /* unmatched second surrogate */ \ (c)=UTF_ERROR_VALUE; \ } \ } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \ /* unmatched first surrogate or other non-character */ \ (c)=UTF_ERROR_VALUE; \ } \ } /** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */ #define UTF16_BACK_1_SAFE(s, start, i) U16_BACK_1(s, start, i) /** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */ #define UTF16_BACK_N_SAFE(s, start, i, n) U16_BACK_N(s, start, i, n) /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */ #define UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length) /* Formerly utf32.h --------------------------------------------------------- */ /* * Old documentation: * * This file defines macros to deal with UTF-32 code units and code points. * Signatures and semantics are the same as for the similarly named macros * in utf16.h. * utf32.h is included by utf.h after unicode/umachine.h</p> * and some common definitions. * <p><b>Usage:</b> ICU coding guidelines for if() statements should be followed when using these macros. * Compound statements (curly braces {}) must be used for if-else-while... * bodies and all macro statements should be terminated with semicolon.</p> */ /* internal definitions ----------------------------------------------------- */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_IS_SAFE(c, strict) \ (!(strict) ? \ (uint32_t)(c)<=0x10ffff : \ UTF_IS_UNICODE_CHAR(c)) /* * For the semantics of all of these macros, see utf16.h. * The UTF-32 versions are trivial because any code point is * encoded using exactly one code unit. */ /* single-code point definitions -------------------------------------------- */ /* classes of code unit values */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_IS_SINGLE(uchar) 1 /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_IS_LEAD(uchar) 0 /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_IS_TRAIL(uchar) 0 /* number of code units per code point */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_NEED_MULTIPLE_UCHAR(c) 0 /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_CHAR_LENGTH(c) 1 /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_MAX_CHAR_LENGTH 1 /* average number of code units compared to UTF-16 */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_ARRAY_SIZE(size) (size) /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_GET_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[i]; \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \ (c)=(s)[i]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ } /* definitions with forward iteration --------------------------------------- */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[(i)++]; \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \ (s)[(i)++]=(c); \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_FWD_1_UNSAFE(s, i) { \ ++(i); \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_FWD_N_UNSAFE(s, i, n) { \ (i)+=(n); \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_SET_CHAR_START_UNSAFE(s, i) { \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \ (c)=(s)[(i)++]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \ if((uint32_t)(c)<=0x10ffff) { \ (s)[(i)++]=(c); \ } else /* c>0x10ffff, write 0xfffd */ { \ (s)[(i)++]=0xfffd; \ } \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_FWD_1_SAFE(s, i, length) { \ ++(i); \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_FWD_N_SAFE(s, i, length, n) { \ if(((i)+=(n))>(length)) { \ (i)=(length); \ } \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_SET_CHAR_START_SAFE(s, start, i) { \ } /* definitions with backward iteration -------------------------------------- */ /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \ (c)=(s)[--(i)]; \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_BACK_1_UNSAFE(s, i) { \ --(i); \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_BACK_N_UNSAFE(s, i, n) { \ (i)-=(n); \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \ (c)=(s)[--(i)]; \ if(!UTF32_IS_SAFE(c, strict)) { \ (c)=UTF_ERROR_VALUE; \ } \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_BACK_1_SAFE(s, start, i) { \ --(i); \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_BACK_N_SAFE(s, start, i, n) { \ (i)-=(n); \ if((i)<(start)) { \ (i)=(start); \ } \ } /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \ } /* Formerly utf.h, part 2 --------------------------------------------------- */ /** * Estimate the number of code units for a string based on the number of UTF-16 code units. * * @deprecated ICU 2.4. Obsolete, see utf_old.h. */ #define UTF_ARRAY_SIZE(size) UTF16_ARRAY_SIZE(size) /** @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */ #define UTF_GET_CHAR_UNSAFE(s, i, c) UTF16_GET_CHAR_UNSAFE(s, i, c) /** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */ #define UTF_GET_CHAR_SAFE(s, start, i, length, c, strict) UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) /** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */ #define UTF_NEXT_CHAR_UNSAFE(s, i, c) UTF16_NEXT_CHAR_UNSAFE(s, i, c) /** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */ #define UTF_NEXT_CHAR_SAFE(s, i, length, c, strict) UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) /** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */ #define UTF_APPEND_CHAR_UNSAFE(s, i, c) UTF16_APPEND_CHAR_UNSAFE(s, i, c) /** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */ #define UTF_APPEND_CHAR_SAFE(s, i, length, c) UTF16_APPEND_CHAR_SAFE(s, i, length, c) /** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */ #define UTF_FWD_1_UNSAFE(s, i) UTF16_FWD_1_UNSAFE(s, i) /** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */ #define UTF_FWD_1_SAFE(s, i, length) UTF16_FWD_1_SAFE(s, i, length) /** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */ #define UTF_FWD_N_UNSAFE(s, i, n) UTF16_FWD_N_UNSAFE(s, i, n) /** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */ #define UTF_FWD_N_SAFE(s, i, length, n) UTF16_FWD_N_SAFE(s, i, length, n) /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */ #define UTF_SET_CHAR_START_UNSAFE(s, i) UTF16_SET_CHAR_START_UNSAFE(s, i) /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */ #define UTF_SET_CHAR_START_SAFE(s, start, i) UTF16_SET_CHAR_START_SAFE(s, start, i) /** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */ #define UTF_PREV_CHAR_UNSAFE(s, i, c) UTF16_PREV_CHAR_UNSAFE(s, i, c) /** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */ #define UTF_PREV_CHAR_SAFE(s, start, i, c, strict) UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) /** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */ #define UTF_BACK_1_UNSAFE(s, i) UTF16_BACK_1_UNSAFE(s, i) /** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */ #define UTF_BACK_1_SAFE(s, start, i) UTF16_BACK_1_SAFE(s, start, i) /** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */ #define UTF_BACK_N_UNSAFE(s, i, n) UTF16_BACK_N_UNSAFE(s, i, n) /** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */ #define UTF_BACK_N_SAFE(s, start, i, n) UTF16_BACK_N_SAFE(s, start, i, n) /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */ #define UTF_SET_CHAR_LIMIT_UNSAFE(s, i) UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */ #define UTF_SET_CHAR_LIMIT_SAFE(s, start, i, length) UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length) /* Define default macros (UTF-16 "safe") ------------------------------------ */ /** * Does this code unit alone encode a code point (BMP, not a surrogate)? * Same as UTF16_IS_SINGLE. * @deprecated ICU 2.4. Renamed to U_IS_SINGLE and U16_IS_SINGLE, see utf_old.h. */ #define UTF_IS_SINGLE(uchar) U16_IS_SINGLE(uchar) /** * Is this code unit the first one of several (a lead surrogate)? * Same as UTF16_IS_LEAD. * @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h. */ #define UTF_IS_LEAD(uchar) U16_IS_LEAD(uchar) /** * Is this code unit one of several but not the first one (a trail surrogate)? * Same as UTF16_IS_TRAIL. * @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h. */ #define UTF_IS_TRAIL(uchar) U16_IS_TRAIL(uchar) /** * Does this code point require multiple code units (is it a supplementary code point)? * Same as UTF16_NEED_MULTIPLE_UCHAR. * @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead. */ #define UTF_NEED_MULTIPLE_UCHAR(c) UTF16_NEED_MULTIPLE_UCHAR(c) /** * How many code units are used to encode this code point (1 or 2)? * Same as UTF16_CHAR_LENGTH. * @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h. */ #define UTF_CHAR_LENGTH(c) U16_LENGTH(c) /** * How many code units are used at most for any Unicode code point (2)? * Same as UTF16_MAX_CHAR_LENGTH. * @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h. */ #define UTF_MAX_CHAR_LENGTH U16_MAX_LENGTH /** * Set c to the code point that contains the code unit i. * i could point to the lead or the trail surrogate for the code point. * i is not modified. * Same as UTF16_GET_CHAR. * \pre 0<=i<length * * @deprecated ICU 2.4. Renamed to U16_GET, see utf_old.h. */ #define UTF_GET_CHAR(s, start, i, length, c) U16_GET(s, start, i, length, c) /** * Set c to the code point that starts at code unit i * and advance i to beyond the code units of this code point (post-increment). * i must point to the first code unit of a code point. * Otherwise c is set to the trail unit (surrogate) itself. * Same as UTF16_NEXT_CHAR. * \pre 0<=i<length * \post 0<i<=length * * @deprecated ICU 2.4. Renamed to U16_NEXT, see utf_old.h. */ #define UTF_NEXT_CHAR(s, i, length, c) U16_NEXT(s, i, length, c) /** * Append the code units of code point c to the string at index i * and advance i to beyond the new code units (post-increment). * The code units beginning at index i will be overwritten. * Same as UTF16_APPEND_CHAR. * \pre 0<=c<=0x10ffff * \pre 0<=i<length * \post 0<i<=length * * @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */ #define UTF_APPEND_CHAR(s, i, length, c) UTF16_APPEND_CHAR_SAFE(s, i, length, c) /** * Advance i to beyond the code units of the code point that begins at i. * I.e., advance i by one code point. * Same as UTF16_FWD_1. * \pre 0<=i<length * \post 0<i<=length * * @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */ #define UTF_FWD_1(s, i, length) U16_FWD_1(s, i, length) /** * Advance i to beyond the code units of the n code points where the first one begins at i. * I.e., advance i by n code points. * Same as UT16_FWD_N. * \pre 0<=i<length * \post 0<i<=length * * @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */ #define UTF_FWD_N(s, i, length, n) U16_FWD_N(s, i, length, n) /** * Take the random-access index i and adjust it so that it points to the beginning * of a code point. * The input index points to any code unit of a code point and is moved to point to * the first code unit of the same code point. i is never incremented. * In other words, if i points to a trail surrogate that is preceded by a matching * lead surrogate, then i is decremented. Otherwise it is not modified. * This can be used to start an iteration with UTF_NEXT_CHAR() from a random index. * Same as UTF16_SET_CHAR_START. * \pre start<=i<length * \post start<=i<length * * @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */ #define UTF_SET_CHAR_START(s, start, i) U16_SET_CP_START(s, start, i) /** * Set c to the code point that has code units before i * and move i backward (towards the beginning of the string) * to the first code unit of this code point (pre-increment). * i must point to the first code unit after the last unit of a code point (i==length is allowed). * Same as UTF16_PREV_CHAR. * \pre start<i<=length * \post start<=i<length * * @deprecated ICU 2.4. Renamed to U16_PREV, see utf_old.h. */ #define UTF_PREV_CHAR(s, start, i, c) U16_PREV(s, start, i, c) /** * Move i backward (towards the beginning of the string) * to the first code unit of the code point that has code units before i. * I.e., move i backward by one code point. * i must point to the first code unit after the last unit of a code point (i==length is allowed). * Same as UTF16_BACK_1. * \pre start<i<=length * \post start<=i<length * * @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */ #define UTF_BACK_1(s, start, i) U16_BACK_1(s, start, i) /** * Move i backward (towards the beginning of the string) * to the first code unit of the n code points that have code units before i. * I.e., move i backward by n code points. * i must point to the first code unit after the last unit of a code point (i==length is allowed). * Same as UTF16_BACK_N. * \pre start<i<=length * \post start<=i<length * * @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */ #define UTF_BACK_N(s, start, i, n) U16_BACK_N(s, start, i, n) /** * Take the random-access index i and adjust it so that it points beyond * a code point. The input index points beyond any code unit * of a code point and is moved to point beyond the last code unit of the same * code point. i is never decremented. * In other words, if i points to a trail surrogate that is preceded by a matching * lead surrogate, then i is incremented. Otherwise it is not modified. * This can be used to start an iteration with UTF_PREV_CHAR() from a random index. * Same as UTF16_SET_CHAR_LIMIT. * \pre start<i<=length * \post start<i<=length * * @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */ #define UTF_SET_CHAR_LIMIT(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length) #endif /* U_HIDE_DEPRECATED_API */ #endif
43,525
C++
.h
999
39.980981
166
0.62755
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
33,952
sndfile.h
supercollider_supercollider/external_libraries/libsndfile/sndfile.h
/* ** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by ** the Free Software Foundation; either version 2.1 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Lesser General Public License for more details. ** ** You should have received a copy of the GNU Lesser General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* ** sndfile.h -- system-wide definitions ** ** API documentation is in the doc/ directory of the source code tarball ** and at http://www.mega-nerd.com/libsndfile/api.html. */ #ifndef SNDFILE_H #define SNDFILE_H /* This is the version 1.0.X header file. */ #define SNDFILE_1 #include <stdio.h> #include <sys/types.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* The following file types can be read and written. ** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise ** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and ** SF_FORMAT_SUBMASK can be used to separate the major and minor file ** types. */ enum { /* Major formats. */ SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian default). */ SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */ SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */ SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */ SF_FORMAT_VOC = 0x080000, /* VOC files. */ SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */ SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */ SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */ SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */ SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */ SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */ SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */ SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */ SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */ SF_FORMAT_CAF = 0x180000, /* Core Audio File format */ SF_FORMAT_WVE = 0x190000, /* Psion WVE format */ SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */ SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */ SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */ /* Subtypes from here on. */ SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */ SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */ SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */ SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */ SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */ SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */ SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */ SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */ SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */ SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */ SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */ SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */ SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */ SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */ SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */ SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */ SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */ SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */ SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */ SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ /* Endian-ness options. */ SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */ SF_FORMAT_SUBMASK = 0x0000FFFF, SF_FORMAT_TYPEMASK = 0x0FFF0000, SF_FORMAT_ENDMASK = 0x30000000 } ; /* ** The following are the valid command numbers for the sf_command() ** interface. The use of these commands is documented in the file ** command.html in the doc directory of the source code distribution. */ enum { SFC_GET_LIB_VERSION = 0x1000, SFC_GET_LOG_INFO = 0x1001, SFC_GET_CURRENT_SF_INFO = 0x1002, SFC_GET_NORM_DOUBLE = 0x1010, SFC_GET_NORM_FLOAT = 0x1011, SFC_SET_NORM_DOUBLE = 0x1012, SFC_SET_NORM_FLOAT = 0x1013, SFC_SET_SCALE_FLOAT_INT_READ = 0x1014, SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015, SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, SFC_GET_SIMPLE_FORMAT = 0x1021, SFC_GET_FORMAT_INFO = 0x1028, SFC_GET_FORMAT_MAJOR_COUNT = 0x1030, SFC_GET_FORMAT_MAJOR = 0x1031, SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032, SFC_GET_FORMAT_SUBTYPE = 0x1033, SFC_CALC_SIGNAL_MAX = 0x1040, SFC_CALC_NORM_SIGNAL_MAX = 0x1041, SFC_CALC_MAX_ALL_CHANNELS = 0x1042, SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, SFC_GET_SIGNAL_MAX = 0x1044, SFC_GET_MAX_ALL_CHANNELS = 0x1045, SFC_SET_ADD_PEAK_CHUNK = 0x1050, SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051, SFC_UPDATE_HEADER_NOW = 0x1060, SFC_SET_UPDATE_HEADER_AUTO = 0x1061, SFC_FILE_TRUNCATE = 0x1080, SFC_SET_RAW_START_OFFSET = 0x1090, SFC_SET_DITHER_ON_WRITE = 0x10A0, SFC_SET_DITHER_ON_READ = 0x10A1, SFC_GET_DITHER_INFO_COUNT = 0x10A2, SFC_GET_DITHER_INFO = 0x10A3, SFC_GET_EMBED_FILE_INFO = 0x10B0, SFC_SET_CLIPPING = 0x10C0, SFC_GET_CLIPPING = 0x10C1, SFC_GET_INSTRUMENT = 0x10D0, SFC_SET_INSTRUMENT = 0x10D1, SFC_GET_LOOP_INFO = 0x10E0, SFC_GET_BROADCAST_INFO = 0x10F0, SFC_SET_BROADCAST_INFO = 0x10F1, SFC_GET_CHANNEL_MAP_INFO = 0x1100, SFC_SET_CHANNEL_MAP_INFO = 0x1101, SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110, /* Support for Wavex Ambisonics Format */ SFC_WAVEX_SET_AMBISONIC = 0x1200, SFC_WAVEX_GET_AMBISONIC = 0x1201, SFC_SET_VBR_ENCODING_QUALITY = 0x1300, /* Following commands for testing only. */ SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, /* ** SFC_SET_ADD_* values are deprecated and will disappear at some ** time in the future. They are guaranteed to be here up to and ** including version 1.0.8 to avoid breakage of existng software. ** They currently do nothing and will continue to do nothing. */ SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, SFC_SET_ADD_DITHER_ON_READ = 0x1071 } ; /* ** String types that can be set and read from files. Not all file types ** support this and even the file types which support one, may not support ** all string types. */ enum { SF_STR_TITLE = 0x01, SF_STR_COPYRIGHT = 0x02, SF_STR_SOFTWARE = 0x03, SF_STR_ARTIST = 0x04, SF_STR_COMMENT = 0x05, SF_STR_DATE = 0x06, SF_STR_ALBUM = 0x07, SF_STR_LICENSE = 0x08 } ; /* ** Use the following as the start and end index when doing metadata ** transcoding. */ #define SF_STR_FIRST SF_STR_TITLE #define SF_STR_LAST SF_STR_LICENSE enum { /* True and false */ SF_FALSE = 0, SF_TRUE = 1, /* Modes for opening files. */ SFM_READ = 0x10, SFM_WRITE = 0x20, SFM_RDWR = 0x30, SF_AMBISONIC_NONE = 0x40, SF_AMBISONIC_B_FORMAT = 0x41 } ; /* Public error values. These are guaranteed to remain unchanged for the duration ** of the library major version number. ** There are also a large number of private error numbers which are internal to ** the library which can change at any time. */ enum { SF_ERR_NO_ERROR = 0, SF_ERR_UNRECOGNISED_FORMAT = 1, SF_ERR_SYSTEM = 2, SF_ERR_MALFORMED_FILE = 3, SF_ERR_UNSUPPORTED_ENCODING = 4 } ; /* Channel map values (used with SFC_SET/GET_CHANNEL_MAP). */ enum { SF_CHANNEL_MAP_INVALID = 0, SF_CHANNEL_MAP_MONO = 1, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_FRONT_LEFT, SF_CHANNEL_MAP_FRONT_RIGHT, SF_CHANNEL_MAP_FRONT_CENTER, SF_CHANNEL_MAP_REAR_CENTER, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, SF_CHANNEL_MAP_SIDE_LEFT, SF_CHANNEL_MAP_SIDE_RIGHT, SF_CHANNEL_MAP_TOP_CENTER, SF_CHANNEL_MAP_TOP_FRONT_LEFT, SF_CHANNEL_MAP_TOP_FRONT_RIGHT, SF_CHANNEL_MAP_TOP_FRONT_CENTER, SF_CHANNEL_MAP_TOP_REAR_LEFT, SF_CHANNEL_MAP_TOP_REAR_RIGHT, SF_CHANNEL_MAP_TOP_REAR_CENTER } ; /* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ typedef struct SNDFILE_tag SNDFILE ; /* The following typedef is system specific and is defined when libsndfile is ** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), off64_t ** (Solaris), __int64_t (Win32) etc. On windows, we need to allow the same ** header file to be compiler by both GCC and the microsoft compiler. */ #if (defined (_MSCVER) || defined (_MSC_VER)) typedef __int64_t sf_count_t ; #define SF_COUNT_MAX 0x7fffffffffffffffi64 #else typedef off_t sf_count_t ; #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL #endif /* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. ** On write, the SF_INFO structure is filled in by the user and passed into ** sf_open_write (). */ struct SF_INFO { sf_count_t frames ; /* Used to be called samples. Changed to avoid confusion. */ int samplerate ; int channels ; int format ; int sections ; int seekable ; } ; typedef struct SF_INFO SF_INFO ; /* The SF_FORMAT_INFO struct is used to retrieve information about the sound ** file formats libsndfile supports using the sf_command () interface. ** ** Using this interface will allow applications to support new file formats ** and encoding types when libsndfile is upgraded, without requiring ** re-compilation of the application. ** ** Please consult the libsndfile documentation (particularly the information ** on the sf_command () interface) for examples of its use. */ typedef struct { int format ; const char *name ; const char *extension ; } SF_FORMAT_INFO ; /* ** Enums and typedefs for adding dither on read and write. ** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE ** and SFC_SET_DITHER_ON_READ. */ enum { SFD_DEFAULT_LEVEL = 0, SFD_CUSTOM_LEVEL = 0x40000000, SFD_NO_DITHER = 500, SFD_WHITE = 501, SFD_TRIANGULAR_PDF = 502 } ; typedef struct { int type ; double level ; const char *name ; } SF_DITHER_INFO ; /* Struct used to retrieve information about a file embedded within a ** larger file. See SFC_GET_EMBED_FILE_INFO. */ typedef struct { sf_count_t offset ; sf_count_t length ; } SF_EMBED_FILE_INFO ; /* ** Structs used to retrieve music sample information from a file. */ enum { /* ** The loop mode field in SF_INSTRUMENT will be one of the following. */ SF_LOOP_NONE = 800, SF_LOOP_FORWARD, SF_LOOP_BACKWARD, SF_LOOP_ALTERNATING } ; typedef struct { int gain ; char basenote, detune ; char velocity_lo, velocity_hi ; char key_lo, key_hi ; int loop_count ; struct { int mode ; unsigned int start ; unsigned int end ; unsigned int count ; } loops [16] ; /* make variable in a sensible way */ } SF_INSTRUMENT ; /* Struct used to retrieve loop information from a file.*/ typedef struct { short time_sig_num ; /* any positive integer > 0 */ short time_sig_den ; /* any positive power of 2 > 0 */ int loop_mode ; /* see SF_LOOP enum */ int num_beats ; /* this is NOT the amount of quarter notes !!!*/ /* a full bar of 4/4 is 4 beats */ /* a full bar of 7/8 is 7 beats */ float bpm ; /* suggestion, as it can be calculated using other fields:*/ /* file's lenght, file's sampleRate and our time_sig_den*/ /* -> bpms are always the amount of _quarter notes_ per minute */ int root_key ; /* MIDI note, or -1 for None */ int future [6] ; } SF_LOOP_INFO ; /* Struct used to retrieve broadcast (EBU) information from a file. ** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE. */ #define SF_BROADCAST_INFO_VAR(coding_hist_size) \ struct \ { char description [256] ; \ char originator [32] ; \ char originator_reference [32] ; \ char origination_date [10] ; \ char origination_time [8] ; \ unsigned int time_reference_low ; \ unsigned int time_reference_high ; \ short version ; \ char umid [64] ; \ char reserved [190] ; \ unsigned int coding_history_size ; \ char coding_history [coding_hist_size] ; \ } /* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */ typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ; /* Virtual I/O functionality. */ typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; typedef sf_count_t (*sf_vio_tell) (void *user_data) ; struct SF_VIRTUAL_IO { sf_vio_get_filelen get_filelen ; sf_vio_seek seek ; sf_vio_read read ; sf_vio_write write ; sf_vio_tell tell ; } ; typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; /* Open the specified file for read, write or both. On error, this will ** return a NULL pointer. To find the error number, pass a NULL SNDFILE ** to sf_strerror (). ** All calls to sf_open() should be matched with a call to sf_close(). */ SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; /* Use the existing file descriptor to create a SNDFILE object. If close_desc ** is TRUE, the file descriptor will be closed when sf_close() is called. If ** it is FALSE, the descritor will not be closed. ** When passed a descriptor like this, the library will assume that the start ** of file header is at the current file offset. This allows sound files within ** larger container files to be read and/or written. ** On error, this will return a NULL pointer. To find the error number, pass a ** NULL SNDFILE to sf_strerror (). ** All calls to sf_open_fd() should be matched with a call to sf_close(). */ SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; /* sf_error () returns a error number which can be translated to a text ** string using sf_error_number(). */ int sf_error (SNDFILE *sndfile) ; /* sf_strerror () returns to the caller a pointer to the current error message for ** the given SNDFILE. */ const char* sf_strerror (SNDFILE *sndfile) ; /* sf_error_number () allows the retrieval of the error string for each internal ** error number. ** */ const char* sf_error_number (int errnum) ; /* The following two error functions are deprecated but they will remain in the ** library for the forseeable future. The function sf_strerror() should be used ** in their place. */ int sf_perror (SNDFILE *sndfile) ; int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ int sf_format_check (const SF_INFO *info) ; /* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses ** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as ** stdio.h function fseek (). ** An offset of zero with whence set to SEEK_SET will position the ** read / write pointer to the first data sample. ** On success sf_seek returns the current position in (multi-channel) ** samples from the start of the file. ** Please see the libsndfile documentation for moving the read pointer ** separately from the write pointer on files open in mode SFM_RDWR. ** On error all of these functions return -1. */ sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; /* Functions for retrieving and setting string data within sound files. ** Not all file types support this features; AIFF and WAV do. For both ** functions, the str_type parameter must be one of the SF_STR_* values ** defined above. ** On error, sf_set_string() returns non-zero while sf_get_string() ** returns NULL. */ int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; const char* sf_get_string (SNDFILE *sndfile, int str_type) ; /* Return the library version string. */ const char * sf_version_string (void) ; /* Functions for reading/writing the waveform data of a sound file. */ sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; /* Functions for reading and writing the data chunk in terms of frames. ** The number of items actually read/written = frames * number of channels. ** sf_xxxx_raw read/writes the raw data bytes from/to the file ** sf_xxxx_short passes data in the native short format ** sf_xxxx_int passes data in the native int format ** sf_xxxx_float passes data in the native float format ** sf_xxxx_double passes data in the native double format ** All of these read/write function return number of frames read/written. */ sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ; sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ; sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ; sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; /* Functions for reading and writing the data chunk in terms of items. ** Otherwise similar to above. ** All of these read/write function return number of items read/written. */ sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ; sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ; sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ; sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; /* Close the SNDFILE and clean up all memory allocations associated with this ** file. ** Returns 0 on success, or an error number. */ int sf_close (SNDFILE *sndfile) ; /* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file ** to force the writing of data to disk. If the file is opened SFM_READ ** no action is taken. */ void sf_write_sync (SNDFILE *sndfile) ; #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* SNDFILE_H */
20,073
C++
.h
484
39.61157
98
0.709644
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
33,954
QcHelper.h
supercollider_supercollider/QtCollider/QcHelper.h
#pragma once #include "Common.h" #include <QColor> #include <QString> #include <QFont> #include <QVariant> struct QcHelper { protected: QcHelper() {} float dummyFloat() const { return 0; } int dummyInt() const { return 0; } bool dummyBool() const { return false; } QString dummyString() const { return QString(); } QColor dummyColor() const { return QColor(); } QFont dummyFont() const { return QFont(); } QVariantList dummyVariantList() const { return QVariantList(); } };
509
C++
.h
17
26.882353
68
0.691207
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,955
safeptr.hpp
supercollider_supercollider/QtCollider/safeptr.hpp
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "Common.h" #include <QApplication> #include <QAtomicPointer> #include <QAtomicInt> #include <QMutex> namespace QtCollider { template <typename T> class SafePtr { public: SafePtr(): d(0) {} SafePtr(const SafePtr& other): d(other.d) { ref(); } SafePtr(T* ptr): d(new Data(ptr)) {} SafePtr& operator=(const SafePtr& other) { deref(); d = other.d; ref(); return *this; } ~SafePtr() { deref(); } T* operator->() const { return d->ptr.loadRelaxed(); } T& operator*() const { return *d->ptr.loadRelaxed(); } operator T*() const { return (d ? d->ptr.loadRelaxed() : 0); } T* ptr() const { return (d ? d->ptr.loadRelaxed() : 0); } void* id() const { return (void*)d; } // useful for checking internal pointer identity void invalidate() { qcDebugMsg(2, "SafePtr: invalidating"); if (d) d->ptr = 0; } private: struct Data { Data(T* ptr_): ptr(ptr_), refCount(1) {} QAtomicPointer<T> ptr; QAtomicInt refCount; }; void ref() { if (d) { d->refCount.ref(); qcDebugMsg(2, QString("SafePtr: +refcount = %1").arg(d->refCount.loadRelaxed())); } } void deref() { if (d) { bool ref = d->refCount.deref(); qcDebugMsg(2, QString("SafePtr: -refcount = %1").arg(d->refCount.loadRelaxed())); if (!ref) { qcDebugMsg(2, "SafePtr: unreferenced!"); delete d; } } } Data* d; }; } // namespace QtCollider
2,521
C++
.h
74
28.5
93
0.579489
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
33,956
metatype.hpp
supercollider_supercollider/QtCollider/metatype.hpp
/************************************************************************ * * Copyright 2010 - 2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "type_codec.hpp" #include <PyrSlot.h> #include <QMetaType> #include <QVariant> namespace QtCollider { struct MetaType { public: static void initAll(); static MetaType* find(PyrSlot*); static MetaType* find(int id); // Generic algorithms template <typename T> static void* read(PyrSlot* slot, void* ptr) { if (slot) return new (ptr) T(TypeCodec<T>::read(slot)); else return new (ptr) T(); } template <typename T> static QVariant read(PyrSlot* slot) { return QVariant::fromValue<T>(TypeCodec<T>::read(slot)); } template <typename T> static void write(PyrSlot* slot, void* ptr) { TypeCodec<T>::write(slot, *reinterpret_cast<T*>(ptr)); } template <typename T> static void write(PyrSlot* slot, const QVariant& var) { TypeCodec<T>::write(slot, var.value<T>()); } template <typename T> static void destruct(void* ptr) { T* typed_ptr = reinterpret_cast<T*>(ptr); typed_ptr->~T(); } // Abstract access to generic algorithms virtual size_t size() = 0; virtual void* read(PyrSlot*, void* ptr) = 0; virtual QVariant read(PyrSlot*) = 0; virtual void write(PyrSlot*, void* ptr) = 0; virtual void write(PyrSlot*, const QVariant&) = 0; virtual void destruct(void* ptr) = 0; const int& id() const { return mId; } protected: MetaType(int a_id): mId(a_id) {} int mId; }; template <typename T> struct MetaTypeImpl : MetaType { MetaTypeImpl(): MetaType(qMetaTypeId<T>()) {} size_t size() { return sizeof(T); } void* read(PyrSlot* slot, void* ptr) { return MetaType::read<T>(slot, ptr); } QVariant read(PyrSlot* slot) { return MetaType::read<T>(slot); } void write(PyrSlot* slot, void* ptr) { MetaType::write<T>(slot, ptr); } void write(PyrSlot* slot, const QVariant& var) { MetaType::write<T>(slot, var); } void destruct(void* ptr) { MetaType::destruct<T>(ptr); } ///////////// static MetaTypeImpl<T>* instance; }; class MetaValue { public: MetaValue(): mType(0), mData(0) {} ~MetaValue() { if (mType) mType->destruct(mData); } MetaType* type() const { return mType; } void read(void* mem, MetaType* type, PyrSlot* slot) { mData = mem; mType = type; mType->read(slot, mData); } void write(PyrSlot* slot) { if (mType) mType->write(slot, mData); } template <typename T> T value() { if (mType && qMetaTypeId<T>() == mType->id()) return *reinterpret_cast<T*>(mData); else return T(); } QGenericArgument toGenericArgument() { if (mType) return QGenericArgument(QMetaType(mType->id()).name(), mData); else return QGenericArgument(); } QGenericReturnArgument toGenericReturnArgument() { if (mType) return QGenericReturnArgument(QMetaType(mType->id()).name(), mData); else return QGenericReturnArgument(); } private: MetaType* mType; void* mData; }; template <typename T> inline MetaType* metaType() { return MetaTypeImpl<T>::instance; } template <> struct TypeCodec<QVariant> { static QVariant safeRead(PyrSlot* slot) { MetaType* mt = MetaType::find(slot); return mt ? mt->read(slot) : QVariant(); } }; inline bool set(PyrSlot* s, const QVariant& var) { MetaType* mt = MetaType::find(var.userType()); if (!mt) return false; mt->write(s, var); return true; } } // namespace QtCollider
4,540
C++
.h
128
30.039063
87
0.623971
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
33,957
QcSignalSpy.h
supercollider_supercollider/QtCollider/QcSignalSpy.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "Common.h" #include "QObjectProxy.h" #include <PyrKernel.h> #include <PyrSymbol.h> #include <VMGlobals.h> #include <SCBase.h> #include <QByteArray> #include <QList> #include <QObject> #include <QMetaObject> #include <QMetaMethod> #include <QMetaType> #include <QVariant> class QcSignalSpy : public QObject { public: QcSignalSpy(QObjectProxy* proxy, const char* sigName, Qt::ConnectionType conType = Qt::QueuedConnection): QObject(proxy), _proxy(proxy), _sigId(-1) { Q_ASSERT(sigName); const QMetaObject* mo = _proxy->object()->metaObject(); QByteArray signal = QMetaObject::normalizedSignature(sigName); int sigId = mo->indexOfSignal(signal); if (sigId < 0) { qcDebugMsg(0, QString("WARNING: No such signal to connect: '%1'").arg(signal.constData())); return; } int slotId = QObject::staticMetaObject.methodCount(); if (!QMetaObject::connect(_proxy->object(), sigId, this, slotId, conType, 0)) { qcErrorMsg("QMetaObject::connect returned false. Unable to connect."); return; } QMetaMethod mm = mo->method(sigId); QList<QByteArray> params = mm.parameterTypes(); for (int i = 0; i < params.count(); ++i) { int type = QMetaType::type(params.at(i).constData()); if (type == QMetaType::Void) qcErrorMsg(QString("QObject:connect: Don't know how to handle '%1', " "use qRegisterMetaType to register it.") .arg(params.at(i).constData())); _argTypes << type; } _sigId = sigId; } int qt_metacall(QMetaObject::Call call, int methodId, void** argData) { methodId = QObject::qt_metacall(call, methodId, argData); if (methodId < 0) return methodId; if (call == QMetaObject::InvokeMetaMethod) { Q_ASSERT(methodId == 0); QList<QVariant> args; args.reserve(_argTypes.count()); for (int i = 0; i < _argTypes.count(); ++i) { QMetaType::Type type = static_cast<QMetaType::Type>(_argTypes.at(i)); if (type == QMetaType::QVariant) { #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) // avoid creating a QVariant<QVariant> args << QVariant(type, argData[i + 1]).value<QVariant>(); #else args << QVariant(QMetaType(type), argData[i + 1]).value<QVariant>(); #endif } else { #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) args << QVariant(type, argData[i + 1]); #else args << QVariant(QMetaType(type), (argData[i + 1])); #endif } } react(args); methodId = -1; } return methodId; } inline int indexOfSignal() const { return _sigId; } inline bool isValid() const { return _sigId > 0; } protected: virtual void react(QList<QVariant>& args) = 0; QObjectProxy* _proxy; int _sigId; QList<int> _argTypes; }; class QcMethodSignalHandler : public QcSignalSpy { public: QcMethodSignalHandler(QObjectProxy* proxy, const char* sigName, PyrSymbol* handler, Qt::ConnectionType conType = Qt::QueuedConnection): QcSignalSpy(proxy, sigName, conType), _handler(handler) {} inline PyrSymbol* method() { return _handler; } protected: virtual void react(QList<QVariant>& args) { qcDebugMsg(1, QString("SIGNAL: '%1' handled by method '%2'") .arg(_proxy->object() ? QString(_proxy->object()->metaObject()->method(_sigId).methodSignature()) : "unknown") .arg(_handler->name)); _proxy->invokeScMethod(_handler, args); } PyrSymbol* _handler; }; class QcFunctionSignalHandler : public QcSignalSpy { public: QcFunctionSignalHandler(QObjectProxy* proxy, const char* sigName, PyrObject* handler, Qt::ConnectionType conType = Qt::QueuedConnection): QcSignalSpy(proxy, sigName, conType), _handler(handler) {} inline PyrObject* function() { return _handler; } protected: virtual void react(QList<QVariant>& args) { qcDebugMsg(1, QString("SIGNAL: '%1' handled by a Function") .arg(_proxy->object() ? QString(_proxy->object()->metaObject()->method(_sigId).methodSignature()) : "unknown")); args.prepend(QVariant::fromValue(_handler)); _proxy->invokeScMethod(SC_SYM(doFunction), args); } PyrObject* _handler; };
5,714
C++
.h
139
32.47482
120
0.589924
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,958
LanguageClient.h
supercollider_supercollider/QtCollider/LanguageClient.h
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "SC_TerminalClient.h" #include "Common.h" #include <QObject> #include <QBasicTimer> #include <QEvent> namespace QtCollider { struct SCRequestEvent : public QEvent { SCRequestEvent(QtCollider::EventType type, const QVariant& d = QVariant()): QEvent((QEvent::Type)type), data(d) {} QVariant data; }; class LangClient : public QObject, public SC_TerminalClient { Q_OBJECT public: LangClient(const char* name); virtual ~LangClient() {} virtual void sendSignal(Signal); protected: virtual void commandLoop(); virtual void daemonLoop(); virtual void onQuit(int exitCode); virtual void onLibraryShutdown(); virtual void customEvent(QEvent*); virtual void timerEvent(QTimerEvent*); private: void tick(); QBasicTimer appClockTimer; }; } // namespace QtCollider
1,749
C++
.h
49
32.918367
118
0.685427
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,959
QWidgetProxy.h
supercollider_supercollider/QtCollider/QWidgetProxy.h
/************************************************************************ * * Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QObjectProxy.h" #include <QWidget> #include <QAtomicInt> #include <QMimeData> namespace QtCollider { struct SetFocusEvent; struct SetAlwaysOnTopEvent; struct StartDragEvent; } class QWidgetProxy : public QObjectProxy { Q_OBJECT public: enum GlobalEvent { KeyPress = 0x001, KeyRelease = 0x002 }; public: static void setGlobalEventEnabled(GlobalEvent ev, bool b) { int mask = _globalEventMask.loadRelaxed(); if (b) mask |= ev; else mask &= ~ev; _globalEventMask = mask; } public: QWidgetProxy(QWidget* w, PyrObject* po); void setKeyEventWidget(QWidget*); void setMouseEventWidget(QWidget*); bool alwaysOnTop(); void refresh(); void setLayout(QObjectProxy* layoutProxy); virtual bool setParent(QObjectProxy* parent); void setDragData(QMimeData* data, const QString& label); inline QWidget* widget() { return static_cast<QWidget*>(object()); } protected: virtual void customEvent(QEvent*); virtual bool preProcessEvent(QObject*, QEvent*, EventHandlerData&, QList<QVariant>& args); virtual bool postProcessEvent(QObject*, QEvent*, bool handled); private Q_SLOTS: void customPaint(QPainter*); private: bool interpretMouseEvent(QObject*, QEvent*, QList<QVariant>& args); bool interpretMouseWheelEvent(QObject*, QEvent*, QList<QVariant>& args); bool interpretKeyEvent(QObject*, QEvent*, QList<QVariant>& args); bool interpretDragEvent(QObject*, QEvent*, QList<QVariant>& args); void bringFrontEvent(); void setFocusEvent(QtCollider::SetFocusEvent*); void setAlwaysOnTopEvent(QtCollider::SetAlwaysOnTopEvent*); void performDrag(); static void sendRefreshEventRecursive(QWidget* w); QWidget* _keyEventWidget; QWidget* _mouseEventWidget; static QAtomicInt _globalEventMask; static QMimeData* sDragData; static QString sDragLabel; bool _performDrag; }; namespace QtCollider { struct SetFocusEvent : public QEvent { SetFocusEvent(bool b): QEvent((QEvent::Type)QtCollider::Event_Proxy_SetFocus), focus(b) {} bool focus; }; struct SetAlwaysOnTopEvent : public QEvent { SetAlwaysOnTopEvent(bool b): QEvent((QEvent::Type)QtCollider::Event_Proxy_SetAlwaysOnTop), alwaysOnTop(b) {} bool alwaysOnTop; }; }
3,251
C++
.h
86
33.906977
112
0.707496
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,960
QtDownload.h
supercollider_supercollider/QtCollider/QtDownload.h
/* * QtDownload.h * * * Copyright 2013 Scott Wilson. * * This file is part of SuperCollider. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #include <QObject> #include <QString> #include <QNetworkAccessManager> #include <QNetworkReply> class QtDownload : public QObject { Q_OBJECT Q_PROPERTY(QString source READ source WRITE setSource); Q_PROPERTY(QString destination READ destination WRITE setDestination); public: explicit QtDownload(); ~QtDownload(); void setSource(const QString& t); void setDestination(const QString& l); QString source() { return m_target; } QString destination() { return m_local; } Q_INVOKABLE void cancel(); Q_INVOKABLE void download(); Q_SIGNALS: void doFinished(); void doError(); void doProgress(int, int); private: QNetworkAccessManager* m_manager; QString m_target; QString m_local; QNetworkReply* m_reply; bool started; public Q_SLOTS: void downloadFinished(); void downloadProgress(qint64 received, qint64 total); void replyError(QNetworkReply::NetworkError errorCode); };
1,716
C++
.h
54
28.62963
74
0.741994
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,961
QcObjectFactory.h
supercollider_supercollider/QtCollider/QcObjectFactory.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QObjectProxy.h" #include "Common.h" #include "metatype.hpp" #include <PyrObject.h> #include <QMetaObject> #include <QObject> #include <QWidget> #include <QHash> class QcAbstractFactory; typedef QHash<QString, QcAbstractFactory*> QcFactoryHash; namespace QtCollider { QcFactoryHash& factories(); } class QcAbstractFactory { public: virtual const QMetaObject* metaObject() = 0; virtual QObjectProxy* newInstance(PyrObject*, QtCollider::MetaValue arg[10]) = 0; }; static void qcNoConstructorMsg(const QMetaObject* metaObject, int argc, QtCollider::MetaValue* argv) { QString str = QStringLiteral("No appropriate constructor found for %1 (").arg(metaObject->className()); for (int i = 0; i < argc; ++i) { MetaType* type = argv[i].type(); if (type) { if (i > 0) str += ", "; str += QMetaType(type->id()).name(); } else break; } str += ")"; qcErrorMsg(str); } template <class QOBJECT> class QcObjectFactory : public QcAbstractFactory { public: const QMetaObject* metaObject() { return &QOBJECT::staticMetaObject; } virtual QObjectProxy* newInstance(PyrObject* scObject, QtCollider::MetaValue arg[10]) { QOBJECT* qObject; if (!arg[0].type()) { qObject = new QOBJECT; } else { QObject* obj = QOBJECT::staticMetaObject.newInstance( arg[0].toGenericArgument(), arg[1].toGenericArgument(), arg[2].toGenericArgument(), arg[3].toGenericArgument(), arg[4].toGenericArgument(), arg[5].toGenericArgument(), arg[6].toGenericArgument(), arg[7].toGenericArgument(), arg[8].toGenericArgument(), arg[9].toGenericArgument()); qObject = qobject_cast<QOBJECT*>(obj); if (!qObject) { qcNoConstructorMsg(metaObject(), 10, arg); return 0; } } return proxy(qObject, scObject); } protected: virtual QObjectProxy* proxy(QOBJECT* obj, PyrObject* sc_obj) { QObjectProxy* prox(new QObjectProxy(obj, sc_obj)); initialize(prox, obj); return prox; } virtual void initialize(QObjectProxy* proxy, QOBJECT* obj) {}; }; #define QC_DECLARE_FACTORY(QOBJECT, FACTORY) \ void add_factory_##QOBJECT() { \ QcAbstractFactory* factory = new FACTORY; \ factories().insert(factory->metaObject()->className(), factory); \ } #define QC_DECLARE_QOBJECT_FACTORY(QOBJECT) QC_DECLARE_FACTORY(QOBJECT, QcObjectFactory<QOBJECT>) #define QC_ADD_FACTORY(QOBJECT) \ void add_factory_##QOBJECT(); \ add_factory_##QOBJECT()
4,043
C++
.h
91
38.802198
120
0.572265
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,962
QcCallback.hpp
supercollider_supercollider/QtCollider/QcCallback.hpp
/* SuperCollider Language Copyright (c) 2018 SuperCollider Team https://supercollider.github.io/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <QObject> #include <QPointer> namespace QtCollider { class QcCallback; class QcCallbackWeakFunctor { public: QcCallbackWeakFunctor(QPointer<QcCallback> cb): _cb(cb) {} template <typename RESULT> void operator()(RESULT r) const; private: QPointer<QcCallback> _cb; }; class QcCallback : public QObject { Q_OBJECT public: QcCallback() {} template <typename CallbackT> void call(const CallbackT& result) { Q_EMIT(onCalled(result)); } QcCallbackWeakFunctor asFunctor() { return QcCallbackWeakFunctor(QPointer<QcCallback>(this)); } Q_SIGNALS: void onCalled(bool); void onCalled(const QString&); void onCalled(const QVariant&); void onCalled(const QUrl&); }; template <typename RESULT> void QcCallbackWeakFunctor::operator()(RESULT r) const { if (_cb) { _cb->call(r); } } } // namespace QtCollider Q_DECLARE_METATYPE(QtCollider::QcCallback*);
1,770
C++
.h
47
33.808511
99
0.746628
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
33,963
image.h
supercollider_supercollider/QtCollider/image.h
/************************************************************************ * * This file is part of SuperCollider Qt GUI. * * Copyright 2013 Jakob Leben (jakob.leben@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QImage> #include <QPixmap> #include <QPainter> #include <QSharedPointer> #include <QMetaType> #include <cassert> namespace QtCollider { class Image { enum State { Null, ImageState, PixmapState }; public: Image(): transformationMode(Qt::SmoothTransformation), m_state(Null), m_painting(false) {} void setImage(const QImage& image) { assert(!m_painting); m_pixmap = QPixmap(); m_image = image; m_state = ImageState; } void setPixmap(const QPixmap& pixmap) { assert(!m_painting); m_image = QImage(); m_pixmap = pixmap; m_state = PixmapState; } QImage& image() { if (m_state == ImageState) return m_image; assert(!m_painting); if (m_state == PixmapState) { m_image = m_pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); m_image.setDevicePixelRatio(m_pixmap.devicePixelRatio()); m_pixmap = QPixmap(); } m_state = ImageState; return m_image; } QPixmap& pixmap() { assert(!m_painting); if (m_state == PixmapState) return m_pixmap; if (m_state == ImageState) { m_pixmap = QPixmap::fromImage(m_image); m_pixmap.setDevicePixelRatio(m_image.devicePixelRatio()); m_image = QImage(); } m_state = PixmapState; return m_pixmap; } void clear() { assert(!m_painting); m_image = QImage(); m_pixmap = QPixmap(); m_state = Null; } bool isNull() const { return m_state == Null; } int width() const { switch (m_state) { case ImageState: return m_image.width(); case PixmapState: return m_pixmap.width(); default: return 0; } } int height() const { switch (m_state) { case ImageState: return m_image.height(); case PixmapState: return m_pixmap.height(); default: return 0; } } QRect rect() const { switch (m_state) { case ImageState: return m_image.rect(); case PixmapState: return m_pixmap.rect(); default: return QRect(); } } void resize(const QSize& new_size, int resize_mode) { assert(!m_painting); if (m_state == Null) return; switch (resize_mode) { case 0: { if (m_state == ImageState) { QImage new_image(new_size, QImage::Format_ARGB32_Premultiplied); new_image.setDevicePixelRatio(m_image.devicePixelRatio()); new_image.fill(Qt::transparent); QPainter painter(&new_image); painter.drawImage(QPointF(0, 0), m_image); painter.end(); m_image = new_image; } else { QPixmap new_pixmap(new_size); new_pixmap.setDevicePixelRatio(m_pixmap.devicePixelRatio()); new_pixmap.fill(Qt::transparent); QPainter painter(&new_pixmap); painter.drawPixmap(QPointF(0, 0), m_pixmap); painter.end(); m_pixmap = new_pixmap; } break; } case 1: case 2: case 3: { Qt::AspectRatioMode aspectRatioMode = (Qt::AspectRatioMode)(resize_mode - 1); if (m_state == ImageState) { m_image = m_image.scaled(new_size, aspectRatioMode, transformationMode); } else { m_pixmap = m_pixmap.scaled(new_size, aspectRatioMode, transformationMode); } break; } default: break; } } qreal getDevicePixelRatio() const { switch (m_state) { case ImageState: return m_image.devicePixelRatio(); case PixmapState: return m_pixmap.devicePixelRatio(); default: return 1; } } void setDevicePixelRatio(qreal ratio) { switch (m_state) { case ImageState: m_image.setDevicePixelRatio(ratio); case PixmapState: m_pixmap.setDevicePixelRatio(ratio); default: break; } } bool isPainting() const { return m_painting; } void setPainting(bool painting) { m_painting = painting; } Qt::TransformationMode transformationMode; private: QImage m_image; QPixmap m_pixmap; State m_state; bool m_painting; }; typedef QSharedPointer<QtCollider::Image> SharedImage; } // namespace QtCollider Q_DECLARE_METATYPE(QtCollider::SharedImage);
5,688
C++
.h
177
23.700565
94
0.567262
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,964
debug.h
supercollider_supercollider/QtCollider/debug.h
/************************************************************************ * * Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ namespace QtCollider { int debugLevel(); void setDebugLevel(int); } #include <QString> extern void postfl(const char* fmt, ...); extern void error(const char* fmt, ...); #ifdef QC_DEBUG # define qcDebugMsg(LEVEL, MSG) \ if (LEVEL <= QtCollider::debugLevel()) { \ postfl("Qt: %s\n", QString(MSG).toStdString().c_str()); \ } #else # define qcDebugMsg(LEVEL, MSG) #endif #define qcSCObjectDebugMsg(LEVEL, OBJ, MSG) \ qcDebugMsg(LEVEL, QStringLiteral("[%1] %2").arg(OBJ ? slotRawSymbol(&OBJ->classptr->name)->name : "null").arg(MSG)) #define qcErrorMsg(MSG) error("Qt: %s\n", QString(MSG).toStdString().c_str()) #define qcWarningMsg(MSG) postfl("Qt: %s\n", QString(MSG).toStdString().c_str())
1,926
C++
.h
39
46.897436
120
0.553191
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,965
QcWidgetFactory.h
supercollider_supercollider/QtCollider/QcWidgetFactory.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QcObjectFactory.h" #include "QWidgetProxy.h" #include <QMetaMethod> #include <QLayout> template <class QWIDGET> class QcWidgetFactory : public QcObjectFactory<QWIDGET> { public: virtual QObjectProxy* newInstance(PyrObject* scObject, QtCollider::MetaValue arg[10]) { // Omit the first two arguments - parent and bounds QWIDGET* w; if (!arg[2].type()) { w = new QWIDGET; } else { QObject* obj = QWIDGET::staticMetaObject.newInstance( arg[2].toGenericArgument(), arg[3].toGenericArgument(), arg[4].toGenericArgument(), arg[5].toGenericArgument(), arg[6].toGenericArgument(), arg[7].toGenericArgument(), arg[8].toGenericArgument(), arg[9].toGenericArgument()); w = qobject_cast<QWIDGET*>(obj); if (!w) { qcNoConstructorMsg(QcObjectFactory<QWIDGET>::metaObject(), 8, &arg[2]); return 0; } } // NOTE: performance: it is completely equal if parent is passed // in constructor, or set later, but for some reason it is cheaper // if it is set here, before setting other stuff like geometry, etc. QWidget* parent = arg[0].value<QWidget*>(); if (parent) { const QMetaObject* mo = parent->metaObject(); int mi = mo->indexOfMethod("addChild(QWidget*)"); bool ok; if (mi >= 0) { QMetaMethod mm = mo->method(mi); ok = mm.invoke(parent, Q_ARG(QWidget*, w)); if (!ok) { qcErrorMsg("Could not set parent!"); delete w; return 0; } } else { if (parent->layout()) parent->layout()->addWidget(w); else w->setParent(parent); } } // set requested geometry QRect r(arg[1].value<QRectF>().toRect()); if (r.size().isEmpty()) r.setSize(w->sizeHint()); w->setGeometry(r); // automatically support drag and drop w->setAcceptDrops(true); // ensure visible: if (parent && parent->isVisible()) w->show(); // create the proxy: QObjectProxy* prox(proxy(w, scObject)); return prox; } protected: virtual QObjectProxy* proxy(QWIDGET* w, PyrObject* sc_obj) { QWidgetProxy* prox(new QWidgetProxy(w, sc_obj)); initialize(prox, w); return prox; } // avoid overload of virtual initialize( QObjectProxy *, QWIDGET * ) using QcObjectFactory<QWIDGET>::initialize; virtual void initialize(QWidgetProxy* proxy, QWIDGET* obj) {}; }; #define QC_DECLARE_QWIDGET_FACTORY(QWIDGET) QC_DECLARE_FACTORY(QWIDGET, QcWidgetFactory<QWIDGET>)
3,801
C++
.h
91
33.043956
99
0.586001
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,966
Common.h
supercollider_supercollider/QtCollider/Common.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "debug.h" #include <QList> #include <QVariant> #include <QEvent> #include <QMutex> #include <QWaitCondition> #include <QVector> #include <SCBase.h> #include <PyrSymbol.h> #include <PyrObject.h> #include <PyrSched.h> Q_DECLARE_METATYPE(PyrObject*); Q_DECLARE_METATYPE(QVector<double>); Q_DECLARE_METATYPE(QVector<int>); namespace QtCollider { enum EventType { Event_SCRequest_Work = QEvent::User, Event_SCRequest_Tick, Event_SCRequest_Quit, Event_ScMethodCall, Event_Refresh, Event_Proxy_SetProperty, Event_Proxy_Destroy, Event_Proxy_BringFront, Event_Proxy_SetFocus, Event_Proxy_SetAlwaysOnTop, Event_Proxy_Release }; enum Synchronicity { Synchronous, Asynchronous }; inline void lockLang() { qcDebugMsg(2, "locking lang!"); gLangMutex.lock(); qcDebugMsg(2, "locked"); } inline void unlockLang() { gLangMutex.unlock(); qcDebugMsg(2, "unlocked"); } void runLang(PyrObjectHdr* receiver, PyrSymbol* method, const QList<QVariant>& args = QList<QVariant>(), PyrSlot* result = 0); int wrongThreadError(); QPalette systemPalette(); #define QC_DO_SYMBOLS \ QC_DO_SYMBOL(interpretCmdLine); \ QC_DO_SYMBOL(interpretPrintCmdLine); \ QC_DO_SYMBOL(doFunction); \ QC_DO_SYMBOL(doDrawFunc); \ QC_DO_SYMBOL(prRelease); \ QC_DO_SYMBOL(Rect); \ QC_DO_SYMBOL(Point); \ QC_DO_SYMBOL(Color); \ QC_DO_SYMBOL(Size); \ QC_DO_SYMBOL(QPalette); \ QC_DO_SYMBOL(Font); \ QC_DO_SYMBOL(QCallback); \ QC_DO_SYMBOL(WebPage); \ QC_DO_SYMBOL(QObject); \ QC_DO_SYMBOL(Layout); \ QC_DO_SYMBOL(ScrollCanvas); \ QC_DO_SYMBOL(TreeViewItem); \ QC_DO_SYMBOL(Gradient); \ QC_DO_SYMBOL(HiliteGradient); \ QC_DO_SYMBOL(AbstractMenuAction); \ QC_DO_SYMBOL(Menu); \ QC_DO_SYMBOL(View); \ QC_DO_SYMBOL(Image); #define QC_DO_SYMBOL(SYM) extern PyrSymbol* sym_##SYM QC_DO_SYMBOLS #undef QC_DO_SYMBOL #define SC_SYM(SYM) QtCollider::sym_##SYM #define SC_CLASS(SYM) SC_SYM(SYM)->u.classobj }
5,034
C++
.h
93
50.924731
120
0.393379
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,967
QtCollider.h
supercollider_supercollider/QtCollider/QtCollider.h
#pragma once namespace QtCollider { void initPrimitives(); void init(); int exec(int argc, char** argv); }
108
C++
.h
6
16.833333
32
0.762376
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,968
QcApplication.h
supercollider_supercollider/QtCollider/QcApplication.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "Common.h" #include <QApplication> #include <QEventLoop> #include <QMutex> #include <QMenuBar> namespace QtCollider { class EventProcessor : public QObject { public: void work() { QApplication::postEvent(this, new QEvent(QEvent::User)); _loop.exec(); } void customEvent(QEvent* e) { _loop.exit(); } private: QEventLoop _loop; }; } // namespace QtCollider class QcApplication : public QApplication { Q_OBJECT public: QcApplication(int& argc, char** argv); virtual ~QcApplication(); static bool compareThread(); // NOTE: language must be locked static void processEvents() { if (_instance) _instance->_eventProc.work(); } static inline bool SystemHasMouseWheel() { return _systemHasMouseWheel; } static QMenuBar* getMainMenu() { return _instance->_mainMenu.data(); } public Q_SLOTS: void interpret(const QString& code, bool printResult = true); void onQuit(); protected: virtual bool event(QEvent*); virtual bool notify(QObject*, QEvent*); private: QSharedPointer<QMenuBar> _mainMenu; void createMenu(); QtCollider::EventProcessor _eventProc; static QMutex _mutex; static QcApplication* _instance; static bool _systemHasMouseWheel; bool _handleCmdPeriod; };
2,228
C++
.h
65
30.784615
77
0.675978
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,969
QObjectProxy.h
supercollider_supercollider/QtCollider/QObjectProxy.h
/************************************************************************ * * Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "Common.h" #include <QObject> #include <QString> #include <QVariant> #include <QVector> #include <QEvent> #include <PyrObject.h> #include <PyrSlot.h> #include <PyrSymbol.h> #define qcProxyDebugMsg(LEVEL, MSG) qcDebugMsg(LEVEL, QStringLiteral("[%1]: ").arg(_scClassName) + QString(MSG)) class QObjectProxy; class QcSignalSpy; class QcMethodSignalHandler; class QcFunctionSignalHandler; namespace QtCollider { struct SetPropertyEvent; class DestroyEvent; struct ScMethodCallEvent; class ProxyToken : public QObject { Q_OBJECT public: ProxyToken(QObjectProxy* p, QObject* parent): QObject(parent), proxy(p) {} QObjectProxy* proxy; }; } class QObjectProxy : public QObject { friend class QcMethodSignalHandler; friend class QcFunctionSignalHandler; Q_OBJECT public: enum DestroyAction { DestroyProxy, DestroyObject, DestroyProxyAndObject, }; struct EventHandlerData { EventHandlerData(): type(QEvent::None) {} int type; PyrSymbol* method; QtCollider::Synchronicity sync; bool enabled; }; QObjectProxy(QObject* qObject, PyrObject* scObject); virtual ~QObjectProxy(); // Check if this is the right thread. // WARNING: must be called with language locked! bool compareThread(); // WARNING: must be called with language locked! void finalize() { _scObject = 0; } inline QObject* object() const { return qObject; } inline PyrObject* scObject() const { return _scObject; } // Lock for usage of object() outside Qt thread. inline void lock() { mutex.lock(); } inline void unlock() { mutex.unlock(); } QString scClassName() const { return _scClassName; } QList<PyrObject*> children(PyrSymbol* className); PyrObject* parent(PyrSymbol* className); virtual bool setParent(QObjectProxy* parent); bool setProperty(const char* property, const QVariant& val); QVariant property(const char* property); bool connectObject(const char* signal, PyrObject* object, Qt::ConnectionType); bool connectMethod(const char* signal, PyrSymbol* method, Qt::ConnectionType); bool disconnectObject(const char* signal, PyrObject* object); bool disconnectMethod(const char* signal, PyrSymbol* method); bool setEventHandler(int eventType, PyrSymbol* method, QtCollider::Synchronicity, bool enabled = true); bool setEventHandlerEnabled(int eventType, bool enabled); // thread-safe if connection == queued bool invokeMethod(const char* method, PyrSlot* ret, PyrSlot* arg, Qt::ConnectionType); void destroy(DestroyAction); static QObjectProxy* fromObject(QObject*); protected: void invokeScMethod(PyrSymbol* method, const QList<QVariant>& args = QList<QVariant>(), PyrSlot* result = 0, bool locked = false); virtual bool eventFilter(QObject* watched, QEvent* event); virtual void customEvent(QEvent*); virtual bool preProcessEvent(QObject*, QEvent*, EventHandlerData&, QList<QVariant>& args); virtual bool postProcessEvent(QObject*, QEvent*, bool handled) { return handled; } bool invokeEventHandler(QEvent* e, EventHandlerData&, QList<QVariant>& args); const QVector<EventHandlerData>& eventHandlers() { return _eventHandlers; } private Q_SLOTS: void invalidate(); private: void scMethodCallEvent(QtCollider::ScMethodCallEvent*); bool setPropertyEvent(QtCollider::SetPropertyEvent*); bool destroyEvent(QtCollider::DestroyEvent*); QObject* qObject; // NOTE: scObject is protected by the language lock. Should not use it without it! PyrObject* _scObject; // NOTE: for the reason above we extract SC class name at construction QString _scClassName; QVector<EventHandlerData> _eventHandlers; QList<QcMethodSignalHandler*> methodSigHandlers; QList<QcFunctionSignalHandler*> funcSigHandlers; QMutex mutex; }; namespace QtCollider { struct SetPropertyEvent : public QEvent { SetPropertyEvent(): QEvent((QEvent::Type)QtCollider::Event_Proxy_SetProperty) {} PyrSymbol* property; QVariant value; }; class DestroyEvent : public QEvent { public: DestroyEvent(QObjectProxy::DestroyAction act): QEvent((QEvent::Type)QtCollider::Event_Proxy_Destroy), _action(act) {} QObjectProxy::DestroyAction action() { return _action; } private: QObjectProxy::DestroyAction _action; }; struct ScMethodCallEvent : public QEvent { ScMethodCallEvent(PyrSymbol* m, const QList<QVariant>& l = QList<QVariant>(), bool b_locked = false): QEvent((QEvent::Type)QtCollider::Event_ScMethodCall), method(m), args(l), locked(b_locked) {} PyrSymbol* method; QList<QVariant> args; bool locked; }; } // namespace Q_DECLARE_METATYPE(QObjectProxy*);
5,750
C++
.h
143
35.909091
112
0.71593
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,970
painting.h
supercollider_supercollider/QtCollider/painting.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once class QPainter; class QWidget; class QObject; namespace QtCollider { // WARNING these can be called only from Qt thread (no locking needed): void announcePainting(); bool paintingAnnounced(); // WARNING language must be locked to call these: bool beginPainting(QPainter*, QObject* obj = 0); void endPainting(); bool isPaintingObject(QObject* obj); QPainter* globalPainter(); }
1,302
C++
.h
34
36.588235
74
0.682502
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,971
type_codec.hpp
supercollider_supercollider/QtCollider/type_codec.hpp
/************************************************************************ * * Copyright 2010 - 2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "widgets/QcTreeWidget.h" #include "widgets/QcMenu.h" #include "image.h" #include <PyrSlot.h> #include <PyrKernel.h> #include <QDebug> #include <QChar> #include <QString> #include <QPoint> #include <QPointF> #include <QSize> #include <QSizeF> #include <QRect> #include <QRectF> #include <QColor> #include <QFont> #include <QPalette> #include <QWidget> #include <QLayout> #include <QVector> #include <QUrl> #include <QVariantList> class QObjectProxy; namespace QtCollider { template <typename T, typename EnabledT = void> struct TypeCodec {}; // Forwarding from QtCollider namespace to TypeCodec template <typename T> inline T read(PyrSlot* slot) { return TypeCodec<T>::read(slot); } template <typename T> inline void write(PyrSlot* slot, const T& val) { return TypeCodec<T>::write(slot, val); } // Lazy conversion, allows automatic codec deduction struct DecodableSlot { PyrSlot* _slot; DecodableSlot(PyrSlot* slot): _slot(slot) {} template <typename T> operator T() { return TypeCodec<T>::safeRead(_slot); } }; inline DecodableSlot get(PyrSlot* slot) { return DecodableSlot(slot); } template <typename T> inline T get(PyrSlot* slot) { return TypeCodec<T>::safeRead(slot); } template <typename T> inline void set(PyrSlot* slot, const T& val) { // write is always type-safe TypeCodec<T>::write(slot, val); } template <typename IteratorT> static void setObjectList(PyrSlot* slot, int size, IteratorT iter, IteratorT end) { typedef typename IteratorT::value_type ValueT; VMGlobals* g = gMainVMGlobals; PyrObject* array = newPyrArray(g->gc, size, 0, true); SetObject(slot, array); PyrSlot* s = array->slots; for (; iter != end; ++iter) { if (size > 0) { TypeCodec<ValueT>::write(s, *iter); ++array->size; ++s; --size; } } } // TypeCodecs template <> struct TypeCodec<bool> { static bool read(PyrSlot* slot) { return IsTrue(slot); } static bool safeRead(PyrSlot* slot) { return read(slot); } static void write(PyrSlot* slot, const bool val) { if (val) SetTrue(slot); else SetFalse(slot); } }; template <> struct TypeCodec<int> { static int read(PyrSlot* slot) { return slotRawInt(slot); } static int safeRead(PyrSlot* slot) { int val; if (slotIntVal(slot, &val)) return 0; return val; } static void write(PyrSlot* slot, const int val) { SetInt(slot, val); } }; template <> struct TypeCodec<float> { static float read(PyrSlot* slot) { return slotRawFloat(slot); } static float safeRead(PyrSlot* slot) { float val; if (slotFloatVal(slot, &val)) return 0.f; return val; } static void write(PyrSlot* slot, const float val) { SetFloat(slot, val); } }; template <> struct TypeCodec<double> { static double read(PyrSlot* slot) { double d; slotVal(slot, &d); return d; } static double safeRead(PyrSlot* slot) { double val; if (slotDoubleVal(slot, &val)) return 0.0; return val; } static void write(PyrSlot* slot, const double val) { // NOTE: the signature actually reads SetFloat(PyrSlot*, double): SetFloat(slot, val); } }; template <> struct TypeCodec<QChar> { static QChar read(PyrSlot* slot) { return QChar(slotRawChar(slot)); } static QChar safeRead(PyrSlot* slot) { if (GetTag(slot) == tagChar) return QChar(slotRawChar(slot)); else return QChar(); } static void write(PyrSlot* slot, const QChar& val) { // FIXME: Should add support for unicode in PyrSlot! SetChar(slot, val.toLatin1()); } }; template <> struct TypeCodec<QString> { static QString read(PyrSlot* slot); static QString safeRead(PyrSlot* slot) { return read(slot); } static void write(PyrSlot* slot, const QString& val); }; template <> struct TypeCodec<QUrl> { static QUrl read(PyrSlot* slot); static QUrl safeRead(PyrSlot* slot) { return read(slot); } static void write(PyrSlot* slot, const QUrl& val); }; template <> struct TypeCodec<QPointF> { static QPointF read(PyrSlot* slot); static QPointF safeRead(PyrSlot* slot); static void write(PyrSlot* slot, const QPointF& pt); }; template <> struct TypeCodec<QPoint> { static QPoint read(PyrSlot* slot) { return TypeCodec<QPointF>::read(slot).toPoint(); } static QPoint safeRead(PyrSlot* slot) { return TypeCodec<QPointF>::safeRead(slot).toPoint(); } static void write(PyrSlot* slot, const QPoint& pt) { TypeCodec<QPointF>::write(slot, pt); } }; template <> struct TypeCodec<QRectF> { static QRectF read(PyrSlot* slot); static QRectF safeRead(PyrSlot* slot); static void write(PyrSlot* slot, const QRectF& r); }; template <> struct TypeCodec<QRect> { static QRect read(PyrSlot* slot) { return TypeCodec<QRectF>::read(slot).toRect(); } static QRect safeRead(PyrSlot* slot) { return TypeCodec<QRectF>::safeRead(slot).toRect(); } static void write(PyrSlot* slot, const QRect& rect) { TypeCodec<QRectF>::write(slot, rect); } }; template <> struct TypeCodec<QSizeF> { static QSizeF read(PyrSlot* slot); static QSizeF safeRead(PyrSlot* slot); static void write(PyrSlot* slot, const QSizeF& sz); }; template <> struct TypeCodec<QSize> { static QSize read(PyrSlot* slot) { return TypeCodec<QSizeF>::read(slot).toSize(); } static QSize safeRead(PyrSlot* slot) { return TypeCodec<QSizeF>::safeRead(slot).toSize(); } static void write(PyrSlot* slot, const QSize& size) { TypeCodec<QSizeF>::write(slot, size); } }; template <> struct TypeCodec<QColor> { static QColor read(PyrSlot* slot); static QColor safeRead(PyrSlot* slot) { if (IsObj(slot)) return read(slot); return QColor(); } static void write(PyrSlot* slot, const QColor&); }; template <> struct TypeCodec<QFont> { static QFont read(PyrSlot* slot); static QFont safeRead(PyrSlot* slot); static void write(PyrSlot* slot, const QFont&) { qWarning("WARNING: QtCollider: writing QFont to PyrSlot not supported."); } }; template <> struct TypeCodec<QPalette> { static QPalette read(PyrSlot* slot); static QPalette safeRead(PyrSlot* slot); static void write(PyrSlot* slot, const QPalette&); }; template <> struct TypeCodec<QObjectProxy*> { static QObjectProxy* read(PyrSlot* slot) { PyrSlot* proxySlot = slotRawObject(slot)->slots; if (IsPtr(proxySlot)) return (QObjectProxy*)slotRawPtr(proxySlot); else return 0; } static QObjectProxy* safeRead(PyrSlot* slot); static void write(PyrSlot*, QObjectProxy*) { qWarning("WARNING: QtCollider: writing QObjectProxy* to PyrSlot not supported."); } }; template <> struct TypeCodec<QObject*> { static QObject* read(PyrSlot*) { qWarning("WARNING: QtCollider: reading QObject* from PyrSlot not supported."); return 0; } static void write(PyrSlot*, QObject*); }; #define TYPE_IS_QOBJECT(type) std::is_convertible<QObjectT, QObject*>::value template <> struct TypeCodec<PyrObject*> { static PyrObject* read(PyrSlot*) { qWarning("WARNING: TypeCodec<PyrObject*>::read(PyrSlot*) = NO-OP"); return 0; } static void write(PyrSlot* slot, PyrObject* object) { SetObject(slot, object); } }; template <> struct TypeCodec<QcTreeWidget::ItemPtr> { static QcTreeWidget::ItemPtr read(PyrSlot* slot); static void write(PyrSlot* slot, const QcTreeWidget::ItemPtr&); }; template <> struct TypeCodec<SharedImage> { static SharedImage read(PyrSlot* slot); static SharedImage safeRead(PyrSlot* slot); static void write(PyrSlot* slot, SharedImage image); }; template <> struct TypeCodec<QVector<int>> { static QVector<int> read(PyrSlot* slot); static void write(PyrSlot* slot, const QVector<int>&); }; template <> struct TypeCodec<QVector<double>> { static QVector<double> read(PyrSlot* slot); static void write(PyrSlot* slot, const QVector<double>&); }; template <typename ContainedT> struct TypeCodec<QVector<ContainedT>> { static QVector<ContainedT> read(PyrSlot* slot) { qWarning("WARNING: TypeCodec<PyrObject*>::read(PyrSlot*) = NO-OP"); return QVector<ContainedT>(); } static void write(PyrSlot* slot, const QVector<ContainedT>& vec) { setObjectList(slot, vec.size(), vec.begin(), vec.end()); } }; #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) template <typename ContainedT> struct TypeCodec<QList<ContainedT>> { static QList<ContainedT> read(PyrSlot* slot) { qWarning("WARNING: TypeCodec<PyrObject*>::read(PyrSlot*) = NO-OP"); return QList<ContainedT>(); } static void write(PyrSlot* slot, const QList<ContainedT>& vec) { setObjectList(slot, vec.size(), vec.begin(), vec.end()); } }; #endif template <> struct TypeCodec<QVariantList> { static QVariantList read(PyrSlot* slot); static QVariantList safeRead(PyrSlot* slot) { return read(slot); } static void write(PyrSlot* slot, const QVariantList&); }; template <typename QObjectT> struct TypeCodec<QObjectT, void> { static QObjectT read(PyrSlot* slot) { return safeRead(slot); } static QObjectT safeRead(PyrSlot* slot) { auto proxy = TypeCodec<QObjectProxy*>::safeRead(slot); if (proxy) { auto action = qobject_cast<QObjectT>(proxy->object()); return action; } else { return 0; } } static void write(PyrSlot* slot, QObjectT object) { auto qobject = qobject_cast<QObject*>(object); TypeCodec<QObject*>::write(slot, qobject); } }; } // namespace QtCollider
10,793
C++
.h
285
33.003509
113
0.674253
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
33,972
image_primitive_helper_funcs.h
supercollider_supercollider/QtCollider/primitives/image_primitive_helper_funcs.h
/************************************************************************ * * This file is part of SuperCollider Qt GUI. * * Copyright 2013 Jakob Leben (jakob.leben@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ // these functions are useful for the creation of QImage SC objects #pragma once #include <QImage> #include "../image.h" #include "../type_codec.hpp" namespace QC = QtCollider; namespace QtCollider { inline QC::Image* to_image(struct PyrObject* obj) { SharedImage* shared_image_ptr = reinterpret_cast<SharedImage*>(slotRawPtr(obj->slots)); return shared_image_ptr->data(); } inline QC::Image* to_image(PyrSlot* slot) { SharedImage* shared_image_ptr = reinterpret_cast<SharedImage*>(slotRawPtr(slotRawObject(slot)->slots)); return shared_image_ptr->data(); } inline QRgb color_to_pixel(const QColor& color) { int r, g, b, a; color.getRgb(&r, &g, &b, &a); qreal k = a / 255.f; r *= k; g *= k; b *= k; QRgb pixel = (a << 24) | (r << 16) | (g << 8) | b; return pixel; } inline QColor pixel_to_color(QRgb pixel) { int r, g, b, a; int mask = 0xFF; a = pixel >> 24 & mask; r = pixel >> 16 & mask; g = pixel >> 8 & mask; b = pixel & mask; if (a > 0) { qreal k = a > 0 ? 255.f / a : 0.f; r *= k; g *= k; b *= k; return QColor(r, g, b, a); } else return QColor(0, 0, 0, 0); } inline int finalize_image_object(struct VMGlobals* g, struct PyrObject* obj) { SharedImage* shared_image_ptr = reinterpret_cast<SharedImage*>(slotRawPtr(obj->slots)); delete shared_image_ptr; SetNil(obj->slots + 0); return errNone; } inline void initialize_image_object(struct VMGlobals* g, struct PyrObject* obj, Image* image) { assert(IsNil(obj->slots) && IsNil(obj->slots + 1)); SharedImage* shared_image_ptr = new SharedImage(image); SetPtr(obj->slots, shared_image_ptr); // dataptr InstallFinalizer(g, obj, 1, finalize_image_object); // finalizer } } // namespace QtCollider
2,725
C++
.h
74
33.243243
107
0.635089
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,973
primitives.h
supercollider_supercollider/QtCollider/primitives/primitives.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #include <PyrPrimitive.h> #include <VMGlobals.h> #include <PyrSlot.h> #include <QList> #include <cstring> namespace QtCollider { template <typename T> struct LangPrimitive {}; class LangPrimitiveDefiner { public: LangPrimitiveDefiner(): _base(nextPrimitiveIndex()), _index(0) {} template <typename T> void define() { LangPrimitive<T>::define(_base, _index++); } private: int _base; int _index; }; } // namespace #define QC_LANG_PRIMITIVE(NAME, ARGC, RECEIVER, ARGS, GLOBAL) \ struct NAME {}; \ template <> struct LangPrimitive<NAME> { \ static int implementation(RECEIVER, ARGS, GLOBAL); \ static int mediate(VMGlobals* g, int i) { \ PyrSlot* stack = g->sp - i + 1; \ return implementation(stack, i > 1 ? stack + 1 : 0, g); \ } \ static void define(int base, int index) { definePrimitive(base, index, "_" #NAME, &mediate, ARGC + 1, 0); } \ }; \ int LangPrimitive<NAME>::implementation(RECEIVER, ARGS, GLOBAL) #if 0 # define QC_LANG_PRIMITIVE(name, argc, receiver, args, global) \ int name(receiver, args, global); \ static QtCollider::LangPrimitive<&name> p_##name("_" #name, argc); \ int name(receiver, args, global) #endif
3,046
C++
.h
53
53.792453
120
0.452716
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,974
prim_QPalette.hpp
supercollider_supercollider/QtCollider/primitives/prim_QPalette.hpp
/************************************************************************ * * Copyright 2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QPalette> struct PyrObject; struct VMGlobals; #define QPALETTE_FROM_OBJECT(OBJ) reinterpret_cast<QPalette*>(slotRawPtr(OBJ->slots)); namespace QtCollider { void QPalette_Init(struct VMGlobals* g, struct PyrObject* obj, const QPalette& palette = QPalette()); }
1,197
C++
.h
28
40.821429
101
0.672117
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
33,975
layouts.hpp
supercollider_supercollider/QtCollider/layouts/layouts.hpp
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "stack_layout.hpp" #include "../Common.h" #include "../QcObjectFactory.h" #include "../QObjectProxy.h" #include <QHBoxLayout> #include <QVBoxLayout> #include <QGridLayout> #include <QStackedLayout> template <class LAYOUT> struct QcLayout : public LAYOUT { public: QVariantList margins() const { return QVariantList(); } void setMargins(const QVariantList& list) { if (list.size() < 4) return; int m[4]; for (int i = 0; i < 4; ++i) m[i] = list[i].toInt(); LAYOUT::setContentsMargins(m[0], m[1], m[2], m[3]); } }; template <class BOXLAYOUT> class QcBoxLayout : public QcLayout<BOXLAYOUT> { public: QcBoxLayout() {} QcBoxLayout(const QVariantList& items) { Q_FOREACH (const QVariant& var, items) { QVariantList item = var.toList(); addItem(item); } } void addItem(const QVariantList& item) { if (item.size() < 3) return; int stretch = item[1].toInt(); Qt::Alignment alignment = (Qt::Alignment)item[2].toInt(); const QVariant& varObject = item[0]; if (!varObject.isValid()) { BOXLAYOUT::addStretch(stretch); return; } if (varObject.canConvert<int>()) { int size = varObject.toInt(); BOXLAYOUT::addSpacing(size); return; } QWidget* w = varObject.value<QWidget*>(); if (w) { BOXLAYOUT::addWidget(w, stretch, alignment); return; } QLayout* l2 = varObject.value<QLayout*>(); if (l2) { BOXLAYOUT::addLayout(l2, stretch); return; } } void insertItem(const QVariantList& item) { if (item.size() < 4) return; int index = item[1].toInt(); int stretch = item[2].toInt(); Qt::Alignment alignment = (Qt::Alignment)item[3].toInt(); const QVariant& varObject = item[0]; if (!varObject.isValid()) { BOXLAYOUT::insertStretch(index, stretch); return; } if (varObject.canConvert<int>()) { int size = varObject.toInt(); BOXLAYOUT::insertSpacing(index, size); return; } QWidget* w = varObject.value<QWidget*>(); if (w) { BOXLAYOUT::insertWidget(index, w, stretch, alignment); return; } QLayout* l2 = varObject.value<QLayout*>(); if (l2) { BOXLAYOUT::insertLayout(index, l2, stretch); return; } } void setStretch(QWidget* w, int stretch) { BOXLAYOUT::setStretchFactor(w, stretch); } void setStretch(QLayout* l, int stretch) { BOXLAYOUT::setStretchFactor(l, stretch); } void setAlignment(QWidget* w, Qt::Alignment alignment) { BOXLAYOUT::setAlignment(w, alignment); } void setAlignment(QLayout* l, Qt::Alignment alignment) { BOXLAYOUT::setAlignment(l, alignment); } }; class QcHBoxLayout : public QcBoxLayout<QHBoxLayout> { Q_OBJECT Q_PROPERTY(QVariantList margins READ margins WRITE setMargins) public: QcHBoxLayout() {} Q_INVOKABLE QcHBoxLayout(const QVariantList& items): QcBoxLayout<QHBoxLayout>(items) {} Q_INVOKABLE void addItem(const QVariantList& data) { QcBoxLayout<QHBoxLayout>::addItem(data); } Q_INVOKABLE void insertItem(const QVariantList& data) { QcBoxLayout<QHBoxLayout>::insertItem(data); } Q_INVOKABLE void setStretch(int index, int stretch) { QBoxLayout::setStretch(index, stretch); } Q_INVOKABLE void setStretch(QWidget* w, int stretch) { QcBoxLayout<QHBoxLayout>::setStretch(w, stretch); } Q_INVOKABLE void setStretch(QLayout* l, int stretch) { QcBoxLayout<QHBoxLayout>::setStretch(l, stretch); } Q_INVOKABLE void setAlignment(int i, int a) { itemAt(i)->setAlignment((Qt::Alignment)a); update(); } Q_INVOKABLE void setAlignment(QWidget* w, int a) { QcBoxLayout<QHBoxLayout>::setAlignment(w, (Qt::Alignment)a); } Q_INVOKABLE void setAlignment(QLayout* l, int a) { QcBoxLayout<QHBoxLayout>::setAlignment(l, (Qt::Alignment)a); } }; class QcVBoxLayout : public QcBoxLayout<QVBoxLayout> { Q_OBJECT Q_PROPERTY(QVariantList margins READ margins WRITE setMargins) public: QcVBoxLayout() {} Q_INVOKABLE QcVBoxLayout(const QVariantList& items): QcBoxLayout<QVBoxLayout>(items) {} Q_INVOKABLE void addItem(const QVariantList& data) { QcBoxLayout<QVBoxLayout>::addItem(data); } Q_INVOKABLE void insertItem(const QVariantList& data) { QcBoxLayout<QVBoxLayout>::insertItem(data); } Q_INVOKABLE void setStretch(int index, int stretch) { QBoxLayout::setStretch(index, stretch); } Q_INVOKABLE void setStretch(QWidget* w, int stretch) { QcBoxLayout<QVBoxLayout>::setStretch(w, stretch); } Q_INVOKABLE void setStretch(QLayout* l, int stretch) { QcBoxLayout<QVBoxLayout>::setStretch(l, stretch); } Q_INVOKABLE void setAlignment(int i, int a) { itemAt(i)->setAlignment((Qt::Alignment)a); update(); } Q_INVOKABLE void setAlignment(QWidget* w, int a) { QcBoxLayout<QVBoxLayout>::setAlignment(w, (Qt::Alignment)a); } Q_INVOKABLE void setAlignment(QLayout* l, int a) { QcBoxLayout<QVBoxLayout>::setAlignment(l, (Qt::Alignment)a); } }; class QcGridLayout : public QcLayout<QGridLayout> { Q_OBJECT Q_PROPERTY(QVariantList margins READ margins WRITE setMargins) Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) public: Q_INVOKABLE void addItem(const QVariantList& dataList); Q_INVOKABLE void setRowStretch(int row, int factor) { QcLayout<QGridLayout>::setRowStretch(row, factor); } Q_INVOKABLE void setColumnStretch(int column, int factor) { QcLayout<QGridLayout>::setColumnStretch(column, factor); } Q_INVOKABLE void setAlignment(int r, int c, int a) { QLayoutItem* item = itemAtPosition(r, c); if (item) { item->setAlignment((Qt::Alignment)a); update(); } } Q_INVOKABLE void setAlignment(QWidget* w, int a) { QLayout::setAlignment(w, (Qt::Alignment)a); } Q_INVOKABLE void setAlignment(QLayout* l, int a) { QLayout::setAlignment(l, (Qt::Alignment)a); } Q_INVOKABLE int minRowHeight(int row) { return (row >= 0 && row < rowCount()) ? rowMinimumHeight(row) : 0; } Q_INVOKABLE int minColumnWidth(int col) { return (col >= 0 && col < columnCount()) ? columnMinimumWidth(col) : 0; } Q_INVOKABLE void setMinRowHeight(int row, int h) { setRowMinimumHeight(row, h); } Q_INVOKABLE void setMinColumnWidth(int col, int w) { setColumnMinimumWidth(col, w); } }; class QcStackLayout : public QcLayout<QtCollider::StackLayout> { Q_OBJECT Q_PROPERTY(QVariantList margins READ margins WRITE setMargins) public: QcStackLayout() {} Q_INVOKABLE QcStackLayout(const QVariantList& items) { Q_FOREACH (const QVariant& var, items) { QWidget* w = var.value<QWidget*>(); if (w) addWidget(w); } } Q_INVOKABLE void insertWidget(int index, QWidget* w) { QtCollider::StackLayout::insertWidget(index, w); } };
8,181
C++
.h
183
38.180328
119
0.656415
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
33,976
classic_layouts.hpp
supercollider_supercollider/QtCollider/layouts/classic_layouts.hpp
/************************************************************************ * * Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QWidget> #include <QResizeEvent> #include "../Common.h" namespace QtCollider { enum HSizePolicy { StickLeft = 1, HStretch, StickRight }; enum VSizePolicy { StickTop = 1, VStretch, StickBottom }; static VSizePolicy vSizePolicy(QWidget* w) { QVariant var = w->property("_qc_vSizePolicy"); if (!var.isValid()) return StickTop; return (VSizePolicy)var.toInt(); } static HSizePolicy hSizePolicy(QWidget* w) { QVariant var = w->property("_qc_hSizePolicy"); if (!var.isValid()) return StickLeft; return (HSizePolicy)var.toInt(); } class DefaultLayout { public: DefaultLayout(QWidget* w): parent(w), initialized(false) {} void resize(QResizeEvent* e) { QRect r; r.setSize(e->size()); if (!initialized) { initialized = true; geom = r; return; } QPoint dPos = r.topLeft() - geom.topLeft(); QSize dSize = r.size() - geom.size(); const QObjectList& children = parent->children(); Q_FOREACH (QObject* o, children) { if (!o->isWidgetType()) continue; QWidget* child = static_cast<QWidget*>(o); QRect g = child->geometry(); int x = g.x(); int y = g.y(); int w = g.width(); int h = g.height(); if (!dPos.isNull()) { x += dPos.x(); y += dPos.y(); } if (!dSize.isNull()) { if (hSizePolicy(child) == QtCollider::StickRight) x += dSize.width(); if (vSizePolicy(child) == QtCollider::StickBottom) y += dSize.height(); if (hSizePolicy(child) == QtCollider::HStretch) w += dSize.width(); if (vSizePolicy(child) == QtCollider::VStretch) h += dSize.height(); } child->setGeometry(QRect(x, y, w, h)); } geom = r; } private: QWidget* parent; bool initialized; QRect geom; }; class HLayout { public: HLayout(QWidget* w): parent(w) {} void resize(QResizeEvent* e) { QRect geom; geom.setSize(e->size()); const QObjectList& children = parent->children(); int varWidth = geom.width(); int i = 0; Q_FOREACH (QObject* o, children) { if (!o->isWidgetType()) continue; QWidget* w = static_cast<QWidget*>(o); if (hSizePolicy(w) == QtCollider::HStretch) { ++i; } else { QRect r = w->geometry(); varWidth -= r.width(); if (varWidth < 0) break; } } int partWidth = i > 0 && varWidth > 0 ? varWidth / i : 0; int x = 0; Q_FOREACH (QObject* o, children) { if (!o->isWidgetType()) continue; QWidget* w = static_cast<QWidget*>(o); QRect r = w->geometry(); r.setHeight(geom.height()); r.moveTo(x, geom.top()); if (hSizePolicy(w) == QtCollider::HStretch) r.setWidth(partWidth); x += r.width(); w->setGeometry(r); } } private: QWidget* parent; }; class VLayout { public: VLayout(QWidget* w): parent(w) {} void resize(QResizeEvent* e) { QRect geom; geom.setSize(e->size()); const QObjectList& children = parent->children(); int varHeight = geom.height(); int i = 0; Q_FOREACH (QObject* o, children) { if (!o->isWidgetType()) continue; QWidget* w = static_cast<QWidget*>(o); if (vSizePolicy(w) == QtCollider::VStretch) { ++i; } else { QRect r = w->geometry(); varHeight -= r.height(); if (varHeight < 0) break; } } int partHeight = i > 0 && varHeight > 0 ? varHeight / i : 0; int y = 0; Q_FOREACH (QObject* o, children) { if (!o->isWidgetType()) continue; QWidget* w = static_cast<QWidget*>(o); QRect r = w->geometry(); r.setWidth(geom.width()); r.moveTo(geom.left(), y); if (vSizePolicy(w) == QtCollider::VStretch) r.setHeight(partHeight); y += r.height(); w->setGeometry(r); } } private: QWidget* parent; }; } // namespace QtCollider
5,563
C++
.h
166
24.313253
74
0.520075
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
33,977
stack_layout.hpp
supercollider_supercollider/QtCollider/layouts/stack_layout.hpp
/************************************************************************ * * Copyright 2012 Jakob Leben (jakob.leben@gmail.com) * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * Contact: Nokia Corporation (qt-info@nokia.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QLayout> #include <QList> namespace QtCollider { class StackLayout : public QLayout { Q_OBJECT Q_ENUMS(StackingMode) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex) Q_PROPERTY(StackingMode stackingMode READ stackingMode WRITE setStackingMode) Q_PROPERTY(int count READ count) public: enum StackingMode { StackOne, StackAll }; StackLayout(); ~StackLayout(); int addWidget(QWidget* w); int insertWidget(int index, QWidget* w); QWidget* currentWidget() const; void setCurrentWidget(QWidget* widget); int currentIndex() const; void setCurrentIndex(int index); inline QWidget* widget() { return QLayout::widget(); } QWidget* widget(int) const; int count() const; StackingMode stackingMode() const; void setStackingMode(StackingMode stackingMode); // abstract virtual functions: void addItem(QLayoutItem* item); QLayoutItem* itemAt(int) const; QLayoutItem* takeAt(int); QSize sizeHint() const; QSize minimumSize() const; Qt::Orientations expandingDirections() const; void setGeometry(const QRect& rect); virtual void invalidate(); private: QList<QLayoutItem*> _list; int _index; StackingMode _mode; bool _gotParent; }; } // namespace QtCollider
2,379
C++
.h
65
33.046154
81
0.69378
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
33,978
QcMultiSlider.h
supercollider_supercollider/QtCollider/widgets/QcMultiSlider.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../QcHelper.h" #include "../style/style.hpp" #include "../Common.h" #include <QWidget> class QcMultiSlider : public QWidget, QcHelper, QtCollider::Style::Client { // TODO setting selection with mouse Q_OBJECT Q_PROPERTY(int sliderCount READ sliderCount WRITE setSliderCount); Q_PROPERTY(QVector<double> values READ values WRITE setValues); Q_PROPERTY(QVector<double> reference READ reference WRITE setReference); Q_PROPERTY(double value READ value WRITE setValue); Q_PROPERTY(double step READ step WRITE setStep); Q_PROPERTY(int index READ index WRITE setIndex); Q_PROPERTY(int selectionSize READ selectionSize WRITE setSelectionSize); Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation); Q_PROPERTY(bool elastic READ dummyBool WRITE setElastic); Q_PROPERTY(int indexThumbSize READ dummyFloat WRITE setIndexThumbSize); Q_PROPERTY(float valueThumbSize READ dummyFloat WRITE setValueThumbSize); Q_PROPERTY(int gap READ dummyInt WRITE setGap); Q_PROPERTY(bool drawLines READ dummyBool WRITE setDrawLines); Q_PROPERTY(bool drawRects READ dummyBool WRITE setDrawRects); Q_PROPERTY(bool isFilled READ dummyBool WRITE setIsFilled); Q_PROPERTY(bool highlight READ dummyBool WRITE setHighlight); Q_PROPERTY(bool editable READ dummyBool WRITE setEditable); Q_PROPERTY(int startIndex READ dummyInt WRITE setStartIndex); Q_PROPERTY(QColor background READ background WRITE setBackground); Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor); Q_PROPERTY(QColor strokeColor READ strokeColor WRITE setStrokeColor); Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor); Q_SIGNALS: void modified(); void interacted(); void action(); void metaAction(); public Q_SLOTS: void doAction(); public: QcMultiSlider(); QVector<double> values() const; void setValues(const QVector<double>&); double value() const; void setValue(double); QVector<double> reference() const; void setReference(const QVector<double>&); double step() const { return roundStep; } void setStep(double); QSize sizeHint() const { return QSize(500, 300); } QSize minimumSizeHint() const { return QSize(50, 50); } const QColor& background() const { return _bkgColor.isValid() ? _bkgColor : palette().color(QPalette::Base); } void setBackground(const QColor& c) { _bkgColor = c; update(); } const QColor& fillColor() const { return _fillColor.isValid() ? _fillColor : palette().color(QPalette::Text); } void setFillColor(const QColor& c) { _fillColor = c; update(); } const QColor& strokeColor() const { return _strokeColor.isValid() ? _strokeColor : palette().color(QPalette::Text); } void setStrokeColor(const QColor& c) { _strokeColor = c; update(); } protected: virtual void mousePressEvent(QMouseEvent*); virtual void mouseMoveEvent(QMouseEvent*); virtual void paintEvent(QPaintEvent*); private: Qt::Orientation orientation() const { return ort; } int index() const { return _currentIndex; } int selectionSize() const { return _selectionSize; } int sliderCount() const { return _values.size(); } void setSliderCount(int size); void setIndex(int i); void setSelectionSize(int i); void setOrientation(Qt::Orientation o) { ort = o; update(); } void setElastic(bool b) { elastic = b; update(); } void setIndexThumbSize(float f) { thumbSize.setWidth(f); update(); } void setValueThumbSize(float f) { thumbSize.setHeight(f); update(); } void setGap(int i) { gap = i; update(); } void setDrawLines(bool b) { drawLines = b; update(); } void setDrawRects(bool b) { drawRects = b; update(); } void setIsFilled(bool b) { isFilled = b; update(); } void setHighlight(bool b) { highlight = b; update(); } void setEditable(bool b) { editable = b; } void setStartIndex(int i) { startIndex = qBound(0, i, _values.count() - 1); update(); } QRect contentsRect(); QRect valueRect(int count, qreal& spacing); inline float valueFromPos(float pos, float range); inline void setValue(int index, double value); double rounded(double value); // values QList<double> _values; QList<double> _ref; int _currentIndex; int _selectionSize; // functional properties double roundStep; bool editable; // visual properties Qt::Orientation ort; bool elastic; QSizeF thumbSize; int gap; bool drawRects; bool drawLines; bool isFilled; bool highlight; int startIndex; QColor _bkgColor; QColor _fillColor; QColor _strokeColor; QColor _focusColor; // temporary QPoint moveOrigin; };
5,947
C++
.h
169
30.065089
115
0.677554
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,979
QcMenu.h
supercollider_supercollider/QtCollider/widgets/QcMenu.h
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #ifndef QC_MENU_H #define QC_MENU_H #include "../Common.h" #include "../QObjectProxy.h" #include "../image.h" #include "../safeptr.hpp" #include <VMGlobals.h> #include <PyrObject.h> #include <QMenu> #include <QMenuBar> #include <QToolBar> #include <QWidgetAction> #include <QApplication> using namespace QtCollider; // @TODO // - Split to separate files? // - QActionGroup wrapper // class QcAction : public QAction { friend QObjectProxy; Q_OBJECT public: QcAction(); Q_PROPERTY(const QtCollider::SharedImage& icon READ icon WRITE setIcon); Q_PROPERTY(QMenu* menu READ menu WRITE setMenu); Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut); Q_PROPERTY(bool separator READ isSeparator WRITE setSeparator); QtCollider::SharedImage icon() { return QtCollider::SharedImage(); } void setIcon(const QtCollider::SharedImage& image); QString shortcut() { return QAction::shortcut().toString(); } void setShortcut(QString shortcut) { QAction::setShortcut(QKeySequence(shortcut)); } }; class QcWidgetAction : public QWidgetAction { friend QObjectProxy; Q_OBJECT public: QcWidgetAction(); Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut); Q_PROPERTY(QWidget* defaultWidget READ defaultWidget WRITE setDefaultWidget); QString shortcut() { return QAction::shortcut().toString(); } void setShortcut(QString shortcut) { QAction::setShortcut(QKeySequence(shortcut)); } private: bool hasCustomWidget; }; class QcMenu : public QMenu { Q_OBJECT public: QcMenu(); ~QcMenu() {}; Q_PROPERTY(QList<QAction*> actions READ actions()); QList<QAction*> actions() const { return QWidget::actions(); } Q_INVOKABLE void popup(QPointF pos, QAction* at); Q_INVOKABLE void setParent(QWidget* parent) { QMenu::setParent(parent); } Q_INVOKABLE void addAction(QAction* action); Q_INVOKABLE void insertAction(QAction* before, QAction* action); Q_INVOKABLE void removeAction(QAction* action); Q_INVOKABLE void clear() { QMenu::clear(); } }; class QcToolBar : public QToolBar { Q_OBJECT public: QcToolBar(); Q_PROPERTY(QList<QAction*> actions READ actions()); QList<QAction*> actions() const { return QToolBar::actions(); } Q_INVOKABLE void addAction(QAction* action); Q_INVOKABLE void insertAction(QAction* before, QAction* action); Q_INVOKABLE void removeAction(QAction* action); Q_INVOKABLE void clear() { QToolBar::clear(); } }; Q_DECLARE_METATYPE(QcMenu*); Q_DECLARE_METATYPE(QcToolBar*); Q_DECLARE_METATYPE(QcAction*); #endif
3,508
C++
.h
93
34.548387
88
0.708038
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,980
QcQuartzComposerView.h
supercollider_supercollider/QtCollider/widgets/QcQuartzComposerView.h
/************************************************************************ * * Copyright 2013 Scott Wilson * * This file is part of SuperCollider Qt GUI. Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QVariantList> #include <QMacCocoaViewContainer> #import <Quartz/Quartz.h> class QcQuartzComposerContainerView : public QMacCocoaViewContainer { Q_OBJECT public: QcQuartzComposerContainerView(QWidget* parent = 0); ~QcQuartzComposerContainerView(); QSize sizeHint() const { return QSize(150, 150); } QSize minimumSizeHint() const { return QSize(30, 30); } }; class QcQuartzComposerView : public QWidget { Q_OBJECT public: QcQuartzComposerView(QWidget* parent = 0); ~QcQuartzComposerView(); QSize sizeHint() const; virtual void resizeEvent(QResizeEvent*); QcQuartzComposerContainerView* containerView; QVariantList inputKeys() const; QVariantList outputKeys() const; bool hasInputKey(NSString* key); bool hasOutputKey(NSString* key); void setInputPort(NSString* key, id val); id getInputPort(NSString* key); id getOutputPort(NSString* key); NSString* getTypeForKey(NSString* key); Q_INVOKABLE void startRendering(); Q_INVOKABLE void stopRendering(); Q_INVOKABLE void loadCompositionFromFile(const QString& path); Q_INVOKABLE void setMaxRenderingFrameRate(double rate); Q_PROPERTY(QVariantList inputKeys READ inputKeys); Q_PROPERTY(QVariantList outputKeys READ outputKeys); private: QVariantList variantForNSObject(id nsObject, NSString* type) const; id nsObjectForQVariant(const QVariantList& data); QCView* mQCView; };
2,397
C++
.h
59
37.237288
96
0.716065
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,981
QcSlider.h
supercollider_supercollider/QtCollider/widgets/QcSlider.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QcAbstractStepValue.h" #include "../QcHelper.h" #include "../style/style.hpp" #include <QWidget> class QcSlider : public QWidget, QcHelper, QcAbstractStepValue, QtCollider::Style::Client { Q_OBJECT Q_PROPERTY(double shiftScale READ dummyFloat WRITE setShiftScale); Q_PROPERTY(double ctrlScale READ dummyFloat WRITE setCtrlScale); Q_PROPERTY(double altScale READ dummyFloat WRITE setAltScale); Q_PROPERTY(double step READ step WRITE setStep) Q_PROPERTY(double pixelStep READ pixelStep) Q_PROPERTY(double value READ value WRITE setValue); Q_PROPERTY(int orientation READ orientation WRITE setOrientation); Q_PROPERTY(int handleLength READ handleLength WRITE setHandleLength); Q_PROPERTY(QColor grooveColor READ grooveColor WRITE setGrooveColor); Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor); Q_PROPERTY(QColor knobColor READ knobColor WRITE setKnobColor); public Q_SLOTS: void increment(double factor); void decrement(double factor); Q_SIGNALS: void action(); void preAction(double); public: QcSlider(); double value() { return _value; } void setValue(double val); double step() { return _step; } void setStep(double d) { _step = d; } double pixelStep(); Qt::Orientation orientation() const { return _ort; } void setOrientation(int); int handleLength() const { return _hndLen; } void setHandleLength(int i) { _hndLen = i; updateGeometry(); update(); } const QColor& knobColor() const { return _knobColor.isValid() ? _knobColor : palette().color(QPalette::ButtonText); } void setKnobColor(const QColor& c) { _knobColor = c; update(); } virtual QSize sizeHint() const; virtual QSize minimumSizeHint() const; protected: virtual void mousePressEvent(QMouseEvent*); virtual void mouseMoveEvent(QMouseEvent*); virtual void wheelEvent(QWheelEvent*); virtual void paintEvent(QPaintEvent*); private: QRect thumbRect(); double valueAt(const QPoint& pos); Qt::Orientation _ort; double _value; double _step; int _hndLen; QColor _knobColor; };
3,125
C++
.h
82
33.95122
91
0.694087
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,982
QcCheckBox.h
supercollider_supercollider/QtCollider/widgets/QcCheckBox.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #include "../QcWidgetFactory.h" #include <QCheckBox> class QcCheckBox : public QCheckBox { Q_OBJECT Q_PROPERTY(bool value READ value WRITE setValue); public: QcCheckBox() { connect(this, SIGNAL(clicked()), this, SIGNAL(action())); } Q_SIGNALS: void action(); private: bool value() { return isChecked(); } void setValue(bool val) { setChecked(val); } }; QC_DECLARE_QWIDGET_FACTORY(QcCheckBox);
1,335
C++
.h
34
36.823529
78
0.657143
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,983
QcAbstractStepValue.h
supercollider_supercollider/QtCollider/widgets/QcAbstractStepValue.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once class QcAbstractStepValue { protected: QcAbstractStepValue(): _shiftScale(100.f), _ctrlScale(10.f), _altScale(0.1f) {} bool modifyStep(double* step); void setShiftScale(double scale) { _shiftScale = scale; } void setCtrlScale(double scale) { _ctrlScale = scale; } void setAltScale(double scale) { _altScale = scale; } double shiftScale() { return _shiftScale; } double ctrlScale() { return _ctrlScale; } double altScale() { return _altScale; } private: double _shiftScale; double _ctrlScale; double _altScale; };
1,480
C++
.h
36
38.277778
83
0.65857
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,984
QcPopUpMenu.h
supercollider_supercollider/QtCollider/widgets/QcPopUpMenu.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #include "../QcHelper.h" #include <QComboBox> class QcPopUpMenu : public QComboBox, QcHelper { Q_OBJECT Q_PROPERTY(QVariantList items READ dummyVariantList WRITE setItems); Q_PROPERTY(bool reactivationEnabled READ reactivationEnabled WRITE setReactivationEnabled) public: QcPopUpMenu(); bool reactivationEnabled() const { return _reactivation; } void setReactivationEnabled(bool b) { _reactivation = b; } Q_SIGNALS: void action(); private Q_SLOTS: void doAction(int); void setChanged() { _changed = true; } void clearChanged() { _changed = false; } private: void setItems(const QVariantList&); bool _changed; bool _reactivation; };
1,602
C++
.h
41
36.195122
94
0.67717
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,985
image_painter.h
supercollider_supercollider/QtCollider/widgets/image_painter.h
/************************************************************************ * * Copyright 2013 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../image.h" #include "../debug.h" #include <QPainter> namespace QtCollider { struct ImagePainter { enum HorizontalMode { AlignLeft, AlignHCenter, AlignRight, TileHorizontally, StretchHorizontally, }; enum VerticalMode { AlignTop, AlignVCenter, AlignBottom, TileVertically, StretchVertically }; SharedImage image; QRectF sourceRect; HorizontalMode horizontalMode; VerticalMode verticalMode; bool scaleToFit; qreal opacity; ImagePainter(): horizontalMode(AlignLeft), verticalMode(AlignTop), scaleToFit(false), opacity(1.0) {} bool isValid() const { return !image.isNull(); } void setImage(const SharedImage& image, const QRectF& rect = QRectF(), int tileMode = 1, qreal opacity = 1.0) { this->image = image; this->sourceRect = rect; this->opacity = opacity; setTileMode(tileMode); } void clear() { image.clear(); } void paint(QPainter* painter, const QRectF& targetRect) { if (!image) return; if (image->isPainting()) { qcErrorMsg("Can not draw image while being painted."); return; } const QPixmap& pixmap = image->pixmap(); if (sourceRect.isNull() || targetRect.isNull()) return; painter->save(); painter->setOpacity(opacity); painter->setRenderHint(QPainter::SmoothPixmapTransform, image->transformationMode == Qt::SmoothTransformation); QRectF rect = sourceRect; qreal ratio = pixmap.devicePixelRatio(); rect.setWidth(rect.width() / ratio); rect.setHeight(rect.height() / ratio); if (horizontalMode == StretchHorizontally) { rect.moveLeft(targetRect.left()); rect.setWidth(targetRect.width()); } if (verticalMode == StretchVertically) { rect.moveTop(targetRect.top()); rect.setHeight(targetRect.height()); } if (horizontalMode != StretchHorizontally && verticalMode != StretchVertically && scaleToFit) { float aspect_ratio = rect.width() / rect.height(); rect.setHeight(targetRect.height()); rect.setWidth(rect.height() * aspect_ratio); if (rect.width() > targetRect.width()) { rect.setWidth(targetRect.width()); rect.setHeight(rect.width() / aspect_ratio); } } switch (horizontalMode) { case AlignLeft: case TileHorizontally: rect.moveLeft(targetRect.left()); break; case AlignHCenter: rect.moveLeft(targetRect.left() + targetRect.width() / 2 - rect.width() / 2); break; case AlignRight: rect.moveRight(targetRect.right()); break; default: break; }; switch (verticalMode) { case AlignTop: case TileVertically: rect.moveTop(targetRect.top()); break; case AlignVCenter: rect.moveTop(targetRect.top() + targetRect.height() / 2 - rect.height() / 2); break; case AlignRight: rect.moveBottom(targetRect.bottom()); break; default: break; }; bool tileVertically = verticalMode == TileVertically; bool tileHorizontally = horizontalMode == TileHorizontally; qreal y_origin = rect.top(); do { do { painter->drawPixmap(rect, pixmap, sourceRect); if (tileVertically) rect.moveTop(rect.top() + rect.height()); else break; } while (rect.top() <= targetRect.bottom()); if (tileHorizontally) { rect.moveTop(y_origin); rect.moveLeft(rect.left() + rect.width()); } else break; } while (rect.left() <= targetRect.right()); painter->restore(); } void setTileMode(const int mode) { /* modes : 1 - fixed to left, fixed to top 2 - horizontally tile, fixed to top 3 - fixed to right, fixed to top 4 - fixed to left, vertically tile 5 - horizontally tile, vertically tile 6 - fixed to right, vertically tile 7 - fixed to left, fixed to bottom 8 - horizontally tile, fixed to bottom 9 - fixed to right, fixed to bottom 10 - fit 11 - center, center (scale) 12 - center , fixed to top 13 - center , fixed to bottom 14 - fixed to left, center 15 - fixed to right, center 16 - center, center (no scale) */ int mode_map_index = mode - 1; if (mode_map_index < 0 || mode_map_index >= 16) return; static int mode_map[16][2] = { { AlignLeft, AlignTop }, { TileHorizontally, AlignTop }, { AlignRight, AlignTop }, { AlignLeft, TileVertically }, { TileHorizontally, TileVertically }, { AlignRight, TileVertically }, { AlignLeft, AlignBottom }, { TileHorizontally, AlignBottom }, { AlignRight, AlignBottom }, { StretchHorizontally, StretchVertically }, { AlignHCenter, AlignVCenter }, { AlignHCenter, AlignTop }, { AlignHCenter, AlignBottom }, { AlignLeft, AlignVCenter }, { AlignRight, AlignVCenter }, { AlignHCenter, AlignVCenter } }; horizontalMode = (HorizontalMode)mode_map[mode_map_index][0]; verticalMode = (VerticalMode)mode_map[mode_map_index][1]; scaleToFit = (mode == 11); } }; } // namespace QtCollider
7,191
C++
.h
175
29.222857
119
0.544231
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,986
QcCanvas.h
supercollider_supercollider/QtCollider/widgets/QcCanvas.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "image_painter.h" #include <QWidget> #include <QPixmap> #include <QBasicTimer> #include <QTime> #include <QPalette> using QcCanvasBase = QWidget; class QcCanvas : public QcCanvasBase { Q_PROPERTY(bool clearOnRefresh READ clearOnRefresh WRITE setClearOnRefresh); Q_PROPERTY(bool drawingEnabled READ drawingEnabled WRITE setDrawingEnabled); Q_PROPERTY(float frameRate READ frameRate WRITE setFrameRate); Q_PROPERTY(int frameCount READ frameCount); Q_PROPERTY(QColor background READ background WRITE setBackground); Q_OBJECT public: QcCanvas(QWidget* parent = 0); bool drawingEnabled() const { return _paint; } void setDrawingEnabled(bool b) { _paint = b; } bool clearOnRefresh() const { return _clearOnRefresh; } void setClearOnRefresh(bool b) { _clearOnRefresh = b; } float frameRate() const; void setFrameRate(float rate); int frameCount() const { return _frameCount; } QColor background() const { return _bkg; } void setBackground(const QColor& c); Q_INVOKABLE void setBackgroundImage(const QtCollider::SharedImage& image, const QRectF& rect, int tileMode, double opacity); Q_INVOKABLE void removeBackgroundImage() { _bkg_image.clear(); update(); } public Q_SLOTS: void refresh(); void clear(); void animate(bool toggle); Q_SIGNALS: void painting(QPainter*); protected: virtual void customEvent(QEvent*); virtual void changeEvent(QEvent*); virtual void resizeEvent(QResizeEvent*); virtual void paintEvent(QPaintEvent*); virtual void timerEvent(QTimerEvent*); private: QPixmap _pixmap; bool _paint; bool _repaintNeeded; bool _clearOnRefresh; bool _clearOnce; bool _resize; float _fps; float _fpsActual; int _timerId; bool _animating; int _frameCount; // SC has no idea of unsigned integers QBasicTimer _fpsTimer; int _meterPeriod; // msecs between actual fps recalculation QTime _meterTime; int _meterFrames; QColor _bkg; QtCollider::ImagePainter _bkg_image; };
3,005
C++
.h
84
32
116
0.697011
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,987
QcRangeSlider.h
supercollider_supercollider/QtCollider/widgets/QcRangeSlider.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QcAbstractStepValue.h" #include "../QcHelper.h" #include "../style/style.hpp" #include <QWidget> class QcRangeSlider : public QWidget, QcHelper, QcAbstractStepValue, QtCollider::Style::Client { Q_OBJECT Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation); Q_PROPERTY(double loValue READ loValue WRITE setLoValue) Q_PROPERTY(double hiValue READ hiValue WRITE setHiValue) Q_PROPERTY(double shiftScale READ dummyFloat WRITE setShiftScale); Q_PROPERTY(double ctrlScale READ dummyFloat WRITE setCtrlScale); Q_PROPERTY(double altScale READ dummyFloat WRITE setAltScale); Q_PROPERTY(double step READ dummyFloat WRITE setStep) Q_PROPERTY(QColor grooveColor READ grooveColor WRITE setGrooveColor); Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor); Q_PROPERTY(QColor knobColor READ knobColor WRITE setKnobColor); public: enum MouseMode { None = 0, Move, MoveHi, MoveLo, SetLo, SetHi }; QcRangeSlider(); Qt::Orientation orientation() const { return _ort; } void setOrientation(int); double loValue() const { return _lo; } void setLoValue(double); double hiValue() const { return _hi; } void setHiValue(double); void setRange(double val, double range); void setStep(double f) { _step = f; } QSize sizeHint() const; QSize minimumSizeHint() const; const QColor& knobColor() const { return _knobColor.isValid() ? _knobColor : palette().color(QPalette::ButtonText); } void setKnobColor(const QColor& c) { _knobColor = c; update(); } public Q_SLOTS: void increment(double factor); void decrement(double factor); Q_SIGNALS: void action(); private: QRect thumbRect(); QRect valueRect(); double valueFromPos(const QPoint& pos); void moveBy(double); void increment(); void decrement(); void mouseMoveEvent(QMouseEvent*); void mousePressEvent(QMouseEvent*); void mouseReleaseEvent(QMouseEvent*); void keyPressEvent(QKeyEvent*); void paintEvent(QPaintEvent*); Qt::Orientation asOrientationWithDefault(int, Qt::Orientation); Qt::Orientation _ort; double _lo; double _hi; double _step; QPoint dragOrigin; double dragVal, dragRange; MouseMode mouseMode; QColor _knobColor; };
3,259
C++
.h
84
34.761905
96
0.700917
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,988
QcWindow.h
supercollider_supercollider/QtCollider/widgets/QcWindow.h
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "BasicWidgets.h" #include "QcScrollArea.h" class QcWindow : public QcCustomPainted { Q_OBJECT public: QcWindow() {} Q_INVOKABLE QcWindow(const QString& title, const QRectF& geom, bool resizable, bool frame); }; class QcScrollWindow : public QcScrollArea { Q_OBJECT public: QcScrollWindow() {} Q_INVOKABLE QcScrollWindow(const QString& title, const QRectF& geom, bool resizable, bool frame); };
1,351
C++
.h
35
36.257143
101
0.670732
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,989
scope_shm_interface.hpp
supercollider_supercollider/QtCollider/widgets/scope_shm_interface.hpp
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of Qt GUI for SuperCollider. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../../common/server_shm.hpp" #include <QObject> namespace QtCollider { class ScopeShm : public QObject { public: ScopeShm(QObject* parent): QObject(parent), client(0) {} server_shared_memory_client* client; scope_buffer_reader reader; }; } // namespace QtCollider
1,216
C++
.h
31
37.032258
74
0.659033
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
33,990
QcGraph.h
supercollider_supercollider/QtCollider/widgets/QcGraph.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../Common.h" #include "../QcHelper.h" #include "../style/style.hpp" #include <QWidget> struct QcGraphElement { friend class QcGraphModel; enum CurveType { Step = 0, Linear, Sine, Welch, Exponential, Quadratic, Cubic, Curvature, Hold }; QcGraphElement(const QSize& sz): size(sz), curveType(Linear), curvature(0.0), editable(true), selected(false), _prev(0), _next(0) {} void setCurveType(CurveType type, double curve = 0.0) { curveType = type; curvature = curve; } QcGraphElement* prev() { return _prev; } QcGraphElement* next() { return _next; } QPointF value; QSize size; QString text; QColor fillColor; CurveType curveType; double curvature; bool editable; bool selected; private: QcGraphElement* _prev; QcGraphElement* _next; }; class QcGraphModel : public QObject { Q_OBJECT public: QcGraphModel(QObject* parent = 0): QObject(parent) {} struct Connection { Connection(QcGraphElement* a_ = 0, QcGraphElement* b_ = 0): a(a_), b(b_) {} QcGraphElement* a; QcGraphElement* b; }; inline QList<QcGraphElement*> elements() const { return _elems; } inline QcGraphElement* elementAt(int i) const { return _elems[i]; } inline int elementCount() const { return _elems.count(); } void append(QcGraphElement* e); void removeAt(int i); inline QList<Connection> connections() const { return _conns; } void connect(int xi, int yi) { QcGraphElement* x = _elems[xi]; QcGraphElement* y = _elems[yi]; int i; for (i = 0; i < _conns.count(); ++i) { Connection c = _conns[i]; if ((c.a == x && c.b == y) || (c.a == y && c.b == x)) return; } _conns.append(Connection(x, y)); } Q_SIGNALS: void appended(QcGraphElement*); void removed(QcGraphElement*); private: QList<Connection> _conns; QList<QcGraphElement*> _elems; }; class QcGraph : public QWidget, QcHelper, QtCollider::Style::Client { Q_OBJECT Q_ENUMS(ElementStyle) Q_PROPERTY(QVariantList value READ value WRITE setValue) Q_PROPERTY(QVariantList strings READ dummyVariantList WRITE setStrings); Q_PROPERTY(int index READ index WRITE setIndex); Q_PROPERTY(int lastIndex READ lastIndex); Q_PROPERTY(QVariantList selectionIndexes READ selectionIndexes); Q_PROPERTY(int thumbSize READ dummyInt WRITE setThumbSize); Q_PROPERTY(int thumbWidth READ dummyInt WRITE setThumbWidth); Q_PROPERTY(int thumbHeight READ dummyInt WRITE setThumbHeight); Q_PROPERTY(QColor background READ background WRITE setBackground); Q_PROPERTY(QColor strokeColor READ strokeColor WRITE setStrokeColor); Q_PROPERTY(QColor fillColor READ dummyColor WRITE setFillColor); Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor); Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor); Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor); Q_PROPERTY(bool drawLines READ dummyBool WRITE setDrawLines); Q_PROPERTY(bool drawRects READ dummyBool WRITE setDrawRects); Q_PROPERTY(ElementStyle style READ elementStyle WRITE setElementStyle); Q_PROPERTY(bool editable READ dummyBool WRITE setEditable); Q_PROPERTY(double step READ step WRITE setStep); Q_PROPERTY(int selectionForm READ selectionForm WRITE setSelectionForm); Q_PROPERTY(int horizontalOrder READ horizontalOrder WRITE setHorizontalOrder); Q_PROPERTY(float x READ currentX WRITE setCurrentX); Q_PROPERTY(float y READ currentY WRITE setCurrentY); Q_PROPERTY(QPointF grid READ grid WRITE setGrid); Q_PROPERTY(bool gridOn READ dummyBool WRITE setGridOn); public: Q_INVOKABLE void connectElements(int, QVariantList); Q_INVOKABLE void setStringAt(int, const QString&); Q_INVOKABLE void setFillColorAt(int, const QColor&); Q_INVOKABLE void setEditableAt(int, bool); Q_INVOKABLE void setThumbHeightAt(int, int); Q_INVOKABLE void setThumbWidthAt(int, int); Q_INVOKABLE void setThumbSizeAt(int, int); Q_INVOKABLE void setCurves(double curvature); Q_INVOKABLE void setCurves(int type); Q_INVOKABLE void setCurves(const QVariantList& curves); public Q_SLOTS: Q_INVOKABLE void select(int index, bool exclusive = true); Q_INVOKABLE void deselect(int index); Q_INVOKABLE void deselectAll(); Q_SIGNALS: void action(); void metaAction(); public: enum SelectionForm { ElasticSelection, RigidSelection }; enum Order { NoOrder, RigidOrder }; enum ElementStyle { DotElements, RectElements, }; public: QcGraph(); QVariantList value() const; QcGraphElement* currentElement() const; int index() const; /** \brief The last node selected, regardless of current selection status. * * If no nodes have been selected yet, defaults to -1. */ int lastIndex() const { return _lastIndex; } QVariantList selectionIndexes() const; float currentX() const; float currentY() const; QPointF grid() const { return _gridMetrics; } void setValue(const QVariantList&); void setStrings(const QVariantList& list); void setIndex(int i); void setCurrentX(float); void setCurrentY(float); void setThumbSize(int f); void setThumbWidth(int f); void setThumbHeight(int f); const QColor& background() const { return _bkg.isValid() ? _bkg : palette().color(QPalette::Base); } void setBackground(const QColor& c) { _bkg = c; update(); } const QColor& selectionColor() const { return _selectColor.isValid() ? _selectColor : palette().color(QPalette::Highlight); } void setSelectionColor(const QColor& c) { _selectColor = c; update(); } const QColor& strokeColor() const { return _strokeColor.isValid() ? _strokeColor : palette().color(QPalette::Text); } void setStrokeColor(const QColor& c) { _strokeColor = c; update(); } void setFillColor(const QColor& c); QColor gridColor() const { if (_gridColor.isValid()) return _gridColor; else { QColor c = palette().color(QPalette::Text); c.setAlpha(40); return c; } } void setGridColor(const QColor& c) { _gridColor = c; update(); } ElementStyle elementStyle() const { return _style; } void setElementStyle(ElementStyle s) { _style = s; _geometryDirty = true; update(); } void setDrawLines(bool b) { _drawLines = b; update(); } void setDrawRects(bool b) { _drawRects = b; update(); } void setEditable(bool b) { _editable = b; update(); } double step() const { return _step; } void setStep(double); int selectionForm() const { return (int)_selectionForm; } void setSelectionForm(int i) { _selectionForm = (SelectionForm)i; } int horizontalOrder() const { return (int)_xOrder; } void setHorizontalOrder(int i); void setGrid(const QPointF& pt) { _gridMetrics = pt; update(); } void setGridOn(bool b) { _gridOn = b; update(); } QSize sizeHint() const { return QSize(200, 200); } QSize minimumSizeHint() const { return QSize(50, 50); } private Q_SLOTS: void onElementRemoved(QcGraphElement* e); private: struct SelectedElement { SelectedElement(QcGraphElement* e): elem(e) {} bool operator==(const SelectedElement& other) const { return elem == other.elem; } QcGraphElement* elem; QPointF moveOrigin; // in data domain }; private: void setAllDeselected(); /** \brief Sets a node as being either selected or unselected. * * \c update() is called at the end of the function. * * \param index the index of the node to update * \param selected whether to mark it as selected or not * \post \c lastIndex() returns \c index if the node was newly selected. */ void setIndexSelected(int index, bool selected); void restrictValue(QPointF&); void orderRestrictValue(QcGraphElement*, QPointF&, bool selected); void setValue(QcGraphElement*, const QPointF&); void ensureOrder(); void moveFree(QcGraphElement*, const QPointF&); void moveOrderRestricted(QcGraphElement*, const QPointF&); void moveSelected(const QPointF& dValue, SelectionForm, bool fromCache); void addCurve(QPainterPath&, QcGraphElement* e1, QcGraphElement* e2); QSize drawnElementSize(QcGraphElement* e); QRect valueRect(); QRectF labelRect(QcGraphElement*, const QPointF&, const QRect&, const QFontMetrics&); void drawDotElement(QcGraphElement*, const QRectF&, const QRect& bounds, const QColor& dotColor, const QColor& circleColor, const QColor& textColor, const QColor& selectColor, const QPalette&, const QFontMetrics&, QPainter*); void drawRectElement(QcGraphElement*, const QRectF&, const QColor& fillColor, const QColor& textColor, const QColor& selectColor, const QPalette&, QPainter*); void paintEvent(QPaintEvent*); void mousePressEvent(QMouseEvent*); void mouseMoveEvent(QMouseEvent*); void keyPressEvent(QKeyEvent*); void doAction(Qt::KeyboardModifiers); QcGraphModel _model; QColor _bkg; QColor _strokeColor; QColor _gridColor; QColor _selectColor; QSize _defaultThumbSize; QPointF _gridMetrics; bool _gridOn; ElementStyle _style; bool _drawLines; bool _drawRects; bool _editable; double _step; SelectionForm _selectionForm; Order _xOrder; bool _geometryDirty; QSize _largestThumbSize; struct Selection { Selection(): cached(false), shallMove(false) {} int size() const { return elems.size(); } int count() const { return elems.count(); } QList<SelectedElement> elems; bool cached; bool shallMove; QPointF moveOrigin; // in data domain } _selection; int _lastIndex; ///< The last node selected, regardless of the current state of selection };
11,261
C++
.h
298
31.909396
119
0.674063
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,991
QcNumberBox.h
supercollider_supercollider/QtCollider/widgets/QcNumberBox.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QLineEdit> #include "QcAbstractStepValue.h" #include "../QcHelper.h" #include <QDoubleValidator> class QcNumberBox : public QLineEdit, QcHelper, QcAbstractStepValue { Q_OBJECT Q_PROPERTY(double shiftScale READ dummyFloat WRITE setShiftScale); Q_PROPERTY(double ctrlScale READ dummyFloat WRITE setCtrlScale); Q_PROPERTY(double altScale READ dummyFloat WRITE setAltScale); Q_PROPERTY(double minimum READ minimum WRITE setMinimum); Q_PROPERTY(double maximum READ maximum WRITE setMaximum); Q_PROPERTY(int decimals READ decimals WRITE setDecimals); Q_PROPERTY(int maxDecimals READ maxDecimals WRITE setMaxDecimals); Q_PROPERTY(int minDecimals READ minDecimals WRITE setMinDecimals); Q_PROPERTY(double value READ value WRITE setValue); Q_PROPERTY(int valueType READ valueType); Q_PROPERTY(QString text READ text WRITE setTextValue); Q_PROPERTY(double step READ dummyFloat WRITE setStep) Q_PROPERTY(double scrollStep READ dummyFloat WRITE setScrollStep) Q_PROPERTY(bool scroll READ dummyBool WRITE setScroll); Q_PROPERTY(QColor normalColor READ dummyColor WRITE setTextColor); Q_PROPERTY(QColor editingColor READ dummyColor WRITE setEditedTextColor); public: enum ValueType { Number, Infinite, InfiniteNegative, NaN, Text }; QcNumberBox(); void setStep(double step_) { step = step_; } void setScrollStep(double step_) { scrollStep = step_; } void setScroll(bool b) { scroll = b; } void setLocked(bool); void setTextColor(const QColor& c); void setEditedTextColor(const QColor& c); void setValue(double); Q_INVOKABLE void setInfinite(bool positive = true); Q_INVOKABLE void setNaN(); void setTextValue(const QString&); double value() const; int valueType() const { return (int)_valueType; } double minimum() const { return _validator->bottom(); } double maximum() const { return _validator->top(); } void setMinimum(double); void setMaximum(double); int decimals() const { return maxDecimals(); } int minDecimals() const { return _minDec; } int maxDecimals() const { return _maxDec; } void setDecimals(int); void setMinDecimals(int); void setMaxDecimals(int); public Q_SLOTS: void increment(double factor); void decrement(double factor); Q_SIGNALS: void scrolled(int steps); void valueChanged(); void action(); private Q_SLOTS: void onEditingFinished(); void updateText(); protected: virtual void keyPressEvent(QKeyEvent* event); virtual void mouseDoubleClickEvent(QMouseEvent* event); virtual void mousePressEvent(QMouseEvent* event); virtual void mouseMoveEvent(QMouseEvent* event); virtual void wheelEvent(QWheelEvent* event); private: void stepBy(int steps, double stepSize); double roundedVal(double val); QString stringForVal(double val); void updateTextColor(); inline void doAction(); bool scroll; int lastPos; QColor editedTextColor; QColor normalTextColor; QDoubleValidator* _validator; double step; double scrollStep; float dragDist; double _value; ValueType _valueType; int _minDec; int _maxDec; }; #if 0 class NumberBoxWidget : public QDoubleSpinBox { friend class SCNumberBox; Q_OBJECT public: NumberBoxWidget( ); void setScroll( bool b ); private Q_SLOTS: void stepBy( int steps ); void scrollBy( int steps ); void onEditingFinished(); protected: virtual void keyPressEvent ( QKeyEvent * event ); private: void stepBy( int steps, float stepSize ); SCAbstractStepValue *modifier; float scrollStep; }; #endif
4,593
C++
.h
123
33.357724
77
0.718202
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,992
QcScopeShm.h
supercollider_supercollider/QtCollider/widgets/QcScopeShm.h
/************************************************************************ * * Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of Qt GUI for SuperCollider. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../QcHelper.h" #include <SC_Types.h> #include <QWidget> // FIXME: Due to Qt bug #22829, moc can not process headers that include // boost/type_traits/detail/has_binary_operator.hp from boost 1.48, so // we have to wrap the shm interface into a separate class. namespace QtCollider { class ScopeShm; } using QtCollider::ScopeShm; class QcScopeShm : public QWidget, QcHelper { Q_OBJECT Q_PROPERTY(int serverPort READ serverPort WRITE setServerPort); Q_PROPERTY(int bufferNumber READ dummyInt WRITE setBufferNumber); Q_PROPERTY(float xOffset READ dummyFloat WRITE setXOffset); Q_PROPERTY(float yOffset READ dummyFloat WRITE setYOffset); Q_PROPERTY(float xZoom READ dummyFloat WRITE setXZoom); Q_PROPERTY(float yZoom READ dummyFloat WRITE setYZoom); Q_PROPERTY(int style READ style WRITE setStyle); Q_PROPERTY(QVariantList waveColors READ dummyVariantList WRITE setWaveColors); Q_PROPERTY(QColor background READ background WRITE setBackground); Q_PROPERTY(bool fill READ fill WRITE setFill); Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval); Q_PROPERTY(bool running READ running); public: QcScopeShm(); ~QcScopeShm(); int serverPort() const { return _srvPort; } void setServerPort(int); void setBufferNumber(int); void setXOffset(float f) { xOffset = f; } void setYOffset(float f) { yOffset = f; } void setXZoom(float f) { xZoom = f; } void setYZoom(float f) { yZoom = f; } int style() const { return _style; } void setStyle(int i) { _style = i; } void setWaveColors(const QVariantList& colors); QColor background() const { return _bkg; } void setBackground(const QColor& c) { _bkg = c; update(); } bool fill() { return _fill; }; void setFill(bool b) { _fill = b; }; int updateInterval() const; void setUpdateInterval(int i); bool running() const { return _running; } QSize sizeHint() const { return QSize(500, 300); } QSize minimumSizeHint() const { return QSize(50, 50); } public Q_SLOTS: void start(); void stop(); protected: void resizeEvent(QResizeEvent*); void paintEvent(QPaintEvent*); private Q_SLOTS: void updateScope(); private: void connectSharedMemory(int port); void initScopeReader(ScopeShm*, int index); void paint1D(bool overlapped, int channels, int maxFrames, int frames, const QRect& area, QPainter&); void paint2D(int channels, int maxFrames, int frames, const QRect& area, QPainter&); int _srvPort; int _scopeIndex; ScopeShm* _shm; bool _running; float* _data; uint _availableFrames; QTimer* timer; float xOffset; float yOffset; float xZoom; float yZoom; int _style; QList<QColor> colors; QColor _bkg; bool _fill; QPixmap _pixmap; };
3,788
C++
.h
100
33.97
105
0.691721
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,993
QcKnob.hpp
supercollider_supercollider/QtCollider/widgets/QcKnob.hpp
/************************************************************************ * * Copyright 2011-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QWidget> #include "QcAbstractStepValue.h" #include "../style/style.hpp" class QcKnob : public QWidget, QcAbstractStepValue, QtCollider::Style::Client { Q_OBJECT Q_PROPERTY(double shiftScale READ shiftScale WRITE setShiftScale); Q_PROPERTY(double ctrlScale READ ctrlScale WRITE setCtrlScale); Q_PROPERTY(double altScale READ altScale WRITE setAltScale); Q_PROPERTY(double value READ value WRITE setValue) Q_PROPERTY(int mode READ mode WRITE setMode) Q_PROPERTY(double step READ step WRITE setStep) Q_PROPERTY(bool centered READ centered WRITE setCentered) Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor); Q_SIGNALS: void action(); public: QcKnob(); void setValue(double); double value() const { return _value; } void setMode(int i) { _mode = i; } int mode() const { return _mode; } void setStep(float step) { _step = step; } float step() const { return _step; } void setCentered(bool b) { _centered = b; update(); } bool centered() const { return _centered; } virtual QSize sizeHint() const { return QSize(40, 40); } virtual QSize minimumSizeHint() const { return QSize(15, 15); } protected: virtual void mousePressEvent(QMouseEvent*); virtual void mouseMoveEvent(QMouseEvent*); virtual void paintEvent(QPaintEvent*); private: double value(const QPoint&); double _value; double _step; int _mode; QPoint _prevPos; bool _centered; };
2,434
C++
.h
63
34.952381
79
0.681914
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
33,994
QcTextField.h
supercollider_supercollider/QtCollider/widgets/QcTextField.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #include "../QcWidgetFactory.h" #include <QLineEdit> #include <QKeyEvent> class QcTextField : public QLineEdit { Q_OBJECT public: QcTextField() {} protected: virtual void keyPressEvent(QKeyEvent* e) { // NOTE: We could use the returnPressed() signal, but that would still // propagate the event to parent, which we want to avoid. if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) Q_EMIT(action()); else QLineEdit::keyPressEvent(e); } Q_SIGNALS: void action(); }; QC_DECLARE_QWIDGET_FACTORY(QcTextField);
1,510
C++
.h
40
34.2
78
0.639098
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,995
QcScrollArea.h
supercollider_supercollider/QtCollider/widgets/QcScrollArea.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QcCanvas.h" #include "../QcHelper.h" #include <QScrollArea> class QObjectProxy; class QcScrollWidget : public QcCanvas { Q_OBJECT public: QcScrollWidget(QWidget* parent = 0); QSize sizeHint() const; protected: virtual bool event(QEvent*); virtual bool eventFilter(QObject*, QEvent*); }; class QcScrollArea : public QScrollArea, public QcHelper { Q_OBJECT Q_PROPERTY(bool hasBorder READ dummyBool WRITE setHasBorder); Q_PROPERTY(QRectF innerBounds READ innerBounds); Q_PROPERTY(QPointF visibleOrigin READ visibleOrigin WRITE setVisibleOrigin); Q_SIGNALS: void scrolled(); public: QcScrollArea(); Q_INVOKABLE void setWidget(QWidget*); Q_INVOKABLE void addChild(QWidget* w); void setHasBorder(bool b); QRectF innerBounds() const; QPointF visibleOrigin() const; void setVisibleOrigin(const QPointF&); QSize sizeHint() const { return QSize(300, 200); } QSize minimumSizeHint() const { return QSize(50, 50); } };
1,922
C++
.h
52
33.961538
80
0.689952
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,996
QcButton.h
supercollider_supercollider/QtCollider/widgets/QcButton.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #include "../QcHelper.h" #include "QcMenu.h" #include "../style/style.hpp" #include <QPushButton> class QcButton : public QPushButton, QcHelper, QtCollider::Style::Client { Q_OBJECT Q_PROPERTY(QVariantList states READ dummyVariantList WRITE setStates); Q_PROPERTY(int value READ getValue WRITE setValue); Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor); Q_PROPERTY(QcMenu* menu READ qcmenu WRITE setQcMenu); Q_PROPERTY(const QtCollider::SharedImage& icon READ icon WRITE setIcon); public: QcButton(); Q_SIGNALS: void action(int); protected: #ifdef Q_WS_MAC bool hitButton(const QPoint&) const; #endif virtual void paintEvent(QPaintEvent*); private Q_SLOTS: void doAction(); private: struct State { QString text; QColor textColor; QColor buttonColor; }; void setStates(const QVariantList&); void setValue(int val) { setState(val); } int getValue() const { return currentState; } void setQcMenu(QcMenu* menu); QcMenu* qcmenu() const; QtCollider::SharedImage icon() { return QtCollider::SharedImage(); } void setIcon(const QtCollider::SharedImage& image); void setState(int); void cycleStates(); QList<State> states; int currentState; };
2,194
C++
.h
60
33.1
76
0.685176
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,997
QcTextEdit.h
supercollider_supercollider/QtCollider/widgets/QcTextEdit.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../QcHelper.h" #include <QTextEdit> class QcTextEdit : public QTextEdit, QcHelper { Q_OBJECT Q_PROPERTY(QString document READ documentFilename WRITE setDocument); Q_PROPERTY(int selectionStart READ selectionStart); Q_PROPERTY(int selectionSize READ selectionSize); Q_PROPERTY(QString selectedString READ selectedString WRITE replaceSelectedText); Q_PROPERTY(QString currentLine READ currentLine); Q_PROPERTY(QFont textFont READ dummyFont WRITE setTextFont); Q_PROPERTY(QColor textColor READ dummyColor WRITE setTextColor); Q_PROPERTY(QVariantList rangeColor READ dummyVariantList WRITE setRangeColor); Q_PROPERTY(QVariantList rangeFont READ dummyVariantList WRITE setRangeFont); Q_PROPERTY(QVariantList rangeText READ dummyVariantList WRITE setRangeText); Q_PROPERTY(bool enterInterpretsSelection READ interpretSelection WRITE setInterpretSelection); public: QcTextEdit(); QString documentFilename() const; void setDocument(const QString&); int selectionStart() const; int selectionSize() const; Q_INVOKABLE void select(int start, int size); QString selectedString() const; void replaceSelectedText(const QString&); QString currentLine() const; bool interpretSelection() const { return _interpretSelection; } void setInterpretSelection(bool b) { _interpretSelection = b; } void setTextFont(const QFont&); void setTextColor(const QColor&); void setRangeColor(const QVariantList&); void setRangeFont(const QVariantList&); void setRangeText(const QVariantList&); Q_SIGNALS: void interpret(const QString& code); protected: virtual void keyPressEvent(QKeyEvent*); virtual void insertFromMimeData(const QMimeData*); private: QString& prepareText(QString& str) const; QString _document; bool _interpretSelection; };
2,784
C++
.h
63
40.587302
98
0.732301
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,998
QcPenPrinter.h
supercollider_supercollider/QtCollider/widgets/QcPenPrinter.h
/************************************************************************ * * Copyright 2011 Jonatan Liljedahl <lijon@kymatica.com> * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../painting.h" #include "../debug.h" #include <QPrintDialog> #include <QPrinter> #include <QPainter> class QcPenPrinter : public QObject { Q_OBJECT Q_PROPERTY(QRect pageRect READ pageRect); Q_PROPERTY(QRect paperRect READ paperRect); Q_PROPERTY(int fromPage READ fromPage); Q_PROPERTY(int toPage READ toPage); public: QcPenPrinter(): dialog(0) {} ~QcPenPrinter() { delete dialog; } QRect pageRect() const { return printer.pageLayout().paintRectPixels(printer.resolution()); } QRect paperRect() const { return printer.pageLayout().fullRectPixels(printer.resolution()); } int fromPage() const { return printer.fromPage(); } int toPage() const { return printer.toPage(); } Q_SIGNALS: void dialogDone(int); void printFunc(); private Q_SLOTS: void show() { if (!dialog) { dialog = new QPrintDialog(&printer); dialog->setWindowTitle(QStringLiteral("Print Document")); dialog->setOptions(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange | QAbstractPrintDialog::PrintShowPageSize); connect(dialog, SIGNAL(finished(int)), this, SIGNAL(dialogDone(int))); } if (dialog->isVisible()) qcWarningMsg("WARNING: Print dialog already open."); else dialog->exec(); } void print() { QPainter painter; painter.begin(&printer); QtCollider::beginPainting(&painter); Q_EMIT(printFunc()); painter.end(); QtCollider::endPainting(); } void newPage() { printer.newPage(); } private: QPrinter printer; QPrintDialog* dialog; };
2,631
C++
.h
69
32.855072
103
0.64849
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
33,999
web_page.hpp
supercollider_supercollider/QtCollider/widgets/web_page.hpp
/************************************************************************ * * Copyright 2011-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QWebEnginePage> namespace QtCollider { class WebPage : public QWebEnginePage { Q_OBJECT public: WebPage(QObject* parent): QWebEnginePage(parent), _delegateReload(false), _delegateNavigation(false) {} virtual void triggerAction(WebAction action, bool checked = false) override; virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) override; bool delegateReload() const { return _delegateReload; } void setDelegateReload(bool flag) { _delegateReload = flag; } bool delegateNavigation() const { return _delegateNavigation; } void setDelegateNavigation(bool flag) { _delegateNavigation = flag; } bool acceptNavigationRequest(const QUrl& url, NavigationType type, bool isMainFrame) override; Q_SIGNALS: void jsConsoleMsg(const QString&, int, const QString&); void navigationRequested(const QUrl& url, QWebEnginePage::NavigationType, bool); private: bool _delegateReload; bool _delegateNavigation; }; } // namespace QtCollider
2,050
C++
.h
43
43.744186
118
0.699097
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
34,000
QcSlider2D.h
supercollider_supercollider/QtCollider/widgets/QcSlider2D.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QcAbstractStepValue.h" #include "../QcHelper.h" #include "../style/style.hpp" #include "image_painter.h" #include <QWidget> class QcSlider2D : public QWidget, QcHelper, QcAbstractStepValue, QtCollider::Style::Client { Q_OBJECT Q_PROPERTY(double xValue READ xValue WRITE setXValue) Q_PROPERTY(double yValue READ yValue WRITE setYValue) Q_PROPERTY(double shiftScale READ dummyFloat WRITE setShiftScale); Q_PROPERTY(double ctrlScale READ dummyFloat WRITE setCtrlScale); Q_PROPERTY(double altScale READ dummyFloat WRITE setAltScale); Q_PROPERTY(double step READ dummyFloat WRITE setStep) Q_PROPERTY(int thumbSize READ thumbSize WRITE setThumbSize); Q_PROPERTY(QColor grooveColor READ grooveColor WRITE setGrooveColor); Q_PROPERTY(QColor focusColor READ focusColor WRITE setFocusColor); Q_PROPERTY(QColor knobColor READ knobColor WRITE setKnobColor); public: QcSlider2D(); double xValue() const { return _x; } double yValue() const { return _y; } void setXValue(double x) { setValue(QPointF(x, _y), false); } void setYValue(double y) { setValue(QPointF(_x, y), false); } void setStep(double f) { _step = f; } const QColor& knobColor() const { return _knobColor.isValid() ? _knobColor : palette().color(QPalette::ButtonText); } void setKnobColor(const QColor& c) { _knobColor = c; update(); } QSize sizeHint() const { return QSize(150, 150); } QSize minimumSizeHint() const { return QSize(30, 30); } int thumbSize() const { return _thumbSize.width(); } void setThumbSize(int i) { const auto clamped = std::clamp(i, 0, std::numeric_limits<int>::max()); _thumbSize = QSize(clamped, clamped); updateGeometry(); update(); } Q_INVOKABLE void setBackgroundImage(const QtCollider::SharedImage& image, const QRectF& rect, int tileMode, double opacity); public Q_SLOTS: void incrementX(double factor = 1.f); void decrementX(double factor = 1.f); void incrementY(double factor = 1.f); void decrementY(double factor = 1.f); Q_SIGNALS: void action(); void randomize(); private: QRect thumbRect(); void setValue(const QPointF val, bool doAction = true); void mouseMoveEvent(QMouseEvent*); void mousePressEvent(QMouseEvent*); void keyPressEvent(QKeyEvent*); void paintEvent(QPaintEvent*); double _x; double _y; QSize _thumbSize; double _step; QColor _knobColor; QtCollider::ImagePainter _backgroundImage; };
3,468
C++
.h
85
36.635294
116
0.688704
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,001
QcTreeWidget.h
supercollider_supercollider/QtCollider/widgets/QcTreeWidget.h
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../Common.h" #include "../QObjectProxy.h" #include "../safeptr.hpp" #include <VMGlobals.h> #include <PyrObject.h> #include <QTreeWidget> #include <QTreeWidgetItem> #include <QApplication> using namespace QtCollider; class QcTreeWidget : public QTreeWidget { public: class Item : public QTreeWidgetItem { public: enum { Type = QTreeWidgetItem::UserType }; Item(): QTreeWidgetItem(Item::Type), _safePtr(this) {} Item(const QStringList& strings): QTreeWidgetItem(strings, Item::Type), _safePtr(this) {} ~Item() { _safePtr.invalidate(); } SafePtr<Item> safePtr() const { return _safePtr; } static SafePtr<Item> safePtr(QTreeWidgetItem*); static void initialize(VMGlobals*, PyrObject*, const SafePtr<Item>&); static int finalize(VMGlobals*, PyrObject*); bool operator<(const QTreeWidgetItem& other) const; private: SafePtr<Item> _safePtr; }; typedef SafePtr<Item> ItemPtr; Q_OBJECT Q_PROPERTY(QVariantList columns READ columns WRITE setColumns) Q_PROPERTY(QcTreeWidget::ItemPtr currentItem READ currentItem WRITE setCurrentItem); public: Q_INVOKABLE QcTreeWidget::ItemPtr item(const QcTreeWidget::ItemPtr& parent, int index); Q_INVOKABLE QcTreeWidget::ItemPtr parentItem(const QcTreeWidget::ItemPtr&); Q_INVOKABLE int indexOfItem(const QcTreeWidget::ItemPtr&); Q_INVOKABLE QcTreeWidget::ItemPtr addItem(const QcTreeWidget::ItemPtr& parent, const QVariantList& data); Q_INVOKABLE QcTreeWidget::ItemPtr insertItem(const QcTreeWidget::ItemPtr& parent, int index, const QVariantList& data); Q_INVOKABLE void removeItem(const QcTreeWidget::ItemPtr&); Q_INVOKABLE QVariantList strings(const QcTreeWidget::ItemPtr&); Q_INVOKABLE void setText(const QcTreeWidget::ItemPtr&, int column, const QString&); Q_INVOKABLE void setColor(const QcTreeWidget::ItemPtr&, int column, const QColor&); Q_INVOKABLE void setTextColor(const QcTreeWidget::ItemPtr&, int column, const QColor&); Q_INVOKABLE QWidget* itemWidget(const QcTreeWidget::ItemPtr&, int column); Q_INVOKABLE void setItemWidget(const QcTreeWidget::ItemPtr&, int column, QWidget*); Q_INVOKABLE void removeItemWidget(const QcTreeWidget::ItemPtr&, int column); Q_INVOKABLE void sort(int column, bool descending); Q_INVOKABLE int columnWidth(int column); Q_INVOKABLE void setColumnWidth(int column, int width); Q_SIGNALS: void action(); void itemPressedAction(); void currentItemChanged(); void expanded(QcTreeWidget::ItemPtr); void collapsed(QcTreeWidget::ItemPtr); public: QcTreeWidget(); ItemPtr currentItem() const; void setCurrentItem(const ItemPtr&); QVariantList columns() const; void setColumns(const QVariantList&); public Q_SLOTS: void onExpanded(QTreeWidgetItem*); void onCollapsed(QTreeWidgetItem*); protected: virtual void keyPressEvent(QKeyEvent*); private: QTreeWidgetItem* _itemOnPress; bool _emitAction; }; Q_DECLARE_METATYPE(QcTreeWidget::ItemPtr);
4,043
C++
.h
90
40.255556
109
0.71123
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,002
QcWebView.h
supercollider_supercollider/QtCollider/widgets/QcWebView.h
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../QcCallback.hpp" #include <QtGlobal> #include <QWebEngineView> #include <QWebEnginePage> #include <QPointer> #include <QUrl> #include <QException> #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) # include <QWebEngineCallback> #endif const static int kWebEngineTimeout = 10000; Q_DECLARE_METATYPE(QUrl) namespace QtCollider { class WebPage; class WebView : public QWebEngineView { Q_OBJECT public: Q_INVOKABLE void setFontFamily(int genericFontFamily, const QString& fontFamily); Q_INVOKABLE void triggerPageAction(int action, bool checked = false); Q_INVOKABLE QAction* pageAction(QWebEnginePage::WebAction) const; // QWebEnginePage forwards // Note: need to use QtCollider:: namespace here due to limitations of Qt metatype system Q_INVOKABLE void setHtml(const QString& html, const QString& baseUrl); Q_INVOKABLE void setContent(const QVector<int>& data, const QString& mimeType, const QString& baseUrl); Q_INVOKABLE void toHtml(QtCollider::QcCallback* cb) const; Q_INVOKABLE void toPlainText(QtCollider::QcCallback* cb) const; Q_INVOKABLE void runJavaScript(const QString& script, QtCollider::QcCallback* cb); Q_INVOKABLE void setWebAttribute(int attr, bool on); Q_INVOKABLE bool testWebAttribute(int attr); Q_INVOKABLE void resetWebAttribute(int attr); Q_INVOKABLE void navigate(const QString& url); public Q_SLOTS: void findText(const QString& searchText, bool reversed, QtCollider::QcCallback* cb = nullptr); Q_SIGNALS: void linkActivated(const QString&, int, bool); void jsConsoleMsg(const QString&, int, const QString&); void reloadTriggered(const QString&); // QWebEnginePage forwards void linkHovered(const QString& url); void geometryChangeRequested(const QRect& geom); void windowCloseRequested(); void navigationRequested(const QUrl&, int, bool); void renderProcessTerminated(int terminationStatus, int exitCode); void scrollPositionChanged(const QPointF& position); void contentsSizeChanged(const QSizeF& size); void audioMutedChanged(bool muted); void recentlyAudibleChanged(bool recentlyAudible); public: WebView(QWidget* parent = 0); Q_PROPERTY(qreal zoom READ zoomFactor WRITE setZoomFactor); Q_PROPERTY(bool hasSelection READ hasSelection); Q_PROPERTY(QString selectedText READ selectedText); Q_PROPERTY(QString title READ title); Q_PROPERTY(bool overrideNavigation READ overrideNavigation WRITE setOverrideNavigation); bool overrideNavigation() const; void setOverrideNavigation(bool b); Q_PROPERTY(QString url READ url WRITE setUrl); QString url() const; void setUrl(const QString&); Q_PROPERTY(bool delegateReload READ delegateReload WRITE setDelegateReload); bool delegateReload() const; void setDelegateReload(bool); Q_PROPERTY(bool editable READ editable WRITE setEditable); bool editable() const { return _editable; } void setEditable(bool b); // QWebEnginePage properties Q_PROPERTY(QString requestedUrl READ requestedUrl) QString requestedUrl() const { return page() ? page()->requestedUrl().toString() : QString(); } Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) QColor backgroundColor() const { return page() ? page()->backgroundColor() : QColor(); } void setBackgroundColor(QColor c) { if (page()) page()->setBackgroundColor(c); } Q_PROPERTY(QSizeF contentsSize READ contentsSize) QSizeF contentsSize() const { return page() ? page()->contentsSize() : QSizeF(0, 0); } Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition) QPointF scrollPosition() const { return page() ? page()->scrollPosition() : QPointF(0, 0); } void setScrollPosition(QPointF p) { if (page()) page()->runJavaScript(QString("window.scrollTo(%1, %2);").arg(p.rx()).arg(p.ry())); } Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted) bool isAudioMuted() const { return page() ? page()->isAudioMuted() : false; } void setAudioMuted(bool m) { if (page()) page()->setAudioMuted(m); } Q_PROPERTY(bool recentlyAudible READ recentlyAudible) bool recentlyAudible() const { return page() ? page()->recentlyAudible() : false; } inline static QUrl urlFromString(const QString& str) { return QUrl::fromUserInput(str); } protected: void contextMenuEvent(QContextMenuEvent*) override; bool event(QEvent* ev) override; bool eventFilter(QObject* obj, QEvent* event) override; public Q_SLOTS: void onPageReload(); void onRenderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus, int); void onLinkClicked(const QUrl&, QWebEnginePage::NavigationType, bool); void pageLoaded(bool); private: void connectPage(QtCollider::WebPage* page); bool _editable; }; } // namespace QtCollider
5,872
C++
.h
126
42.34127
107
0.727336
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,003
QcFileDialog.h
supercollider_supercollider/QtCollider/widgets/QcFileDialog.h
/************************************************************************ * * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../Common.h" #include <QFileDialog> #include <QPointer> class QcFileDialog : public QObject { Q_OBJECT public: /** * \param fileMode What the user may select in the dialog * \param acceptMode Whether for opening or saving files * \param startDir What location the directory will open at */ Q_INVOKABLE QcFileDialog(int fileMode = QFileDialog::ExistingFile, int acceptMode = QFileDialog::AcceptOpen, const QString& startDir = QDir::home().path()); ~QcFileDialog() { if (dialog) { dialog->deleteLater(); }; } QFileDialog* theDialog() { return dialog; } Q_SIGNALS: void accepted(QVariantList result); void rejected(); private Q_SLOTS: void show() { dialog->exec(); dialog->deleteLater(); } void onFinished(int res) { if (res == QDialog::Accepted) { QStringList files = dialog->selectedFiles(); QVariantList varFiles; Q_FOREACH (QString f, files) { varFiles << QVariant(f); } Q_EMIT(accepted(varFiles)); } else { Q_EMIT(rejected()); } } private: QPointer<QFileDialog> dialog; };
2,175
C++
.h
63
28.936508
112
0.614102
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,004
BasicWidgets.h
supercollider_supercollider/QtCollider/widgets/BasicWidgets.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "QcCanvas.h" #include "QcMenu.h" #include "../layouts/classic_layouts.hpp" #include "image_painter.h" #include <QBackingStore> class QcSimpleWidget : public QWidget { Q_OBJECT Q_PROPERTY(QColor background READ background WRITE setBackground); Q_PROPERTY(QList<QAction*> actions READ actions()); Q_PROPERTY(float devicePixelRatio READ devicePixelRatio); public: const QColor& background() const { return _bkg; } void setBackground(const QColor& c); Q_INVOKABLE void setBackgroundImage(const QtCollider::SharedImage& image, const QRectF& rect, int tileMode, double opacity); Q_INVOKABLE void removeBackgroundImage() { _bkg_image.clear(); update(); } float devicePixelRatio() const { return backingStore()->window()->devicePixelRatio(); } Q_INVOKABLE void addAction(QAction* action) { QWidget::addAction(action); } Q_INVOKABLE void removeAction(QAction* action) { QWidget::removeAction(action); } Q_INVOKABLE void insertAction(QAction* before, QAction* action) { QWidget::insertAction(before, action); } protected: virtual void paintEvent(QPaintEvent*); private: QColor _bkg; QtCollider::ImagePainter _bkg_image; }; class QcDefaultWidget : public QcSimpleWidget { Q_OBJECT public: QcDefaultWidget(): l(this) {} protected: virtual void resizeEvent(QResizeEvent* e) { if (!layout()) l.resize(e); } QtCollider::DefaultLayout l; }; class QcHLayoutWidget : public QcSimpleWidget { Q_OBJECT public: QcHLayoutWidget(): l(this) {} protected: virtual void resizeEvent(QResizeEvent* e) { if (!layout()) l.resize(e); } QtCollider::HLayout l; }; class QcVLayoutWidget : public QcSimpleWidget { Q_OBJECT public: QcVLayoutWidget(): l(this) {} protected: virtual void resizeEvent(QResizeEvent* e) { if (!layout()) l.resize(e); } QtCollider::VLayout l; }; class QcCustomPainted : public QcCanvas { Q_OBJECT public: QcCustomPainted(): l(this) {} protected: // reimplement event handlers just so events don't propagate virtual void mousePressEvent(QMouseEvent*) {} virtual void mouseReleaseEvent(QMouseEvent*) {} virtual void mouseMoveEvent(QMouseEvent*) {} virtual void resizeEvent(QResizeEvent* e) { QcCanvas::resizeEvent(e); if (!layout()) l.resize(e); } QtCollider::DefaultLayout l; };
3,388
C++
.h
100
29.79
116
0.682569
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,005
QcListWidget.h
supercollider_supercollider/QtCollider/widgets/QcListWidget.h
/************************************************************************ * * Copyright 2010-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #include "../QcHelper.h" #include "../Common.h" #include <QListWidget> class QcListWidget : public QListWidget, QcHelper { Q_OBJECT Q_PROPERTY(QVariantList items READ dummyVariantList WRITE setItems); Q_PROPERTY(QVariantList colors READ dummyVariantList WRITE setColors); Q_PROPERTY(int currentRow READ currentRow WRITE setCurrentRowWithoutAction) Q_PROPERTY(QVariantList selection READ selection WRITE setSelection); public: QcListWidget(); void setItems(const QVariantList&); void setColors(const QVariantList&) const; void setCurrentRowWithoutAction(int); QVariantList selection() const; void setSelection(const QVariantList&); Q_SIGNALS: void action(); void returnPressed(); private Q_SLOTS: void onCurrentItemChanged(); protected: virtual void keyPressEvent(QKeyEvent*); private: bool _emitAction; };
1,788
C++
.h
46
35.934783
79
0.701613
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,006
QcScope.h
supercollider_supercollider/QtCollider/widgets/QcScope.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../QcHelper.h" #include <SC_Types.h> #include <SC_SndBuf.h> #include <QWidget> class QcScope : public QWidget, QcHelper { Q_OBJECT Q_PROPERTY(int bufferNumber READ dummyInt WRITE setBufferNumber); Q_PROPERTY(float xOffset READ dummyFloat WRITE setXOffset); Q_PROPERTY(float yOffset READ dummyFloat WRITE setYOffset); Q_PROPERTY(float xZoom READ dummyFloat WRITE setXZoom); Q_PROPERTY(float yZoom READ dummyFloat WRITE setYZoom); Q_PROPERTY(int style READ dummyInt WRITE setStyle); Q_PROPERTY(QVariantList waveColors READ dummyVariantList WRITE setWaveColors); Q_PROPERTY(QColor background READ background WRITE setBackground); Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval); public: QcScope(); ~QcScope(); void setBufferNumber(int); void setXOffset(float f) { xOffset = f; } void setYOffset(float f) { yOffset = f; } void setXZoom(float f) { xZoom = f; } void setYZoom(float f) { yZoom = f; } void setStyle(int i) { style = i; } void setWaveColors(const QVariantList& colors); QColor background() const { return _bkg; } void setBackground(const QColor& c) { _bkg = c; update(); } int updateInterval() const; void setUpdateInterval(int i); QSize sizeHint() const { return QSize(500, 300); } QSize minimumSizeHint() const { return QSize(50, 50); } private Q_SLOTS: void updateScope(); private: void paintEvent(QPaintEvent* event); void setPoint(QPointF& pt, float frame, float data, float xRatio, float yRatio, int xStart, int yStart); void paint1D(bool overlapped, QPainter&); void paint2D(QPainter&); int bufNum; SndBuf buffer; QTimer* timer; float xOffset; float yOffset; float xZoom; float yZoom; int style; QList<QColor> colors; QColor _bkg; };
2,794
C++
.h
73
34.438356
108
0.685588
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,007
QcLevelIndicator.h
supercollider_supercollider/QtCollider/widgets/QcLevelIndicator.h
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../QcHelper.h" #include "../style/style.hpp" #include <QWidget> #include <QTimer> class QcLevelIndicator : public QWidget, QcHelper, QtCollider::Style::Client { Q_OBJECT Q_PROPERTY(float value READ dummyFloat WRITE setValue); Q_PROPERTY(float warning READ dummyFloat WRITE setWarning); Q_PROPERTY(float critical READ dummyFloat WRITE setCritical); Q_PROPERTY(float peak READ dummyFloat WRITE setPeak); Q_PROPERTY(bool drawPeak READ dummyBool WRITE setDrawPeak); Q_PROPERTY(int ticks READ dummyInt WRITE setTicks); Q_PROPERTY(int majorTicks READ dummyInt WRITE setMajorTicks); Q_PROPERTY(int stepWidth READ dummyInt WRITE setStepWidth); Q_PROPERTY(LevelIndicatorStyle style READ style WRITE setStyle); Q_PROPERTY(QColor grooveColor READ grooveColor WRITE setGrooveColor); Q_PROPERTY(QColor meterColor READ dummyColor WRITE setMeterColor); Q_PROPERTY(QColor warningColor READ dummyColor WRITE setWarningColor); Q_PROPERTY(QColor criticalColor READ dummyColor WRITE setCriticalColor); public: enum LevelIndicatorStyle { Continuous = 0, LED }; Q_ENUMS(LevelIndicatorStyle); QcLevelIndicator(); void setValue(float f) { _value = f; update(); } void setWarning(float f) { _warning = f; update(); } void setCritical(float f) { _critical = f; update(); } void setPeak(float f) { _peak = f; update(); } void setDrawPeak(bool b) { _drawPeak = b; update(); } void setTicks(int i) { _ticks = qMax(i, 0); update(); } void setMajorTicks(int i) { _majorTicks = qMax(i, 0); update(); } void setStepWidth(int i) { _stepWidth = qMax(i, 1); update(); } void setStyle(LevelIndicatorStyle i) { _style = i; update(); } void setStyle(int i) { _style = (LevelIndicatorStyle)i; update(); } LevelIndicatorStyle style() { return _style; }; void setMeterColor(const QColor c) { _meterColor = c; update(); } void setWarningColor(const QColor c) { _warningColor = c; update(); } void setCriticalColor(const QColor c) { _criticalColor = c; update(); } virtual QSize sizeHint() const { return QSize(25, 150); } private Q_SLOTS: void clipTimeout(); private: const QColor valueColor(float value); void paintEvent(QPaintEvent* e); float _value; float _warning; float _critical; float _peak; bool _drawPeak; int _ticks; int _majorTicks; float _stepWidth; LevelIndicatorStyle _style; bool _clipped; QTimer* _clipTimer; QColor _meterColor, _warningColor, _criticalColor; };
3,723
C++
.h
116
26.991379
78
0.650083
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,008
view.hpp
supercollider_supercollider/QtCollider/widgets/soundfileview/view.hpp
/************************************************************************ * * Copyright 2010 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include "../../Common.h" #include "../../QcHelper.h" #include "SC_SndFileHelpers.hpp" #include <QVBoxLayout> #include <QScrollBar> #include <QSlider> #include <QPixmap> #include <QThread> class QcWaveform; class SoundCacheStream; struct SoundCache { SoundCache(): min(0), max(0), sum(0), sum2(0) {}; ~SoundCache() { delete[] min; delete[] max; delete[] sum; delete[] sum2; } float* min; float* max; float* sum; float* sum2; }; class QcWaveform : public QWidget, public QcHelper { Q_OBJECT Q_PROPERTY(float readProgress READ loadProgress); Q_PROPERTY(int startFrame READ startFrame); Q_PROPERTY(int frames READ frames); Q_PROPERTY(double viewFrames READ viewFrames); Q_PROPERTY(double viewStartFrame READ viewStartFrame WRITE scrollTo); Q_PROPERTY(float scrollPos READ scrollPos WRITE setScrollPos); Q_PROPERTY(int currentSelection READ currentSelection WRITE setCurrentSelection); Q_PROPERTY(QVariantList selections READ selections); Q_PROPERTY(float yZoom READ yZoom WRITE setYZoom); Q_PROPERTY(float xZoom READ xZoom WRITE setXZoom); Q_PROPERTY(float yOffset READ yOffset WRITE setYOffset); Q_PROPERTY(float spacing READ spacing WRITE setSpacing); Q_PROPERTY(bool cursorVisible READ cursorVisible WRITE setCursorVisible); Q_PROPERTY(bool cursorEditable READ cursorEditable WRITE setCursorEditable); Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition); Q_PROPERTY(bool gridVisible READ gridVisible WRITE setGridVisible); Q_PROPERTY(float gridOffset READ gridOffset WRITE setGridOffset); Q_PROPERTY(float gridResolution READ gridResolution WRITE setGridResolution); Q_PROPERTY(bool drawsWaveform READ drawsWaveform WRITE setDrawsWaveform); Q_PROPERTY(bool drawsRMS READ drawsRMS WRITE setDrawsRMS); // Q_PROPERTY( bool antialiasing READ antialiasing WRITE setAntialiasing ); //TODO: antialiasing doesn't look good // when enabled, would probably require reworking the waveform drawing mechanism? Q_PROPERTY(bool drawsCenterLine READ drawsCenterLine WRITE setDrawsCenterLine); Q_PROPERTY(bool drawsBoundingLines READ drawsBoundingLines WRITE setDrawsBoundingLines); Q_PROPERTY(QColor background READ background WRITE setBackground); Q_PROPERTY(QColor peakColor READ peakColor WRITE setPeakColor); Q_PROPERTY(QColor rmsColor READ rmsColor WRITE setRmsColor); Q_PROPERTY(QColor cursorColor READ cursorColor WRITE setCursorColor); Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor); public: Q_INVOKABLE void load(const QString& filename); // NOTE: Using int instead of sf_count_t for accessibility from SC language. Q_INVOKABLE void load(const QString& filename, int beginning, int duration); Q_INVOKABLE void load(const QVector<double>& data, int offset = 0, int channels = 1, int samplerate = 44100); Q_INVOKABLE void allocate(int frames, int channels = 1, int samplerate = 44100); Q_INVOKABLE void write(const QVector<double>& data, int offset); public: struct Selection { Selection(): start(0), size(0), editable(true), color(QColor(128, 128, 128, 192)) {} sf_count_t start; sf_count_t size; bool editable; QColor color; }; QcWaveform(QWidget* parent = 0); ~QcWaveform(); float loadProgress(); sf_count_t startFrame() { return _rangeBeg; } sf_count_t frames() { return _rangeDur; } double viewStartFrame() { return _beg; } double viewFrames() { return _dur; } float scrollPos(); // as fraction of scrolling range float zoom(); // visible fraction float xZoom(); // visible seconds float yZoom(); // factor float yOffset(); // normalized value (1 equals half helght) float spacing(); // factor for space otuside the ±1.0 value range QVariantList selections() const; int currentSelection() const { return _curSel; } void setCurrentSelection(int i); // for SC: selection start relative to first loaded frame Q_INVOKABLE QVariantList selection(int index) const; // for SC: selection start relative to first loaded frame Q_INVOKABLE void setSelection(int index, QVariantList data); void setSelection(int i, sf_count_t a, sf_count_t b); Q_INVOKABLE void setSelectionStart(int i, sf_count_t frame); Q_INVOKABLE void setSelectionEnd(int i, sf_count_t frame); Q_INVOKABLE void setSelectionEditable(int index, bool editable); Q_INVOKABLE void setSelectionColor(int index, const QColor& clr); Q_PROPERTY(QVariantList waveColors READ waveColors WRITE setWaveColors); bool cursorVisible() const { return _showCursor; } void setCursorVisible(bool b) { _showCursor = b; update(); } int cursorPosition() const { return _cursorPos; } void setCursorPosition(int pos) { _cursorPos = pos; update(); } bool cursorEditable() const { return _cursorEditable; } void setCursorEditable(bool b) { _cursorEditable = b; } bool gridVisible() const { return _showGrid; } void setGridVisible(bool b) { _showGrid = b; update(); } float gridOffset() const { return _gridOffset; } void setGridOffset(float f) { _gridOffset = f; update(); } float gridResolution() const { return _gridResolution; } void setGridResolution(float f) { _gridResolution = f; update(); } bool drawsWaveform() const { return _drawWaveform; } void setDrawsWaveform(bool b) { _drawWaveform = b; update(); } bool drawsRMS() const { return _drawRMS; } void setDrawsRMS(bool b) { _drawRMS = b; redraw(); } QVariantList waveColors() const; void setWaveColors(const QVariantList&); // bool antialiasing() const { return _antialiasing; } //TODO // void setAntialiasing( bool b ) { _antialiasing = b; redraw(); } bool drawsCenterLine() const { return _drawsCenterLine; } void setDrawsCenterLine(bool b) { _drawsCenterLine = b; redraw(); } bool drawsBoundingLines() const { return _drawsBoundingLines; } void setDrawsBoundingLines(bool b) { _drawsBoundingLines = b; redraw(); } const QColor& background() const { return _bkgColor; } void setBackground(const QColor& c) { if (_bkgColor == c) return; _bkgColor = c; setAttribute(Qt::WA_OpaquePaintEvent, c.isValid() && c.alpha() == 255); update(); } const QColor& peakColor() const { return _peakColor; } void setPeakColor(const QColor& clr) { _peakColor = clr; redraw(); } const QColor& rmsColor() const { return _rmsColor; } void setRmsColor(const QColor& clr) { _rmsColor = clr; redraw(); } const QColor& cursorColor() const { return _cursorColor; } void setCursorColor(const QColor& c) { _cursorColor = c; update(); } const QColor& gridColor() const { return _gridColor; } void setGridColor(const QColor& c) { _gridColor = c; update(); } QSize sizeHint() const { return QSize(400, 200); } QSize minimumSizeHint() const { return QSize(100, 20); } public Q_SLOTS: void zoomTo(double fraction); // void zoomTo( float fraction, quint64 frame ); void zoomBy(double factor); void zoomAllOut(); void zoomSelection(int selectionIndex); void scrollTo(double frame); void scrollBy(double frames); void setScrollPos(double fraction); // as fraction of scrolling range void scrollToStart(); void scrollToEnd(); void setYZoom(double factor); void setXZoom(double seconds); void setYOffset(double offset); void setSpacing(double factor); Q_SIGNALS: void loadProgress(int); void loadingDone(); void action(); void metaAction(); public Q_SLOTS: void redraw() { dirty = true; update(); } protected: virtual void resizeEvent(QResizeEvent*); virtual void paintEvent(QPaintEvent*); virtual void keyPressEvent(QKeyEvent*); virtual void mousePressEvent(QMouseEvent*); virtual void mouseDoubleClickEvent(QMouseEvent*); virtual void mouseMoveEvent(QMouseEvent*); private: /// \param allFrames If true, all frames are loaded and duration is ignored. void load(const QString& filename, int beginning, int duration, bool allFrames); void doLoad(SNDFILE* new_sf, const SF_INFO& new_info, sf_count_t beginning, sf_count_t duration); inline void updateFPP() { _fpp = width() ? (double)_dur / width() : 0.0; } void rebuildCache(int maxFramesPerCache, int maxRawFrames); void draw(QPixmap*, int x, int width, double beginning, double duration); // data SNDFILE* sf; SF_INFO sfInfo; sf_count_t _rangeBeg; sf_count_t _rangeDur; sf_count_t _rangeEnd; SoundCacheStream* _cache; // selections Selection _selections[64]; int _curSel; // cursor bool _showCursor; sf_count_t _cursorPos; bool _cursorEditable; // grid bool _showGrid; float _gridResolution; float _gridOffset; // view double _beg; double _dur; double _fpp; float _yZoom; float _yOffset; float _spacing; // painting QPixmap* pixmap; QColor _bkgColor; QColor _peakColor; QColor _rmsColor; QColor _cursorColor; QColor _gridColor; bool dirty; bool _drawWaveform; bool _drawRMS; // bool _antialiasing; //TODO bool _drawsCenterLine; bool _drawsBoundingLines; // at the values of ±1.0 QList<QColor> _waveColors; // interaction enum DragAction { NoDragAction, Navigate, Select, MoveSelection, MoveCursor }; DragAction _dragAction; QPointF _dragPoint; sf_count_t _dragFrame; double _dragData; double _dragData2; // display tweaks int _rmsMaxFpp = 128; // when frames-per-pixel drops below this value (zoom in), the RMS waveform starts to fade // out, as its calculation becomes less precise int _rmsMinFpp = 32; // when frames-per-pixel drops below this value, RMS waveform disapperas completely }; class SoundStream { public: inline int channels() { return _ch; } inline sf_count_t beginning() { return _beg; } inline sf_count_t duration() { return _dur; } virtual bool displayData(int channel, double offset, double duration, float* minBuffer, float* maxBuffer, float* minRMS, float* maxRMS, int bufferSize) = 0; virtual float* rawFrames(int channel, sf_count_t beginning, sf_count_t duration, bool* interleaved) = 0; protected: SoundStream(): _ch(0), _beg(0), _dur(0) {} SoundStream(int channels, sf_count_t beginning, sf_count_t duration): _ch(channels), _beg(beginning), _dur(duration) {} int _ch; sf_count_t _beg; sf_count_t _dur; }; class SoundFileStream : public SoundStream { public: SoundFileStream(); SoundFileStream(SNDFILE* sf, const SF_INFO& sf_info, sf_count_t beginning, sf_count_t duration); ~SoundFileStream(); void load(SNDFILE* sf, const SF_INFO& sf_info, sf_count_t beginning, sf_count_t duration); bool integrate(int channel, double offset, double duration, float* minBuffer, float* maxBuffer, float* sumBuffer, float* sum2Buffer, int bufferSize); bool displayData(int channel, double offset, double duration, float* minBuffer, float* maxBuffer, float* minRMS, float* maxRMS, int bufferSize); float* rawFrames(int channel, sf_count_t beginning, sf_count_t duration, bool* interleaved); private: float* _data; sf_count_t _dataSize; sf_count_t _dataOffset; }; class SoundCacheLoader; class SoundCacheStream : public QObject, public SoundStream { friend class SoundCacheLoader; Q_OBJECT public: SoundCacheStream(); ~SoundCacheStream(); void load(const QVector<double>& data, int frames, int offset, int channels); void load(SNDFILE* sf, const SF_INFO& info, sf_count_t beg, sf_count_t dur, int maxFramesPerUnit, int maxRawFrames); void allocate(int frames, int channels); void write(const QVector<double>& data, int offset, int count); inline double fpu() { return _fpu; } inline bool ready() { return _ready; } inline bool loading() { return _loading; } inline int loadProgress() { return _loadProgress; } bool displayData(int channel, double offset, double duration, float* minBuffer, float* maxBuffer, float* minRMS, float* maxRMS, int bufferSize); float* rawFrames(int channel, sf_count_t beginning, sf_count_t duration, bool* interleaved); Q_SIGNALS: void loadProgress(int); void loadingDone(); private Q_SLOTS: void onLoadProgress(int); void onLoadingDone(); private: SoundCache* _caches; double _fpu; // soundfile frames per cache unit sf_count_t _dataOffset; // offset into soundfile of first frame cached (in frames) sf_count_t _dataSize; // amount of cache units bool _ready; bool _loading; SoundCacheLoader* _loader; int _loadProgress; }; class SoundCacheLoader : public QThread { Q_OBJECT public: SoundCacheLoader(SoundCacheStream* cache): QThread(cache), _cache(cache), _sf(0) {} void load(SNDFILE* sf, const SF_INFO& info); Q_SIGNALS: void loadProgress(int); void loadingDone(); private: void run(); SoundCacheStream* _cache; SNDFILE* _sf; SF_INFO _info; };
14,520
C++
.h
369
34.02981
120
0.689861
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
34,009
hacks_qt.hpp
supercollider_supercollider/QtCollider/hacks/hacks_qt.hpp
/************************************************************************ * * Copyright 2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #include <QtGlobal> #if QT_VERSION >= 0x040800 # define QURL_IS_LOCAL_FILE(url) url.isLocalFile() #else # define QURL_IS_LOCAL_FILE(url) url.scheme() == QString("file") #endif
1,091
C++
.h
26
40.153846
74
0.645343
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
34,010
hacks_x11.hpp
supercollider_supercollider/QtCollider/hacks/hacks_x11.hpp
/************************************************************************ * * Copyright 2011 Tim Blechmann (tim@klingt.org) * Copyright 2011 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QtGlobal> #ifdef Q_WS_X11 # include <QWidget> # include <QX11Info> bool raise_window(Display* display, QWidget* window); #endif
1,119
C++
.h
28
38.035714
74
0.654378
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
34,011
hacks_mac.hpp
supercollider_supercollider/QtCollider/hacks/hacks_mac.hpp
/************************************************************************ * * Copyright 2011-2012 Jakob Leben (jakob.leben@gmail.com) * * This file is part of SuperCollider Qt GUI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #pragma once #include <QWidget> namespace QtCollider { namespace Mac { bool IsCmdPeriodKeyUp(void* event); bool IsCmdPeriodKeyDown(void* event); bool isKeyWindow(QWidget* w); bool AlwaysShowScrollbars(); void activateApp(); void DisableAutomaticWindowTabbing(); } // namespace Mac } // namespace QtCollider
1,224
C++
.h
31
37.709677
74
0.678451
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
34,012
routines.hpp
supercollider_supercollider/QtCollider/style/routines.hpp
#pragma once #include <QPainter> #include <QPalette> namespace QtCollider { namespace Style { #if 0 namespace ReliefType { struct Hover; struct Raised; struct Flat; struct Sunken; }; using namespace ReliefType; namespace ShapeType { struct Rect; struct RoundRect; struct LeftRoundRect; struct RightRoundRect; struct TopRoundRect; struct BottomRoundRect; struct Ellipse; }; using namespace ShapeType; // drawShape // template<typename Shape> void drawShape( QPainter *, const QRect & ); template<typename Shape> void drawShape( QPainter *, const QRect &, qreal param1 ); template<> void drawShape <Rect> ( QPainter *p, const QRect &r ) { p->drawRect(r); } template<> void drawShape <Ellipse> ( QPainter *p, const QRect &r ) { p->drawEllipse(r); } template<> void drawShape <RoundRect> ( QPainter *p, const QRect &r, qreal radius ) { p->drawRoundedRect( r, radius, radius, Qt::RelativeSize ); } // drawReliefShape // template<typename ShapeT> struct Shape { template<typename RectT> void draw(); }; #endif struct Rect { Rect(QRectF rect): _rect(rect) {} template <typename RectT> inline void draw(QPainter* p, const RectT& r) const { p->drawRect(r); } QRectF _rect; }; struct RoundRect { RoundRect(QRectF rect, qreal radius): _rect(rect), _radius(radius) {} template <typename RectT> inline void draw(QPainter* p, const RectT& r) const { p->drawRoundedRect(r, _radius, _radius, Qt::AbsoluteSize); } QRectF _rect; qreal _radius; }; struct Ellipse { Ellipse(QRectF rect): _rect(rect) {} template <typename RectT> inline void draw(QPainter* p, const RectT& r) const { p->drawEllipse(r); } QRectF _rect; }; template <typename ShapeT> void drawRaised(QPainter* p, const QPalette& plt, const ShapeT& shape, const QColor& color, const QColor& focusColor = QColor()) { p->save(); bool focus = focusColor.isValid(); QRectF r(shape._rect); p->setBrush(Qt::NoBrush); // focus indication QPen pen; pen.setWidth(2); if (focus) { pen.setColor(focusColor); p->setPen(pen); shape.draw(p, r.adjusted(1, 1, -1, -1)); r.adjust(2, 2, -2, -2); } else { r.adjust(1, 1, -1, -1); } // edge QColor edgeClr(focus ? plt.color(QPalette::Light) : plt.color(QPalette::Dark)); if (focus) edgeClr.setAlpha(100); else edgeClr.setAlpha(color.alpha()); pen.setColor(edgeClr); p->setPen(pen); shape.draw(p, r); // center double pos = shape._rect.height(); pos = (pos - 3) / pos; QLinearGradient lgrad(shape._rect.topLeft(), shape._rect.bottomLeft()); lgrad.setColorAt(0, color.lighter(110)); lgrad.setColorAt(pos, color.darker(105)); lgrad.setColorAt(1, color.darker(115)); p->setPen(Qt::NoPen); p->setBrush(QBrush(lgrad)); shape.draw(p, r); p->restore(); } template <typename ShapeT> void drawSunken(QPainter* p, const QPalette& plt, const ShapeT& shape, const QColor& color, const QColor& focusColor = QColor()) { p->save(); QPen pen; pen.setWidth(2); // outer border QColor c = focusColor.isValid() ? focusColor : QColor(255, 255, 255, 20); pen.setColor(c); p->setPen(pen); p->setBrush(Qt::NoBrush); shape.draw(p, shape._rect.adjusted(1, 1, -1, -1)); // inner border QColor c1(plt.color(QPalette::Shadow)); c1.setAlpha(180); pen.setColor(c1); p->setPen(pen); p->setBrush(Qt::NoBrush); shape.draw(p, shape._rect.adjusted(2, 2, -2, -2)); // shadow QColor c2 = color; c2.setAlpha(color.alpha() * 0.5); p->setPen(Qt::NoPen); p->setBrush(c2); shape.draw(p, shape._rect.adjusted(2, 2, -2, -2)); // background p->setBrush(color); shape.draw(p, shape._rect.adjusted(2, 3, -2, -2)); p->restore(); } template <typename RectT> RectT sunkenContentsRect(const RectT& r) { return r.adjusted(1, 1, -1, -1); } template <typename RectT> qreal xValue(qreal x, const RectT& bounds) { return (x - bounds.x()) / bounds.width(); } template <typename RectT> qreal yValue(qreal y, const RectT& bounds) { return (bounds.y() + bounds.height() - y) / bounds.height(); } template <typename RectT, typename SizeT> qreal xValue(qreal x, const RectT& bounds, const SizeT& margin) { return margin.width() < bounds.width() ? (x - bounds.x() - (margin.width() * 0.5)) / (bounds.width() - margin.width()) : 0.0; } template <typename RectT, typename SizeT> qreal yValue(qreal y, const RectT& bounds, const SizeT& margin) { return margin.height() < bounds.height() ? (bounds.y() + bounds.height() - y - (margin.height() * 0.5)) / (bounds.height() - margin.height()) : 0.0; } template <typename RectT, typename PointT> QPointF value(const PointT& pos, const RectT& bounds) { return QPointF(xValue(pos.x(), bounds), yValue(pos.y(), bounds)); } template <typename RectT, typename SizeT, typename PointT> QPointF value(const PointT& pos, const RectT& bounds, const SizeT& margin) { return QPointF(xValue(pos.x(), bounds, margin), yValue(pos.y(), bounds, margin)); } template <typename RectT, typename SizeT> RectT marginsRect(const RectT& bounds, const SizeT& margin) { RectT r; r.setSize(SizeT(qMax((qreal)bounds.width() - margin.width(), qreal(0.0)), qMax((qreal)bounds.height() - margin.height(), qreal(0.0)))); r.moveCenter(bounds.center()); return r; } template <typename RectT, typename SizeT> RectT rect(const QPointF& value, const RectT& bounds, const SizeT& size) { qreal x = value.x() * (bounds.width() - size.width()) + bounds.left(); qreal y = bounds.top() + bounds.height() - size.height() - value.y() * (bounds.height() - size.height()); return RectT(x, y, size.width(), size.height()); } template <typename RectT, typename SizeT> QPointF pos(const QPointF& value, const RectT& bounds, const SizeT& margin) { qreal x = value.x() * (bounds.width() - margin.width()) + bounds.left() + margin.x() * 0.5; qreal y = -value.y() * (bounds.height() - margin.height()) + bounds.top() + bounds.height() - margin.y() * 0.5; return QPointF(x, y); } template <typename RectT> QPointF pos(const QPointF& value, const RectT& bounds) { qreal x = value.x() * bounds.width() + bounds.left(); qreal y = -value.y() * bounds.height() + bounds.top() + bounds.height(); return QPointF(x, y); } } // namespace QtCollider } // namespace Style
6,517
C++
.h
181
31.906077
119
0.660143
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
34,013
style.hpp
supercollider_supercollider/QtCollider/style/style.hpp
#pragma once #include "ProxyStyle.hpp" #include "routines.hpp" #include <QStyleOptionComplex> class QcSlider; namespace QtCollider { namespace Style { enum ColorRole { Focus = 0, Groove, ColorRoleCount }; class StyleImpl : public ProxyStyle { Q_OBJECT public: StyleImpl(QStyle* s = 0): ProxyStyle(s) {} virtual void polish(QPalette&); QColor color(ColorRole role) { Q_ASSERT(role < ColorRoleCount); return _colors[role]; } private: QColor _colors[ColorRoleCount]; }; struct Client { Client(QWidget* w): _widget(w) {} QColor focusColor() const { return color(Focus); } void setFocusColor(const QColor& c) { setColor(Focus, c); } QColor grooveColor() const { return color(Groove); } void setGrooveColor(const QColor& c) { setColor(Groove, c); } QColor color(ColorRole role) const { Q_ASSERT(role < ColorRoleCount); QColor c(_colors[role]); if (c.isValid()) return c; else { StyleImpl* style = qobject_cast<StyleImpl*>(_widget->style()); return style ? style->color(role) : QColor(); } } void setColor(ColorRole role, const QColor& color) { Q_ASSERT(role < ColorRoleCount); _colors[role] = color; _widget->update(); } private: QColor _colors[ColorRoleCount]; QWidget* _widget; }; } // namespace QtCollider } // namespace Style
1,438
C++
.h
50
23.48
74
0.649635
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
34,014
ProxyStyle.hpp
supercollider_supercollider/QtCollider/style/ProxyStyle.hpp
#pragma once #include <QProxyStyle> namespace QtCollider { class ProxyStyle : public QProxyStyle { public: ProxyStyle(QStyle* style = 0): QProxyStyle(style) {} virtual void drawComplexControl(ComplexControl, const QStyleOptionComplex*, QPainter*, const QWidget* w = 0) const; virtual int styleHint(StyleHint, const QStyleOption* = 0, const QWidget* = 0, QStyleHintReturn* = 0) const; }; } // namespace QtCollider
431
C++
.h
10
40.3
119
0.763855
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
34,015
FFT_UGens.h
supercollider_supercollider/include/plugin_interface/FFT_UGens.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_PlugIn.h" #include "SCComplex.h" #include <string.h> struct SCComplexBuf { float dc, nyq; SCComplex bin[1]; }; struct SCPolarBuf { float dc, nyq; SCPolar bin[1]; }; static inline SCPolarBuf* ToPolarApx(SndBuf* buf) { if (buf->coord == coord_Complex) { SCComplexBuf* p = (SCComplexBuf*)buf->data; int numbins = (buf->samples - 2) >> 1; for (int i = 0; i < numbins; ++i) { p->bin[i].ToPolarApxInPlace(); } buf->coord = coord_Polar; } return (SCPolarBuf*)buf->data; } static inline SCComplexBuf* ToComplexApx(SndBuf* buf) { if (buf->coord == coord_Polar) { SCPolarBuf* p = (SCPolarBuf*)buf->data; int numbins = (buf->samples - 2) >> 1; for (int i = 0; i < numbins; ++i) { p->bin[i].ToComplexApxInPlace(); } buf->coord = coord_Complex; } return (SCComplexBuf*)buf->data; } struct PV_Unit : Unit {}; // Ordinary ClearUnitOutputs outputs zero, potentially telling the IFFT (+ PV UGens) to act on buffer zero, so let's // skip that: static inline void FFT_ClearUnitOutputs(Unit* unit, int wrongNumSamples) { ZOUT0(0) = -1; } #define ClearFFTUnitIfMemFailed(condition) \ if (!(condition)) { \ Print("%s: alloc failed, increase server's RT memory (e.g. via ServerOptions)\n", __func__); \ SETCALC(FFT_ClearUnitOutputs); \ unit->mDone = true; \ return; \ } #define sc_clipbuf(x, hi) ((x) >= (hi) ? 0 : ((x) < 0 ? 0 : (x))) // for operation on one buffer #define PV_GET_BUF \ float fbufnum = ZIN0(0); \ if (fbufnum < 0.f) { \ ZOUT0(0) = -1.f; \ return; \ } \ ZOUT0(0) = fbufnum; \ uint32 ibufnum = (uint32)fbufnum; \ World* world = unit->mWorld; \ SndBuf* buf; \ if (ibufnum >= world->mNumSndBufs) { \ int localBufNum = ibufnum - world->mNumSndBufs; \ Graph* parent = unit->mParent; \ if (localBufNum <= parent->localBufNum) { \ buf = parent->mLocalSndBufs + localBufNum; \ } else { \ buf = world->mSndBufs; \ } \ } else { \ buf = world->mSndBufs + ibufnum; \ } \ LOCK_SNDBUF(buf); \ int numbins = (buf->samples - 2) >> 1; // for operation on two input buffers, result goes in first one. #define PV_GET_BUF2 \ float fbufnum1 = ZIN0(0); \ float fbufnum2 = ZIN0(1); \ if (fbufnum1 < 0.f || fbufnum2 < 0.f) { \ ZOUT0(0) = -1.f; \ return; \ } \ ZOUT0(0) = fbufnum1; \ uint32 ibufnum1 = (int)fbufnum1; \ uint32 ibufnum2 = (int)fbufnum2; \ World* world = unit->mWorld; \ SndBuf* buf1; \ SndBuf* buf2; \ if (ibufnum1 >= world->mNumSndBufs) { \ int localBufNum = ibufnum1 - world->mNumSndBufs; \ Graph* parent = unit->mParent; \ if (localBufNum <= parent->localBufNum) { \ buf1 = parent->mLocalSndBufs + localBufNum; \ } else { \ buf1 = world->mSndBufs; \ } \ } else { \ buf1 = world->mSndBufs + ibufnum1; \ } \ if (ibufnum2 >= world->mNumSndBufs) { \ int localBufNum = ibufnum2 - world->mNumSndBufs; \ Graph* parent = unit->mParent; \ if (localBufNum <= parent->localBufNum) { \ buf2 = parent->mLocalSndBufs + localBufNum; \ } else { \ buf2 = world->mSndBufs; \ } \ } else { \ buf2 = world->mSndBufs + ibufnum2; \ } \ LOCK_SNDBUF2(buf1, buf2); \ if (buf1->samples != buf2->samples) \ return; \ int numbins = (buf1->samples - 2) >> 1; #define MAKE_TEMP_BUF \ if (!unit->m_tempbuf) { \ unit->m_tempbuf = (float*)RTAlloc(unit->mWorld, buf->samples * sizeof(float)); \ unit->m_numbins = numbins; \ } else if (numbins != unit->m_numbins) \ return; extern InterfaceTable* ft;
10,967
C++
.h
133
76.406015
120
0.258276
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,016
SC_Wire.h
supercollider_supercollider/include/plugin_interface/SC_Wire.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Types.h" struct Wire { struct Unit* mFromUnit; int32 mCalcRate; float32* mBuffer; float32 mScalarValue; }; typedef struct Wire Wire;
1,052
C++
.h
25
37.92
81
0.755882
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,017
SC_Graph.h
supercollider_supercollider/include/plugin_interface/SC_Graph.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Node.h" #include "SC_Rate.h" #include "SC_SndBuf.h" /* changes to this struct likely also mean that a change is needed for static const int sc_api_version = x; value in SC_InterfaceTable.h file. */ struct Graph { Node mNode; uint32 mNumWires; struct Wire* mWire; uint32 mNumControls; float* mControls; float** mMapControls; int32* mAudioBusOffsets; // try this for setting the rate of a control int* mControlRates; uint32 mNumUnits; struct Unit** mUnits; uint32 mNumCalcUnits; struct Unit** mCalcUnits; // excludes i-rate units. int mSampleOffset; struct RGen* mRGen; struct Unit* mLocalAudioBusUnit; struct Unit* mLocalControlBusUnit; float mSubsampleOffset; SndBuf* mLocalSndBufs; int localBufNum; int localMaxBufNum; void* mPrivate; }; typedef struct Graph Graph;
1,774
C++
.h
50
31.14
81
0.741218
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,018
SC_Rate.h
supercollider_supercollider/include/plugin_interface/SC_Rate.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once enum { calc_ScalarRate, calc_BufRate, calc_FullRate, calc_DemandRate }; struct Rate { double mSampleRate; // samples per second double mSampleDur; // seconds per sample double mBufDuration; // seconds per buffer double mBufRate; // buffers per second double mSlopeFactor; // 1. / NumSamples double mRadiansPerSample; // 2pi / SampleRate int mBufLength; // length of the buffer // second order filter loops are often unrolled by 3 int mFilterLoops, mFilterRemain; double mFilterSlope; }; typedef struct Rate Rate;
1,443
C++
.h
31
42.225806
81
0.751601
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,019
SC_PlugIn.hpp
supercollider_supercollider/include/plugin_interface/SC_PlugIn.hpp
/* * SuperCollider real time audio synthesis system * Copyright (c) 2002 James McCartney. All rights reserved. * Copyright (c) 2011 Tim Blechmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <cassert> #include "SC_PlugIn.h" #include "function_attributes.h" #include <type_traits> /// c++ wrapper for Unit struct class SCUnit : public Unit { public: ///@{ /// generic signal wrappers template <typename FloatType> struct ScalarSignal { explicit ScalarSignal(FloatType value): value(value) {} FloatType consume() const { return value; } FloatType value; }; template <typename FloatType> struct SlopeSignal { SlopeSignal(FloatType value, FloatType slope): value(value), slope(slope) {} FloatType consume() { FloatType ret = value; value += slope; return ret; } FloatType value, slope; }; template <typename FloatType> struct AudioSignal { explicit AudioSignal(const FloatType* pointer): pointer(pointer) {} FloatType consume() { return *pointer++; } const FloatType* pointer; }; template <typename FloatType> inline ScalarSignal<FloatType> makeScalar(FloatType value) const { return ScalarSignal<FloatType>(value); } template <typename FloatType> inline SlopeSignal<FloatType> makeSlope(FloatType next, FloatType last) const { return SlopeSignal<FloatType>(last, calcSlope(next, last)); } inline AudioSignal<float> makeSignal(int index) const { const float* input = in(index); return AudioSignal<float>(input); } ///@} /// get input signal at index const float* in(int index) const { assert(uint32(index) < mNumInputs); const Unit* unit = this; return IN(index); } /// get input signal at index (to be used with ZXP) const float* zin(int index) const { assert(uint32(index) < mNumInputs); const Unit* unit = this; return ZIN(index); } /// get first sample of input signal float in0(int index) const { assert(uint32(index) < mNumInputs); const Unit* unit = this; return IN0(index); } /// get output signal at index float* out(int index) const { assert(uint32(index) < mNumOutputs); const Unit* unit = this; return OUT(index); } /// get output signal at index (to be used with ZXP) float* zout(int index) const { assert(uint32(index) < mNumOutputs); const Unit* unit = this; return ZOUT(index); } /// get reference to first sample of output signal float& out0(int index) const { assert(uint32(index) < mNumOutputs); const Unit* unit = this; return OUT0(index); } /// get rate of input signal int inRate(int index) const { assert(uint32(index) < mNumInputs); const Unit* unit = this; return INRATE(index); } /// get number of inputs int numInputs() const { return int(mNumInputs); } /// get number of outputs int numOutputs() const { return int(mNumOutputs); } /// test if input signal at index is scalar rate bool isScalarRateIn(int index) const { assert(uint32(index) < mNumInputs); return inRate(index) == calc_ScalarRate; } /// test if input signal at index is demand rate bool isDemandRateIn(int index) const { assert(uint32(index) < mNumInputs); return inRate(index) == calc_DemandRate; } /// test if input signal at index is control rate bool isControlRateIn(int index) const { assert(uint32(index) < mNumInputs); return inRate(index) == calc_BufRate; } /// test if input signal at index is audio rate bool isAudioRateIn(int index) const { assert(uint32(index) < mNumInputs); return inRate(index) == calc_FullRate; } /// get the blocksize of the input int inBufferSize(int index) const { assert(uint32(index) < mNumInputs); const Unit* unit = this; return INBUFLENGTH(index); } /// get sample rate of ugen double sampleRate() const { const Unit* unit = this; return SAMPLERATE; } /// get sample duration double sampleDur() const { const Unit* unit = this; return SAMPLEDUR; } /// get buffer size of ugen int bufferSize() const { return mBufLength; } /// get control rate double controlRate() const { const Unit* unit = this; return BUFRATE; } /// get duration of a control block double controlDur() const { const Unit* unit = this; return BUFDUR; } /// get sampling rate of audio signal double fullSampleRate() const { const Unit* unit = this; return FULLRATE; } /// get buffer size of audio signals int fullBufferSize() const { const Unit* unit = this; return FULLBUFLENGTH; } /// calculate slope value template <typename FloatType> FloatType calcSlope(FloatType next, FloatType prev) const { const Unit* unit = this; return CALCSLOPE(next, prev); } template <typename UnitType, void (UnitType::*PointerToMember)(int)> static UnitCalcFunc make_calc_function(void) { return &run_member_function<UnitType, PointerToMember>; } /// set calc function & compute initial sample template <typename UnitType, void (UnitType::*PointerToMember)(int)> void set_calc_function(void) { mCalcFunc = make_calc_function<UnitType, PointerToMember>(); (mCalcFunc)(this, 1); } /// set calc function & compute initial sample template <typename UnitType, void (UnitType::*VectorCalcFunc)(int), void (UnitType::*ScalarCalcFunc)(int)> void set_vector_calc_function(void) { mCalcFunc = make_calc_function<UnitType, VectorCalcFunc>(); make_calc_function<UnitType, ScalarCalcFunc>()(this, 1); } /// @} private: template <typename UnitType, void (UnitType::*PointerToMember)(int)> HOT static void run_member_function(struct Unit* unit, int inNumSamples) { UnitType* realUnit = static_cast<UnitType*>(unit); ((realUnit)->*(PointerToMember))(inNumSamples); } }; /// define Ctor/Dtor functions for a class #define DEFINE_XTORS(CLASSNAME) \ void CLASSNAME##_Ctor(CLASSNAME* unit) { new (unit) CLASSNAME(); } \ \ void CLASSNAME##_Dtor(CLASSNAME* unit) { unit->~CLASSNAME(); } namespace detail { template <class UGenClass> void constructClass(Unit* unit) { new (static_cast<UGenClass*>(unit)) UGenClass(); } template <class UGenClass> void destroyClass(Unit* unit) { static_cast<UGenClass*>(unit)->~UGenClass(); } } template <class Unit> void registerUnit(InterfaceTable* ft, const char* name, bool disableBufferAliasing = false) { UnitCtorFunc ctor = detail::constructClass<Unit>; UnitDtorFunc dtor = std::is_trivially_destructible<Unit>::value ? nullptr : detail::destroyClass<Unit>; (*ft->fDefineUnit)(name, sizeof(Unit), ctor, dtor, uint32(disableBufferAliasing ? 1 : 0)); }
8,150
C++
.h
204
33.357843
120
0.643074
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
true
true
true
false
34,020
SC_BelaScope.h
supercollider_supercollider/include/plugin_interface/SC_BelaScope.h
#pragma once #include "libraries/Scope/Scope.h" #include <string.h> class BelaScope { public: BelaScope(uint32_t maxChannels_, float sampleRate, uint32_t blockSize): scope(), maxChannels(maxChannels_), bufferSamples(maxChannels_ * blockSize) { scope.setup(maxChannels, sampleRate); buffer = new float[bufferSamples](); } ~BelaScope() { delete[] buffer; } void logBuffer() { if (touched) { float* data = buffer; for (unsigned int frame = 0; frame < bufferSamples; frame += maxChannels) { scope.log(data); data += maxChannels; } memset(buffer, 0, bufferSamples * sizeof(float)); touched = false; } } float* buffer; uint32_t maxChannels; uint32_t bufferSamples; bool touched; private: Scope scope; };
891
C++
.h
31
21.516129
87
0.59883
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,021
SC_RGen.h
supercollider_supercollider/include/plugin_interface/SC_RGen.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ //----------------------------------------------------------------------------// // Ran088: L'Ecuyer's 1996 three-component Tausworthe generator "taus88" //----------------------------------------------------------------------------// // // Returns an integer random number uniformly distributed within [0,4294967295] // // The period length is approximately 2^88 (which is 3*10^26). // This generator is very fast and passes all standard statistical tests. // // Reference: // (1) P. L'Ecuyer, Maximally equidistributed combined Tausworthe generators, // Mathematics of Computation, 65, 203-213 (1996), see Figure 4. // (2) recommended in: // P. L'Ecuyer, Random number generation, chapter 4 of the // Handbook on Simulation, Ed. Jerry Banks, Wiley, 1997. // //----------------------------------------------------------------------------// //----------------------------------------------------------------------------// // I chose this random number generator for the following reasons: // fast. // easier and faster to seed than other high quality rng's such as Mersenne Twister. // the internal state is only 12 bytes. // the period is long enough for music/audio. // possible to code in altivec in future if needed. // - James McCartney //----------------------------------------------------------------------------// #pragma once #include "SC_Endian.h" #include "SC_Types.h" #include "SC_BoundsMacros.h" #include "Hash.h" #include <math.h> struct RGen { void init(uint32 seed); uint32 trand(); int32 irand(int32 scale); int32 irand2(int32 scale); int32 ilinrand(int32 scale); int32 ibilinrand(int32 scale); float fcoin(); float frand(); float frand2(); float frand0(); float frand8(); float flinrand(); float fbilinrand(); float fsum3rand(); double drand(); double drand2(double scale); double linrand(double scale); double bilinrand(double scale); double exprandrng(double lo, double hi); double exprand(double scale); double biexprand(double scale); double sum3rand(double scale); uint32 s1, s2, s3; // random generator state }; inline void RGen::init(uint32 seed) { // humans tend to use small seeds - mess up the bits seed = (uint32)Hash((int)seed); // initialize seeds using the given seed value taking care of // the requirements. The constants below are arbitrary otherwise s1 = 1243598713U ^ seed; if (s1 < 2) s1 = 1243598713U; s2 = 3093459404U ^ seed; if (s2 < 8) s2 = 3093459404U; s3 = 1821928721U ^ seed; if (s3 < 16) s3 = 1821928721U; } /** * This function is provided for speed in inner loops where the * state variables are loaded into registers. * Thus updating the instance variables can * be postponed until the end of the loop. */ inline uint32 trand(uint32& s1, uint32& s2, uint32& s3) { s1 = ((s1 & (uint32)-2) << 12) ^ (((s1 << 13) ^ s1) >> 19); s2 = ((s2 & (uint32)-8) << 4) ^ (((s2 << 2) ^ s2) >> 25); s3 = ((s3 & (uint32)-16) << 17) ^ (((s3 << 3) ^ s3) >> 11); return s1 ^ s2 ^ s3; } /// Generate a random 32 bit number inline uint32 RGen::trand() { return ::trand(s1, s2, s3); } /// Generate a double from 0.0 to 0.999... inline double RGen::drand() { #if BYTE_ORDER == BIG_ENDIAN union { struct { uint32 hi, lo; } i; double f; } du; #else union { struct { uint32 lo, hi; } i; double f; } du; #endif du.i.hi = 0x41300000; du.i.lo = trand(); return du.f - 1048576.; } /// Generate a float from 0.0 to 0.999... inline float RGen::frand() { union { uint32 i; float f; } u; // union for floating point conversion of result u.i = 0x3F800000 | (trand() >> 9); return u.f - 1.f; } /// Generate a float from +1.0 to +1.999... inline float RGen::frand0() { union { uint32 i; float f; } u; // union for floating point conversion of result u.i = 0x3F800000 | (trand() >> 9); return u.f; } /// Generate a float from -1.0 to +0.999... inline float RGen::frand2() { union { uint32 i; float f; } u; // union for floating point conversion of result u.i = 0x40000000 | (trand() >> 9); return u.f - 3.f; } /// Generate a float from -0.125 to +0.124999... inline float RGen::frand8() { union { uint32 i; float f; } u; // union for floating point conversion of result u.i = 0x3E800000 | (trand() >> 9); return u.f - 0.375f; } /// Generate one of the two float values -1.0 or +1.0 inline float RGen::fcoin() { union { uint32 i; float f; } u; // union for floating point conversion of result u.i = 0x3F800000 | (0x80000000 & trand()); return u.f; } /// Generates a single random float value in linear distribution from 0.0 to 0.999 inline float RGen::flinrand() { float a = frand(); float b = frand(); return sc_min(a, b); } /// Bilateral linearly distributed random float from -0.999 to +0.999. inline float RGen::fbilinrand() { float a = frand(); float b = frand(); return a - b; } /** * Generates a random float that is the * result of summing three uniform random generators to yield a * bell-like distribution. * * Larry Polansky's loose approximation of a gaussian generator. */ inline float RGen::fsum3rand() { return (float)((frand() + frand() + frand() - 1.5) * 0.666666667); } /// Generate 32 bit integer from 0 to scale - 1 inline int32 RGen::irand(int32 scale) { return (int32)floor(scale * drand()); } /// Generate a 32 bit integer from -scale to +scale inline int32 RGen::irand2(int32 scale) { return (int32)floor((2. * scale + 1.) * drand() - scale); } /// Generates a single random 32 bit integer value in linear distribution from 0 to +scale inline int32 RGen::ilinrand(int32 scale) { int32 a = irand(scale); int32 b = irand(scale); return sc_min(a, b); } /// Generates a single random double value in linear distribution from 0.0 to +scale inline double RGen::linrand(double scale) { double a = drand(); double b = drand(); return sc_min(a, b) * scale; } /// Bilateral linearly distributed random 32 bit integer from -scale to +scale. inline int32 RGen::ibilinrand(int32 scale) { int32 a = irand(scale); int32 b = irand(scale); return a - b; } /// Bilateral linearly distributed random double from -scale to +scale. inline double RGen::bilinrand(double scale) { double a = drand(); double b = drand(); return (a - b) * scale; } /// Generates a single random double value in an exponential distributions from lo to hi inline double RGen::exprandrng(double lo, double hi) { return lo * exp(log(hi / lo) * drand()); } inline double RGen::exprand(double scale) { double z; while ((z = drand()) == 0.0) {} return -log(z) * scale; } /// Bilateral exponentially distributed random double from -scale to +scale. inline double RGen::biexprand(double scale) { double z; while ((z = drand2(1.)) == 0.0 || z == -1.0) {} if (z > 0.0) z = log(z); else z = -log(-z); return z * scale; } /** * Generates a random double from -scale to +scale that is the * result of summing three uniform random generators to yield a * bell-like distribution. * * Larry Polansky's loose approximation of a gaussian generator. */ inline double RGen::sum3rand(double scale) { return (drand() + drand() + drand() - 1.5) * 0.666666667 * scale; } /// Generate a double from 0.0 to 0.999... inline double drand(uint32& s1, uint32& s2, uint32& s3) { union { struct { uint32 hi, lo; } i; double f; } u; u.i.hi = 0x41300000; u.i.lo = trand(s1, s2, s3); return u.f - 1048576.; } /// Generate a float from 0.0 to 0.999... inline float frand(uint32& s1, uint32& s2, uint32& s3) { union { uint32 i; float f; } u; u.i = 0x3F800000 | (trand(s1, s2, s3) >> 9); return u.f - 1.f; } /// Generate a float from +1.0 to +1.999... inline float frand0(uint32& s1, uint32& s2, uint32& s3) { union { uint32 i; float f; } u; u.i = 0x3F800000 | (trand(s1, s2, s3) >> 9); return u.f; } /// Generate a float from -1.0 to +0.999... inline float frand2(uint32& s1, uint32& s2, uint32& s3) { union { uint32 i; float f; } u; u.i = 0x40000000 | (trand(s1, s2, s3) >> 9); return u.f - 3.f; } /// Generate a float from -0.125 to +0.124999... inline float frand8(uint32& s1, uint32& s2, uint32& s3) { union { uint32 i; float f; } u; u.i = 0x3E800000 | (trand(s1, s2, s3) >> 9); return u.f - 0.375f; } /// Returns one of the two float values -1.0 or +1.0 inline float fcoin(uint32& s1, uint32& s2, uint32& s3) { union { uint32 i; float f; } u; u.i = 0x3F800000 | (0x80000000 & trand(s1, s2, s3)); return u.f; }
9,889
C++
.h
298
29.228188
112
0.618469
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,022
Unroll.h
supercollider_supercollider/include/plugin_interface/Unroll.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* These macros allow one to write code which can be compiled optimally depending on what loop constructs the compiler can best generate code. */ #pragma once #include <string.h> #include <cassert> #if 1 // loop type # define FOR_IS_FASTER 1 # define WHILE_IS_FASTER 0 // indexing type # define PREINCREMENT_IS_FASTER 1 # define POSTINCREMENT_IS_FASTER 0 #else // loop type # define FOR_IS_FASTER 1 # define WHILE_IS_FASTER 0 // indexing type # define PREINCREMENT_IS_FASTER 0 # define POSTINCREMENT_IS_FASTER 1 #endif // LOOPING MACROS : #if FOR_IS_FASTER # define LOOP(length, stmt) \ for (int xxi = 0; xxi < (length); ++xxi) { \ stmt; \ } #elif WHILE_IS_FASTER # define LOOP(length, stmt) \ { \ int xxn = (length); \ while (--xxn) { \ stmt; \ } \ } #endif // above macros are not friendly to the debugger #if FOR_IS_FASTER # define LooP(length) for (int xxi = 0; xxi < (length); ++xxi) #elif WHILE_IS_FASTER # define LooP(length) for (int xxi = (length); --xxi;) #endif /* faster loop macro, length is required to be larger than 0 */ #define LOOP1(length, stmt) \ { \ int xxn = (length); \ assert(length); \ do { \ stmt; \ } while (--xxn); \ } // LOOP INDEXING : /* meanings of the indexing macros: ZXP = dereference and pre or post increment ZX = dereference PZ = preincrement (if applicable) ZP = postincrement (if applicable) ZOFF = offset from the pointer of the first element of the array (preincrement requires a ZOFF of 1 which is pre-subtracted from the base pointer. For other indexing types ZOFF is zero) */ #if PREINCREMENT_IS_FASTER # define ZXP(z) (*++(z)) # define ZX(z) (*(z)) # define PZ(z) (++(z)) # define ZP(z) (z) # define ZOFF (1) #elif POSTINCREMENT_IS_FASTER # define ZXP(z) (*(z)++) # define ZX(z) (*(z)) # define PZ(z) (z) # define ZP(z) ((z)++) # define ZOFF (0) #endif // ACCESSING INLETS AND OUTLETS : // unit inputs #define ZIN(i) (IN(i) - ZOFF) // get buffer pointer offset for iteration #define ZIN0(i) (IN(i)[0]) // get first sample // unit outputs #define ZOUT(i) (OUT(i) - ZOFF) // get buffer pointer offset for iteration #define ZOUT0(i) (OUT(i)[0]) // get first sample #include "SC_BoundsMacros.h" #include <assert.h> // Efficiency notes: Clear and Copy was benchmarked in October 2008. // See http://www.mcld.co.uk/blog/blog.php?217 and http://www.mcld.co.uk/blog/blog.php?218 // Set floating-point data to all zeros inline void Clear(int numSamples, float* out) { // The memset approach is valid on any system using IEEE floating-point. On other systems, please check... memset(out, 0, (unsigned int)numSamples * sizeof(float)); } inline void Clear(int numSamples, double* out) { // The memset approach is valid on any system using IEEE floating-point. On other systems, please check... memset(out, 0, (unsigned int)numSamples * sizeof(double)); } inline void Copy(int numSamples, float* out, float* in) { memcpy(out, in, (unsigned int)numSamples * sizeof(float)); } inline void Fill(int numSamples, float* out, float level) { out -= ZOFF; LOOP(numSamples, ZXP(out) = level;); } inline void Fill(int numSamples, float* out, float level, float slope) { out -= ZOFF; LOOP(numSamples, ZXP(out) = level; level += slope;); } inline void Accum(int numSamples, float* out, float* in) { in -= ZOFF; out -= ZOFF; LOOP(numSamples, ZXP(out) += ZXP(in);); } inline void Scale(int numSamples, float* out, float level) { out -= ZOFF; LOOP(numSamples, ZXP(out) *= level;); } inline float Scale(int numSamples, float* out, float level, float slope) { out -= ZOFF; LOOP(numSamples, ZXP(out) *= level; level += slope;); return level; } inline float Scale(int numSamples, float* out, float* in, float level, float slope) { in -= ZOFF; out -= ZOFF; LOOP(numSamples, ZXP(out) = ZXP(in) * level; level += slope;); return level; } inline float ScaleMix(int numSamples, float* out, float* in, float level, float slope) { in -= ZOFF; out -= ZOFF; LOOP(numSamples, ZXP(out) += ZXP(in) * level; level += slope;); return level; } inline void Scale(int numSamples, float* out, float* in, float level) { in -= ZOFF; out -= ZOFF; LOOP(numSamples, ZXP(out) = ZXP(in) * level;); } // in these the pointers are assumed to already have been pre-offset. inline void ZCopy(int numSamples, float* out, const float* in) { // pointers must be 8 byte aligned // assert((((long)(out+ZOFF) & 7) == 0) && (((long)(in+ZOFF) & 7) == 0)); if (in == out) return; if ((numSamples & 1) == 0) { // copying doubles is faster on powerpc. double* outd = (double*)(out + ZOFF) - ZOFF; const double* ind = (const double*)(in + ZOFF) - ZOFF; LOOP(numSamples >> 1, ZXP(outd) = ZXP(ind);); } else { LOOP(numSamples, ZXP(out) = ZXP(in);); } } inline void ZClear(int numSamples, float* out) { // pointers must be 8 byte aligned // assert((((long)(out+ZOFF) & 7) == 0) && (((long)(in+ZOFF) & 7) == 0)); if ((numSamples & 1) == 0) { // copying doubles is faster on powerpc. double* outd = (double*)(out + ZOFF) - ZOFF; LOOP(numSamples >> 1, ZXP(outd) = 0.;); } else { LOOP(numSamples, ZXP(out) = 0.f;); } } inline void ZAccum(int numSamples, float* out, float* in) { LOOP(numSamples, ZXP(out) += ZXP(in);); } template <typename Functor> inline void loop(int length, Functor const& f) { for (int i = 0; i < length; ++i) f(); } template <typename Functor> inline void loop1(int length, Functor const& f) { assert(length > 0); int i = length; do { f(); } while (--i); }
8,312
C++
.h
190
39.789474
120
0.528012
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,024
SCComplex.h
supercollider_supercollider/include/plugin_interface/SCComplex.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Complex.h" /** wrapper for backwards compatibility */ typedef Polar SCPolar; typedef Complex SCComplex; inline void init_SCComplex(InterfaceTable* inTable) {}
1,064
C++
.h
22
44.409091
81
0.768635
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,025
SC_FifoMsg.h
supercollider_supercollider/include/plugin_interface/SC_FifoMsg.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once typedef void (*FifoMsgFunc)(struct FifoMsg*); struct FifoMsg { FifoMsg(): mPerformFunc(0), mFreeFunc(0), mData(0), mWorld(0) {} void Set(struct World* inWorld, FifoMsgFunc inPerform, FifoMsgFunc inFree, void* inData); void Perform(); void Free(); FifoMsgFunc mPerformFunc; FifoMsgFunc mFreeFunc; void* mData; struct World* mWorld; }; inline void FifoMsg::Set(World* inWorld, FifoMsgFunc inPerform, FifoMsgFunc inFree, void* inData) { mWorld = inWorld; mPerformFunc = inPerform; mFreeFunc = inFree; mData = inData; } inline void FifoMsg::Perform() { if (mPerformFunc) (mPerformFunc)(this); } inline void FifoMsg::Free() { if (mFreeFunc) (mFreeFunc)(this); }
1,623
C++
.h
42
34.333333
99
0.73121
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,026
SC_Unit.h
supercollider_supercollider/include/plugin_interface/SC_Unit.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <type_traits> #include "SC_Types.h" #include "SC_SndBuf.h" typedef void (*UnitCtorFunc)(struct Unit* inUnit); typedef void (*UnitDtorFunc)(struct Unit* inUnit); typedef void (*UnitCalcFunc)(struct Unit* inThing, int inNumSamples); struct SC_Unit_Extensions { float* todo; }; struct Unit { struct World* mWorld; struct UnitDef* mUnitDef; struct Graph* mParent; uint32 mNumInputs, mNumOutputs; // changed from uint16 for synthdef ver 2 int16 mCalcRate; int16 mSpecialIndex; // used by unary and binary ops int16 mParentIndex; int16 mDone; struct Wire **mInput, **mOutput; struct Rate* mRate; SC_Unit_Extensions* mExtensions; // future proofing and backwards compatibility; used to be SC_Dimension struct pointer float **mInBuf, **mOutBuf; UnitCalcFunc mCalcFunc; int mBufLength; }; typedef struct Unit Unit; enum { kUnitDef_CantAliasInputsToOutputs = 1 }; #ifdef _WIN32 // Win32 headers (included by C std library headers) define IN and OUT macros // for their own purposes. # undef IN # undef OUT #endif // These return float* pointers to input and output buffers. #define IN(index) (unit->mInBuf[index]) #define OUT(index) (unit->mOutBuf[index]) // These return a float value. Used for control rate inputs and outputs. #define IN0(index) (IN(index)[0]) #define OUT0(index) (OUT(index)[0]) // get the rate of the input. #define INRATE(index) (unit->mInput[index]->mCalcRate) // get the blocksize of the input #define INBUFLENGTH(index) (unit->mInput[index]->mFromUnit->mBufLength) // set the calculation function #define SETCALC(func) (unit->mCalcFunc = (UnitCalcFunc)&func) #define ClearUnitOnMemFailed \ Print("%s: alloc failed, increase server's RT memory (e.g. via ServerOptions)\n", __func__); \ SETCALC(*ClearUnitOutputs); \ unit->mDone = true; \ return; #define ClearUnitIfMemFailed(condition) \ if (!(condition)) { \ ClearUnitOnMemFailed \ } template <typename ToType, typename Value> [[nodiscard]] inline constexpr auto copyAndCastToTypeOfFirstArg(const ToType&, const Value& value) noexcept { using TargetT = std::remove_cv_t<std::remove_reference_t<ToType>>; return static_cast<TargetT>(value); } // calculate a slope for control rate interpolation to audio rate. #define CALCSLOPE(next, prev) ((next - prev) * copyAndCastToTypeOfFirstArg(next, unit->mRate->mSlopeFactor)) // get useful values #define SAMPLERATE (unit->mRate->mSampleRate) #define SAMPLEDUR (unit->mRate->mSampleDur) #define BUFLENGTH (unit->mBufLength) #define BUFRATE (unit->mRate->mBufRate) #define BUFDUR (unit->mRate->mBufDuration) #define FULLRATE (unit->mWorld->mFullRate.mSampleRate) #define FULLBUFLENGTH (unit->mWorld->mFullRate.mBufLength) #ifdef SUPERNOVA template <bool shared1, bool shared2> struct buffer_lock2 { buffer_lock2(const SndBuf* buf1, const SndBuf* buf2): buf1_(buf1), buf2_(buf2) { if (buf1 == buf2) { lock1(); return; } for (;;) { lock1(); if (lock2()) return; unlock1(); } } ~buffer_lock2(void) { unlock1(); if (buf1_ != buf2_) unlock2(); } private: void lock1(void) { if (buf1_->isLocal) return; if (!shared1) buf1_->lock.lock(); else buf1_->lock.lock_shared(); } bool lock2(void) { if (buf2_->isLocal) return true; if (!shared2) return buf2_->lock.try_lock(); else return buf2_->lock.try_lock_shared(); } void unlock1(void) { if (buf1_->isLocal) return; if (!shared1) buf1_->lock.unlock(); else buf1_->lock.unlock_shared(); } void unlock2(void) { if (buf2_->isLocal) return; if (!shared2) buf2_->lock.unlock(); else buf2_->lock.unlock_shared(); } const SndBuf* buf1_; const SndBuf* buf2_; }; template <bool shared> struct buffer_lock { buffer_lock(const SndBuf* buf): buf_(buf) { if (!buf->isLocal) { if (shared) buf->lock.lock_shared(); else buf->lock.lock(); } } ~buffer_lock(void) { if (!buf_->isLocal) { if (shared) buf_->lock.unlock_shared(); else buf_->lock.unlock(); } } const SndBuf* buf_; }; # define ACQUIRE_BUS_AUDIO(index) unit->mWorld->mAudioBusLocks[index].lock() # define ACQUIRE_BUS_AUDIO_SHARED(index) unit->mWorld->mAudioBusLocks[index].lock_shared() # define RELEASE_BUS_AUDIO(index) unit->mWorld->mAudioBusLocks[index].unlock() # define RELEASE_BUS_AUDIO_SHARED(index) unit->mWorld->mAudioBusLocks[index].unlock_shared() # define LOCK_SNDBUF(buf) buffer_lock<false> lock_##buf(buf) # define LOCK_SNDBUF_SHARED(buf) buffer_lock<true> lock_##buf(buf); # define LOCK_SNDBUF2(buf1, buf2) buffer_lock2<false, false> lock_##buf1##_##buf2(buf1, buf2); # define LOCK_SNDBUF2_SHARED(buf1, buf2) buffer_lock2<true, true> lock_##buf1##_##buf2(buf1, buf2); # define LOCK_SNDBUF2_EXCLUSIVE_SHARED(buf1, buf2) buffer_lock2<false, true> lock_##buf1##_##buf2(buf1, buf2); # define LOCK_SNDBUF2_SHARED_EXCLUSIVE(buf1, buf2) buffer_lock2<true, false> lock_##buf1##_##buf2(buf1, buf2); # define ACQUIRE_SNDBUF(buf) \ do { \ if (!buf->isLocal) \ buf->lock.lock(); \ } while (false) # define ACQUIRE_SNDBUF_SHARED(buf) \ do { \ if (!buf->isLocal) \ buf->lock.lock_shared(); \ } while (false) # define RELEASE_SNDBUF(buf) \ do { \ if (!buf->isLocal) \ buf->lock.unlock(); \ } while (false) # define RELEASE_SNDBUF_SHARED(buf) \ do { \ if (!buf->isLocal) \ buf->lock.unlock_shared(); \ } while (false) # define ACQUIRE_BUS_CONTROL(index) unit->mWorld->mControlBusLock->lock() # define RELEASE_BUS_CONTROL(index) unit->mWorld->mControlBusLock->unlock() #else # define ACQUIRE_BUS_AUDIO(index) # define ACQUIRE_BUS_AUDIO_SHARED(index) # define RELEASE_BUS_AUDIO(index) # define RELEASE_BUS_AUDIO_SHARED(index) # define LOCK_SNDBUF(buf) # define LOCK_SNDBUF_SHARED(buf) # define LOCK_SNDBUF2(buf1, buf2) # define LOCK_SNDBUF2_SHARED(buf1, buf2) # define LOCK_SNDBUF2_EXCLUSIVE_SHARED(buf1, buf2) # define LOCK_SNDBUF2_SHARED_EXCLUSIVE(buf1, buf2) # define ACQUIRE_SNDBUF(buf) # define ACQUIRE_SNDBUF_SHARED(buf) # define RELEASE_SNDBUF(buf) # define RELEASE_SNDBUF_SHARED(buf) # define ACQUIRE_BUS_CONTROL(index) # define RELEASE_BUS_CONTROL(index) #endif // macros to grab a Buffer reference from the buffer indicated by the UGen's FIRST input #define GET_BUF \ float fbufnum = ZIN0(0); \ if (fbufnum < 0.f) { \ fbufnum = 0.f; \ } \ if (fbufnum != unit->m_fbufnum) { \ uint32 bufnum = (int)fbufnum; \ World* world = unit->mWorld; \ if (bufnum >= world->mNumSndBufs) { \ int localBufNum = bufnum - world->mNumSndBufs; \ Graph* parent = unit->mParent; \ if (localBufNum <= parent->localBufNum) { \ unit->m_buf = parent->mLocalSndBufs + localBufNum; \ } else { \ bufnum = 0; \ unit->m_buf = world->mSndBufs + bufnum; \ } \ } else { \ unit->m_buf = world->mSndBufs + bufnum; \ } \ unit->m_fbufnum = fbufnum; \ } \ SndBuf* buf = unit->m_buf; \ LOCK_SNDBUF(buf); \ float* bufData __attribute__((__unused__)) = buf->data; \ uint32 bufChannels __attribute__((__unused__)) = buf->channels; \ uint32 bufSamples __attribute__((__unused__)) = buf->samples; \ uint32 bufFrames = buf->frames; \ int mask __attribute__((__unused__)) = buf->mask; \ int guardFrame __attribute__((__unused__)) = bufFrames - 2; #define GET_BUF_SHARED \ float fbufnum = ZIN0(0); \ if (fbufnum < 0.f) { \ fbufnum = 0.f; \ } \ if (fbufnum != unit->m_fbufnum) { \ uint32 bufnum = (int)fbufnum; \ World* world = unit->mWorld; \ if (bufnum >= world->mNumSndBufs) { \ int localBufNum = bufnum - world->mNumSndBufs; \ Graph* parent = unit->mParent; \ if (localBufNum <= parent->localBufNum) { \ unit->m_buf = parent->mLocalSndBufs + localBufNum; \ } else { \ bufnum = 0; \ unit->m_buf = world->mSndBufs + bufnum; \ } \ } else { \ unit->m_buf = world->mSndBufs + bufnum; \ } \ unit->m_fbufnum = fbufnum; \ } \ const SndBuf* buf = unit->m_buf; \ LOCK_SNDBUF_SHARED(buf); \ const float* bufData __attribute__((__unused__)) = buf->data; \ uint32 bufChannels __attribute__((__unused__)) = buf->channels; \ uint32 bufSamples __attribute__((__unused__)) = buf->samples; \ uint32 bufFrames = buf->frames; \ int mask __attribute__((__unused__)) = buf->mask; \ int guardFrame __attribute__((__unused__)) = bufFrames - 2; #define SIMPLE_GET_BUF \ float fbufnum = ZIN0(0); \ fbufnum = sc_max(0.f, fbufnum); \ if (fbufnum != unit->m_fbufnum) { \ uint32 bufnum = (int)fbufnum; \ World* world = unit->mWorld; \ if (bufnum >= world->mNumSndBufs) { \ int localBufNum = bufnum - world->mNumSndBufs; \ Graph* parent = unit->mParent; \ if (localBufNum <= parent->localBufNum) { \ unit->m_buf = parent->mLocalSndBufs + localBufNum; \ } else { \ bufnum = 0; \ unit->m_buf = world->mSndBufs + bufnum; \ } \ } else { \ unit->m_buf = world->mSndBufs + bufnum; \ } \ unit->m_fbufnum = fbufnum; \ } \ SndBuf* buf = unit->m_buf; #define SIMPLE_GET_BUF_EXCLUSIVE \ SIMPLE_GET_BUF; \ LOCK_SNDBUF(buf); #define SIMPLE_GET_BUF_SHARED \ SIMPLE_GET_BUF; \ LOCK_SNDBUF_SHARED(buf); // macros to get pseudo-random number generator, and put its state in registers #define RGET \ RGen& rgen = *unit->mParent->mRGen; \ uint32 s1 = rgen.s1; \ uint32 s2 = rgen.s2; \ uint32 s3 = rgen.s3; #define RPUT \ rgen.s1 = s1; \ rgen.s2 = s2; \ rgen.s3 = s3; typedef void (*UnitCmdFunc)(struct Unit* unit, struct sc_msg_iter* args); typedef void (*PlugInCmdFunc)(World* inWorld, void* inUserData, struct sc_msg_iter* args, void* replyAddr);
21,155
C++
.h
311
61.607717
120
0.335835
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,027
Hash.h
supercollider_supercollider/include/plugin_interface/Hash.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Types.h" #include "SC_Endian.h" // These hash functions are among the best there are in terms of both speed and quality. // A good hash function makes a lot of difference. // I have not used Bob Jenkins own hash function because the keys I use are relatively short. // hash function for a string inline int32 Hash(const char* inKey) { // the one-at-a-time hash. // a very good hash function. ref: a web page by Bob Jenkins. // http://www.burtleburtle.net/bob/hash/doobs.html int32 hash = 0; while (*inKey) { hash += *inKey++; hash += hash << 10; hash ^= hash >> 6; } hash += hash << 3; hash ^= hash >> 11; hash += hash << 15; return hash; } // hash function for a string that also returns the length inline int32 Hash(const char* inKey, size_t* outLength) { // the one-at-a-time hash. // a very good hash function. ref: a web page by Bob Jenkins. const char* origKey = inKey; int32 hash = 0; while (*inKey) { hash += *inKey++; hash += hash << 10; hash ^= hash >> 6; } hash += hash << 3; hash ^= hash >> 11; hash += hash << 15; *outLength = (size_t)(inKey - origKey); return hash; } // hash function for an array of char inline int32 Hash(const char* inKey, int32 inLength) { // the one-at-a-time hash. // a very good hash function. ref: a web page by Bob Jenkins. int32 hash = 0; for (int i = 0; i < inLength; ++i) { hash += *inKey++; hash += hash << 10; hash ^= hash >> 6; } hash += hash << 3; hash ^= hash >> 11; hash += hash << 15; return hash; } // hash function for integers inline int32 Hash(int32 inKey) { // Thomas Wang's integer hash. // http://www.concentric.net/~Ttwang/tech/inthash.htm // a faster hash for integers. also very good. uint32 hash = (uint32)inKey; hash += ~(hash << 15); hash ^= hash >> 10; hash += hash << 3; hash ^= hash >> 6; hash += ~(hash << 11); hash ^= hash >> 16; return (int32)hash; } inline int64 Hash64(int64 inKey) { // Thomas Wang's 64 bit integer hash. uint64 hash = (uint64)inKey; hash += ~(hash << 32); hash ^= (hash >> 22); hash += ~(hash << 13); hash ^= (hash >> 8); hash += (hash << 3); hash ^= (hash >> 15); hash += ~(hash << 27); hash ^= (hash >> 31); return (int64)hash; } inline int32 Hash(const int32* inKey, int32 inLength) { // one-at-a-time hashing of a string of int32's. // uses Thomas Wang's integer hash for the combining step. int32 hash = 0; for (int i = 0; i < inLength; ++i) { hash = Hash(hash + *inKey++); } return hash; } #if BYTE_ORDER == LITTLE_ENDIAN const int32 kLASTCHAR = (int32)0xFF000000; #else const int32 kLASTCHAR = (int32)0x000000FF; #endif inline int32 Hash(const int32* inKey) { // hashing of a string of int32's. // uses Thomas Wang's integer hash for the combining step. int32 hash = 0; int32 c; do { c = *inKey++; hash = Hash(hash + c); } while (c & kLASTCHAR); return hash; }
4,025
C++
.h
122
28.483607
93
0.633136
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,029
SC_Constants.h
supercollider_supercollider/include/plugin_interface/SC_Constants.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <cmath> #ifndef __FP__ const double pi = std::acos(-1.); #else const double sc_pi = std::acos(-1.); # define pi sc_pi // hack to avoid osx warning about deprecated pi #endif /// pi / 2 const double pi2 = pi * .5; /// 3pi / 2 const double pi32 = pi * 1.5; /// 2pi const double twopi = pi * 2.; /// 1/2pi const double rtwopi = 1. / twopi; /// log(0.001) const double log001 = std::log(0.001); /// log(0.01) const double log01 = std::log(0.01); /// log(0.1) const double log1 = std::log(0.1); /// 1/log(2) const double rlog2 = 1. / std::log(2.); /// sqrt(2) const double sqrt2 = std::sqrt(2.); /// 1/sqrt(2) const double rsqrt2 = 1. / sqrt2; /// pi as float const float pi_f = std::acos(-1.f); /// pi / 2 const float pi2_f = pi_f * 0.5f; /// 3pi / 2 const float pi32_f = pi_f * 1.5f; /// 2pi const float twopi_f = pi_f * 2.f; /// sqrt(2) const float sqrt2_f = std::sqrt(2.f); /// 1/sqrt(2) const float rsqrt2_f = 1.f / std::sqrt(2.f); /// used to truncate precision const float truncFloat = (float)(3. * std::pow(2.0, 22)); const double truncDouble = 3. * std::pow(2.0, 51); /// used in the secant table for values very close to 1/0 const float kBadValue = 1e20f;
2,080
C++
.h
61
31.786885
81
0.691228
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,030
SC_sndfile_stub.h
supercollider_supercollider/include/plugin_interface/SC_sndfile_stub.h
/* ** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by ** the Free Software Foundation; either version 2.1 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Lesser General Public License for more details. ** ** You should have received a copy of the GNU Lesser General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* ** SC_sndfile_stub.h -- stub of libsndfile definitions, used to preserve binary compatibility when libsndfile *unavailable ** taken from sndfile.h **/ /* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ typedef struct SNDFILE_tag SNDFILE; #if (defined(_MSCVER) || defined(_MSC_VER)) typedef __int64_t sf_count_t; # define SF_COUNT_MAX 0x7fffffffffffffffi64 #else typedef off_t sf_count_t; # define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL #endif /* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. ** On write, the SF_INFO structure is filled in by the user and passed into ** sf_open_write (). */ struct SF_INFO { sf_count_t frames; /* Used to be called samples. Changed to avoid confusion. */ int samplerate; int channels; int format; int sections; int seekable; }; typedef struct SF_INFO SF_INFO;
1,709
C++
.h
44
37.068182
109
0.746828
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,031
SC_Node.h
supercollider_supercollider/include/plugin_interface/SC_Node.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Types.h" typedef void (*NodeCalcFunc)(struct Node* inNode); struct Node { int32 mID; int32 mHash; struct World* mWorld; struct NodeDef* mDef; NodeCalcFunc mCalcFunc; struct Node *mPrev, *mNext; struct Group* mParent; int32 mIsGroup; }; typedef struct Node Node; enum { kNode_Go, kNode_End, kNode_On, kNode_Off, kNode_Move, kNode_Info };
1,277
C++
.h
31
36.967742
81
0.745543
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,033
SC_Complex.h
supercollider_supercollider/include/plugin_interface/SC_Complex.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <cmath> #include "SC_Types.h" #include "SC_Constants.h" #include "float.h" #ifdef _MSC_VER // hypotf is c99, but not c++ # define hypotf _hypotf #endif //////////////////////////////////////////////////////////////////////////////// namespace detail { const int kSineSize = 8192; const int kSineMask = kSineSize - 1; const double kSinePhaseScale = kSineSize / twopi; const int32 kPolarLUTSize = 2049; const int32 kPolarLUTSize2 = kPolarLUTSize >> 1; /* each object file that is including this header will have separate lookup tables */ namespace { float gMagLUT[kPolarLUTSize]; float gPhaseLUT[kPolarLUTSize]; float gSine[kSineSize + 1]; static bool initTables(void) { double sineIndexToPhase = twopi / kSineSize; for (int i = 0; i <= kSineSize; ++i) { double phase = i * sineIndexToPhase; float32 d = sin(phase); gSine[i] = d; } double rPolarLUTSize2 = 1. / kPolarLUTSize2; for (int i = 0; i < kPolarLUTSize; ++i) { double slope = (i - kPolarLUTSize2) * rPolarLUTSize2; double angle = atan(slope); gPhaseLUT[i] = (float)angle; gMagLUT[i] = (float)(1.f / cos(angle)); } return true; } bool dummy = initTables(); } struct Polar; struct Complex { Complex() {} Complex(float r, float i): real(r), imag(i) {} void Set(float r, float i) { real = r; imag = i; } Complex& operator=(Complex b) { real = b.real; imag = b.imag; return *this; } Complex& operator=(float b) { real = b; imag = 0.; return *this; } Polar ToPolar(); /** * Converts cartesian to polar representation, using lookup tables. * Note: in this implementation the phase values returned lie in the range [-pi/4, 7pi/4] * rather than the more conventional [0, 2pi] or [-pi, pi]. */ Polar ToPolarApx(); void ToPolarInPlace(); void ToPolarApxInPlace(); float real, imag; }; struct Polar { Polar() {} Polar(float m, float p): mag(m), phase(p) {} void Set(float m, float p) { mag = m; phase = p; } Complex ToComplex() { return Complex(mag * std::cos(phase), mag * std::sin(phase)); } Complex ToComplexApx() { uint32 sinindex = (int32)(kSinePhaseScale * phase) & kSineMask; uint32 cosindex = (sinindex + (kSineSize >> 2)) & kSineMask; return Complex(mag * gSine[cosindex], mag * gSine[sinindex]); } void ToComplexInPlace() { Complex complx = ToComplex(); mag = complx.real; phase = complx.imag; } void ToComplexApxInPlace() { Complex complx = ToComplexApx(); mag = complx.real; phase = complx.imag; } float mag, phase; }; inline Polar Complex::ToPolar() { return Polar(hypotf(imag, real), std::atan2(imag, real)); } inline Polar Complex::ToPolarApx() { int32 index; float absreal = fabs(real); float absimag = fabs(imag); float mag, phase, slope; if (absreal > absimag) { slope = imag / real; index = (int32)(kPolarLUTSize2 + kPolarLUTSize2 * slope); mag = gMagLUT[index] * absreal; phase = gPhaseLUT[index]; if (real > 0) { return Polar(mag, phase); } else { return Polar(mag, (float)(pi + phase)); } } else if (absimag > 0) { slope = real / imag; index = (int32)(kPolarLUTSize2 + kPolarLUTSize2 * slope); mag = gMagLUT[index] * absimag; phase = gPhaseLUT[index]; if (imag > 0) { return Polar(mag, (float)(pi2 - phase)); } else { return Polar(mag, (float)(pi32 - phase)); } } else return Polar(0, 0); } inline void Complex::ToPolarInPlace() { Polar polar = ToPolar(); real = polar.mag; imag = polar.phase; } inline void Complex::ToPolarApxInPlace() { Polar polar = ToPolarApx(); real = polar.mag; imag = polar.phase; } } using detail::Complex; using detail::Polar; struct ComplexFT { float dc, nyq; Complex complex[1]; }; struct PolarFT { float dc, nyq; Polar polar[1]; }; void ToComplex(Polar in, Complex& out); inline Complex operator+(Complex a, Complex b) { return Complex(a.real + b.real, a.imag + b.imag); } inline Complex operator+(Complex a, float b) { return Complex(a.real + b, a.imag); } inline Complex operator+(float a, Complex b) { return Complex(a + b.real, b.imag); } inline Complex& operator+=(Complex& a, const Complex& b) { a.real += b.real, a.imag += b.imag; return a; } inline Complex& operator+=(Complex& a, float b) { a.real += b; return a; } inline Complex operator-(Complex a, Complex b) { return Complex(a.real - b.real, a.imag - b.imag); } inline Complex operator-(Complex a, float b) { return Complex(a.real - b, a.imag); } inline Complex operator-(float a, Complex b) { return Complex(a - b.real, b.imag); } inline Complex operator-=(Complex a, Complex b) { a.real -= b.real, a.imag -= b.imag; return a; } inline Complex operator-=(Complex a, float b) { a.real -= b; return a; } inline Complex operator*(Complex a, Complex b) { return Complex(a.real * b.real - a.imag * b.imag, a.real * b.imag + a.imag * b.real); } inline Complex operator*(Complex a, float b) { return Complex(a.real * b, a.imag * b); } inline Complex operator*(float a, Complex b) { return Complex(b.real * a, b.imag * a); } inline Complex operator*=(Complex a, Complex b) { a.Set(a.real * b.real - a.imag * b.imag, a.real * b.imag + a.imag * b.real); return a; } inline Complex operator*=(Complex a, float b) { a.real *= b; a.imag *= b; return a; } inline Polar operator*(Polar a, float b) { return Polar(a.mag * b, a.phase); } inline Polar operator*(float a, Polar b) { return Polar(a * b.mag, b.phase); } inline Polar operator*=(Polar a, float b) { a.mag *= b; return a; }
6,839
C++
.h
202
29.034653
100
0.636681
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,034
SC_DemandUnit.h
supercollider_supercollider/include/plugin_interface/SC_DemandUnit.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Unit.h" #include "SC_Wire.h" // demand rate unit support. inline bool IsDemandInput(Unit* unit, int index) { Unit* fromUnit = unit->mInput[index]->mFromUnit; return fromUnit && fromUnit->mCalcRate == calc_DemandRate; } inline float DemandInput(Unit* unit, int index) { Unit* fromUnit = unit->mInput[index]->mFromUnit; if (fromUnit && fromUnit->mCalcRate == calc_DemandRate) (fromUnit->mCalcFunc)(fromUnit, 1); return IN0(index); } // support for audio rate input to demand UGens // offset comes in as inNumSamples, so is in the range 1..size ! inNumSamples = 0 has a special meaning (reset). // it is converted to a buffer index here. inline float DemandInputA(Unit* unit, int index, int offset) { Unit* fromUnit = unit->mInput[index]->mFromUnit; if (!fromUnit) { return IN0(index); } if (fromUnit->mCalcRate == calc_DemandRate) { (fromUnit->mCalcFunc)(fromUnit, offset); return IN0(index); } else if (fromUnit->mCalcRate == calc_FullRate) { return IN(index)[offset - 1]; } else { return IN0(index); } } inline void ResetInput(Unit* unit, int index) { Unit* fromUnit = unit->mInput[index]->mFromUnit; if (fromUnit && fromUnit->mCalcRate == calc_DemandRate) (fromUnit->mCalcFunc)(fromUnit, 0); } #define ISDEMANDINPUT(index) IsDemandInput(unit, (index)) #define DEMANDINPUT(index) DemandInput(unit, (index)) #define DEMANDINPUT_A(index, offset) DemandInputA(unit, (index), (offset)) #define RESETINPUT(index) ResetInput(unit, (index))
2,454
C++
.h
56
39.607143
112
0.718776
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,035
SC_BufGen.h
supercollider_supercollider/include/plugin_interface/SC_BufGen.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Types.h" typedef void (*BufGenFunc)(struct World* world, struct SndBuf* buf, struct sc_msg_iter* msg); struct BufGen { int32 mBufGenName[kSCNameLen]; int32 mHash; BufGenFunc mBufGenFunc; }; extern "C" { bool BufGen_Create(const char* inName, BufGenFunc inFunc); }
1,181
C++
.h
27
39.888889
93
0.757205
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,036
sc_msg_iter.h
supercollider_supercollider/include/plugin_interface/sc_msg_iter.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Endian.h" #include "SC_Types.h" #include <string.h> // return the ptr to the byte after the OSC string. inline const char* OSCstrskip(const char* str) { // while (str[3]) { str += 4; } // return str + 4; do { str += 4; } while (str[-1]); return str; } // returns the number of bytes (including padding) for an OSC string. inline size_t OSCstrlen(const char* strin) { return (size_t)(OSCstrskip(strin) - strin); } // returns a float, converting an int if necessary inline float32 OSCfloat(const char* inData) { elem32 elem; elem.u = sc_ntohl(*(uint32*)inData); return elem.f; } inline int32 OSCint(const char* inData) { return (int32)sc_ntohl(*(uint32*)inData); } inline int64 OSCtime(const char* inData) { return ((int64)sc_ntohl(*(uint32*)inData) << 32) + (sc_ntohl(*(uint32*)(inData + 4))); } inline float64 OSCdouble(const char* inData) { elem64 slot; slot.i = ((int64)sc_ntohl(*(uint32*)inData) << 32) + (sc_ntohl(*(uint32*)(inData + 4))); return slot.f; } struct sc_msg_iter { const char *data, *rdpos, *endpos, *tags; int size, count; sc_msg_iter(); sc_msg_iter(int inSize, const char* inData); void init(int inSize, const char* inData); int64 gett(int64 defaultValue = 1); int32 geti(int32 defaultValue = 0); float32 getf(float32 defaultValue = 0.f); float64 getd(float64 defaultValue = 0.f); const char* gets(const char* defaultValue = 0); int32* gets4(char* defaultValue = 0); size_t getbsize(); void getb(char* outData, size_t inSize); void skipb(); size_t remain() { return (size_t)(endpos - rdpos); } char nextTag(char defaultTag = 'f') { return tags ? tags[count] : defaultTag; } }; inline sc_msg_iter::sc_msg_iter() {} inline sc_msg_iter::sc_msg_iter(int inSize, const char* inData) { init(inSize, inData); } inline void sc_msg_iter::init(int inSize, const char* inData) { data = inData; size = inSize; endpos = data + size; count = 0; if (data[0] == ',') { tags = data + 1; rdpos = OSCstrskip(data); } else { tags = 0; rdpos = data; } } inline int64 sc_msg_iter::gett(int64 defaultValue) { int64 value; if (remain() <= 0) return defaultValue; if (tags) { if (tags[count] == 't') { value = OSCtime(rdpos); rdpos += sizeof(int64); } else { /* this is dangerous, as rdpos is not advanced accordingly while count++ takes place */ value = defaultValue; } } else { value = OSCtime(rdpos); rdpos += sizeof(int64); } count++; return value; } inline int32 sc_msg_iter::geti(int32 defaultValue) { int value; if (remain() <= 0) return defaultValue; if (tags) { if (tags[count] == 'i') { value = OSCint(rdpos); rdpos += sizeof(int32); } else if (tags[count] == 'f') { value = (int32)OSCfloat(rdpos); rdpos += sizeof(float32); } else if (tags[count] == 's') { /* value = atoi(rdpos); */ value = defaultValue; rdpos = OSCstrskip(rdpos); } else if (tags[count] == 'b') { value = defaultValue; skipb(); } else { /* this is dangerous, as rdpos is not advanced accordingly while count++ takes place */ value = defaultValue; } } else { value = (int)OSCint(rdpos); rdpos += sizeof(int32); } count++; return value; } inline float32 sc_msg_iter::getf(float32 defaultValue) { float32 value; if (remain() <= 0) return defaultValue; if (tags) { if (tags[count] == 'f') { value = OSCfloat(rdpos); rdpos += sizeof(float32); } else if (tags[count] == 'd') { value = static_cast<float32>(OSCdouble(rdpos)); rdpos += sizeof(float64); } else if (tags[count] == 'i') { value = static_cast<float32>(OSCint(rdpos)); rdpos += sizeof(int32); } else if (tags[count] == 's') { /* value = atof(rdpos); */ value = defaultValue; rdpos = OSCstrskip(rdpos); } else if (tags[count] == 'b') { value = defaultValue; skipb(); } else { /* this is dangerous, as rdpos is not advanced accordingly while count++ takes place */ value = defaultValue; } } else { value = OSCfloat(rdpos); rdpos += sizeof(float32); } count++; return value; } inline float64 sc_msg_iter::getd(float64 defaultValue) { float64 value; if (remain() <= 0) return defaultValue; if (tags) { if (tags[count] == 'f') { value = (float64)OSCfloat(rdpos); rdpos += sizeof(float32); } else if (tags[count] == 'd') { value = OSCdouble(rdpos); rdpos += sizeof(float64); } else if (tags[count] == 'i') { value = (float64)OSCint(rdpos); rdpos += sizeof(int32); } else if (tags[count] == 's') { /* value = atof(rdpos); */ value = defaultValue; rdpos = OSCstrskip(rdpos); } else if (tags[count] == 'b') { value = defaultValue; skipb(); } else { /* this is dangerous, as rdpos is not advanced accordingly while count++ takes place */ value = defaultValue; } } else { value = OSCdouble(rdpos); rdpos += sizeof(float64); } count++; return value; } inline const char* sc_msg_iter::gets(const char* defaultValue) { const char* value; if (remain() <= 0) return 0; if (tags) { if (tags[count] == 's') { value = rdpos; rdpos = OSCstrskip(rdpos); } else { value = defaultValue; } } else { value = rdpos; rdpos = OSCstrskip(rdpos); } count++; return value; } inline int32* sc_msg_iter::gets4(char* defaultValue) { int32* value; if (remain() <= 0) return 0; if (tags) { if (tags[count] == 's') { value = (int32*)rdpos; rdpos = OSCstrskip(rdpos); } else { value = (int32*)defaultValue; } } else { value = (int32*)rdpos; rdpos = OSCstrskip(rdpos); } count++; return value; } inline size_t sc_msg_iter::getbsize() { size_t len = 0; if (remain() <= 0) return 0; if (tags) { if (tags[count] == 'b') len = (size_t)OSCint(rdpos); else if (tags[count] == 'm') len = 4; } return len; } inline void sc_msg_iter::getb(char* outArray, size_t arraySize) { size_t len = 0; if (tags[count] == 'b') { len = (size_t)OSCint(rdpos); if (arraySize < len) return; rdpos += sizeof(int32); } else if (tags[count] == 'm') { len = 4; if (arraySize < len) return; } size_t len4 = (len + 3) & (size_t)-4; memcpy(outArray, rdpos, arraySize); rdpos += len4; count++; } inline void sc_msg_iter::skipb() { size_t len = 0; if (tags[count] == 'b') { len = (size_t)OSCint(rdpos); rdpos += sizeof(int32); } else if (tags[count] == 'm') len = 4; size_t len4 = (len + 3) & (size_t)-4; rdpos += len4; count++; }
8,538
C++
.h
275
23.843636
92
0.558106
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,038
SC_PlugIn.h
supercollider_supercollider/include/plugin_interface/SC_PlugIn.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_World.h" #include "SC_Graph.h" #include "SC_Unit.h" #include "SC_Wire.h" #include "SC_InterfaceTable.h" #include "Unroll.h" #include "SC_InlineUnaryOp.h" #include "SC_InlineBinaryOp.h" #include "SC_BoundsMacros.h" #include "SC_RGen.h" #include "SC_DemandUnit.h" #include "clz.h" #include "sc_msg_iter.h" #include <stdlib.h> #include "SC_Alloca.h" #ifdef _WIN32 // temporarily override __attribute__ for (unused), later we'll remove it # ifndef __GNUC__ # define __attribute__(x) # endif # ifndef NAN // NAN is c99 # include <limits> # define NAN std::numeric_limits<float>::quiet_NaN() # endif // windows.h defines min() and max() macros which break things such as // std::numeric_limits<int32>::max() - so let's undefine them # undef max # undef min #endif
1,704
C++
.h
46
34.586957
81
0.72799
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,040
SC_LanguageClient.h
supercollider_supercollider/include/lang/SC_LanguageClient.h
/* -*- c++ -*- Abstract interpreter interface. Copyright (c) 2003 2004 stefan kersten. Copyright (c) 2013 tim blechmann. ==================================================================== SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "SC_Export.h" #include <cstdio> #include <cstdarg> // ===================================================================== // SC_LanguageClient - abstract sclang client. // ===================================================================== SCLANG_DLLEXPORT class SC_LanguageClient* createLanguageClient(const char* name); SCLANG_DLLEXPORT void destroyLanguageClient(class SC_LanguageClient*); class SCLANG_DLLEXPORT SC_LanguageClient { public: struct Options { Options(): mMemSpace(2 * 1024 * 1024), mMemGrow(256 * 1024), mPort(57120), mRuntimeDir(0) {} int mMemSpace; // memory space in bytes int mMemGrow; // memory growth in bytes int mPort; // network port number char* mRuntimeDir; // runtime directory }; protected: // create singleton instance SC_LanguageClient(const char* name); virtual ~SC_LanguageClient(); friend void destroyLanguageClient(class SC_LanguageClient*); public: // singleton instance access locking static void lockInstance(); static void unlockInstance(); // return the singleton instance static SC_LanguageClient* instance(); static SC_LanguageClient* lockedInstance() { lockInstance(); return instance(); } // initialize language runtime void initRuntime(const Options& opt = Options()); void shutdownRuntime(); // return application name const char* getName() const; // library startup/shutdown bool isLibraryCompiled(); void compileLibrary(bool standalone); void shutdownLibrary(); void recompileLibrary(bool standalone); // interpreter access void lock(); bool trylock(); void unlock(); struct VMGlobals* getVMGlobals(); void setCmdLine(const char* buf, size_t size); void setCmdLine(const char* str); void setCmdLinef(const char* fmt, ...); void runLibrary(const char* methodName); void interpretCmdLine(); void interpretPrintCmdLine(); void executeFile(const char* fileName); void runMain(); void stopMain(); // post file access FILE* getPostFile(); void setPostFile(FILE* file); // run (in case of a terminal client) virtual int run(int argc, char** argv); // post buffer output (subclass responsibility) // should be thread-save. virtual void postText(const char* str, size_t len) = 0; virtual void postFlush(const char* str, size_t len) = 0; virtual void postError(const char* str, size_t len) = 0; // flush post buffer contents to screen. // only called from the main language thread. virtual void flush() = 0; // command line argument handling utilities static void snprintMemArg(char* dst, size_t size, int arg); static bool parseMemArg(const char* arg, int* res); static bool parsePortArg(const char* arg, int* res); // AppClock driver // to be called from client mainloop. void tick(); // AppClock driver. WARNING: Must be called locked! // Returns whether there is anything scheduled, // and writes the scheduled absolute time, if any, into nextTime. bool tickLocked(double* nextTime); protected: // language notifications, subclasses can override // called after language runtime has been initialized virtual void onInitRuntime(); // called after the library has been compiled virtual void onLibraryStartup(); // called before the library is shut down virtual void onLibraryShutdown(); // called after the interpreter has been started virtual void onInterpStartup(); void runLibrary(struct PyrSymbol* pyrSymbol); private: friend void closeAllGUIScreens(); friend void initGUIPrimitives(); friend void initGUI(); private: class HiddenLanguageClient* mHiddenClient; }; // ===================================================================== // library functions // ===================================================================== extern void setPostFile(FILE* file); extern "C" int vpost(const char* fmt, va_list vargs); extern void post(const char* fmt, ...); extern void postfl(const char* fmt, ...); extern void postText(const char* text, long length); extern void postChar(char c); extern void error(const char* fmt, ...); extern void flushPostBuf();
5,401
C++
.h
130
37.007692
100
0.671693
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,041
SC_Export.h
supercollider_supercollider/include/common/SC_Export.h
/* SuperCollider real time audio synthesis system Copyright (c) 2010 Tim Blechmann. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #if defined _WIN32 || defined __CYGWIN__ # define SC_API_IMPORT __declspec(dllimport) # define SC_API_EXPORT __declspec(dllexport) #else # if __GNUC__ >= 4 # define SC_API_IMPORT __attribute__((visibility("default"))) # define SC_API_EXPORT __attribute__((visibility("default"))) # else # define SC_API_IMPORT # define SC_API_EXPORT # endif #endif #ifdef __cplusplus # define C_LINKAGE extern "C" #else # define C_LINKAGE #endif #ifdef BUILDING_SCSYNTH // if scsynth is being built, instead of used # define SCSYNTH_DLLEXPORT_C C_LINKAGE SC_API_EXPORT # define SCSYNTH_DLLEXPORT SC_API_EXPORT #elif defined(USING_SCSYNTH) # define SCSYNTH_DLLEXPORT_C C_LINKAGE SC_API_IMPORT # define SCSYNTH_DLLEXPORT SC_API_IMPORT #else # define SCSYNTH_DLLEXPORT_C C_LINKAGE # define SCSYNTH_DLLEXPORT /*SC_API_IMPORT*/ #endif #ifdef BUILDING_SCLANG // if sclang is being built, instead of used # define SCLANG_DLLEXPORT_C C_LINKAGE SC_API_EXPORT # define SCLANG_DLLEXPORT SC_API_EXPORT #elif defined(USING_SCSYNTH) # define SCLANG_DLLEXPORT_C C_LINKAGE SC_API_IMPORT # define SCLANG_DLLEXPORT SC_API_IMPORT #else # define SCLANG_DLLEXPORT_C C_LINKAGE # define SCLANG_DLLEXPORT /*SC_API_IMPORT*/ #endif
2,133
C++
.h
53
38.113208
81
0.736969
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,042
SC_Reply.h
supercollider_supercollider/include/common/SC_Reply.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once struct ReplyAddress; typedef void (*ReplyFunc)(struct ReplyAddress* inReplyAddr, char* inBuf, int inSize);
996
C++
.h
19
48.157895
85
0.76622
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,043
SC_fftlib.h
supercollider_supercollider/include/common/SC_fftlib.h
/* SC_fftlib.h An interface to abstract over different FFT libraries, for SuperCollider 3. Copyright (c) 2008 Dan Stowell. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <string.h> // These specify the min & max FFT sizes expected (used when creating windows, also allocating some other arrays). #define SC_FFT_MINSIZE 8 #define SC_FFT_LOG2_MINSIZE 3 #define SC_FFT_MAXSIZE 32768 #define SC_FFT_LOG2_MAXSIZE 15 // Note that things like *fftWindow actually allow for other sizes, to be created on user request. #define SC_FFT_ABSOLUTE_MAXSIZE 262144 #define SC_FFT_LOG2_ABSOLUTE_MAXSIZE 18 #define SC_FFT_LOG2_ABSOLUTE_MAXSIZE_PLUS1 19 struct scfft; class SCFFT_Allocator { public: virtual void* alloc(size_t size) = 0; virtual void free(void* ptr) = 0; virtual ~SCFFT_Allocator() {} }; enum SCFFT_Direction { kForward = 1, kBackward = 0 }; // These values are referred to from SC lang as well as in the following code - do not rearrange! enum SCFFT_WindowFunction { kRectWindow = -1, kSineWindow = 0, kHannWindow = 1 }; //////////////////////////////////////////////////////////////////////////////////////////////////// // Functions // To initialise a specific FFT, ensure your input and output buffers exist. Internal data structures // will be allocated using the alloc object, // Both "fullsize" and "winsize" should be powers of two (this is not checked internally). scfft* scfft_create(size_t fullsize, size_t winsize, SCFFT_WindowFunction wintype, float* indata, float* outdata, SCFFT_Direction forward, SCFFT_Allocator& alloc); // These two will take data from indata, use trbuf to process it, and put their results in outdata. void scfft_dofft(scfft* f); void scfft_doifft(scfft* f); // destroy any resources held internally. void scfft_destroy(scfft* f, SCFFT_Allocator& alloc);
2,559
C++
.h
49
49.326531
114
0.73205
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,044
wintime.h
supercollider_supercollider/include/common/wintime.h
#pragma once #include <WinSock2.h> // for timeval struct #include <windows.h> /* Implementation as per: The Open Group Base Specifications, Issue 6 IEEE Std 1003.1, 2004 Edition The timezone pointer arg is ignored. Errors are ignored. */ inline int gettimeofday(struct timeval* p, void* tz /* IGNORED */) { union { long long ns100; /*time since 1 Jan 1601 in 100ns units */ FILETIME ft; } now; GetSystemTimeAsFileTime(&(now.ft)); p->tv_usec = (long)((now.ns100 / 10LL) % 1000000LL); p->tv_sec = (long)((now.ns100 - (116444736000000000LL)) / 10000000LL); return 0; }
611
C++
.h
19
28.842105
74
0.687075
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,045
SC_Endian.h
supercollider_supercollider/include/common/SC_Endian.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* NOTE: This file should declare/define the following functions/macros: sc_htonl sc_htons sc_ntohl sc_ntohs */ #pragma once #if defined(__APPLE__) # include <machine/endian.h> #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) # include <sys/types.h> # include <netinet/in.h> #elif defined(_WIN32) # define LITTLE_ENDIAN 1234 # define BIG_ENDIAN 4321 # define BYTE_ORDER LITTLE_ENDIAN # define SC_NO_ENDIAN_FUNCTIONS #elif defined(__linux__) # include <endian.h> # include <netinet/in.h> #else # error cannot find endianess on this platform #endif #ifndef SC_NO_ENDIAN_FUNCTIONS static inline unsigned int sc_htonl(unsigned int arg) { return htonl(arg); } static inline unsigned short sc_htons(unsigned short arg) { return htons(arg); } static inline unsigned int sc_ntohl(unsigned int arg) { return ntohl(arg); } static inline unsigned short sc_ntohs(unsigned short arg) { return ntohs(arg); } #else static inline unsigned int sc_htonl(unsigned int x) { # if BYTE_ORDER == LITTLE_ENDIAN unsigned char* s = (unsigned char*)&x; return (unsigned int)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); # else return x; # endif } static inline unsigned short sc_htons(unsigned short x) { # if BYTE_ORDER == LITTLE_ENDIAN unsigned char* s = (unsigned char*)&x; return (unsigned short)(s[0] << 8 | s[1]); # else return x; # endif } static inline unsigned int sc_ntohl(unsigned int x) { return sc_htonl(x); } static inline unsigned short sc_ntohs(unsigned short x) { return sc_htons(x); } #endif #ifndef BYTE_ORDER # error BYTE_ORDER undefined, check __FILE__ #endif // BYTE_ORDER #ifndef BIG_ENDIAN # error BIG_ENDIAN undefined, check __FILE__ #endif // BIG_ENDIAN #ifndef LITTLE_ENDIAN # error LITTLE_ENDIAN undefined, check __FILE__ #endif // LITTLE_ENDIAN
2,774
C++
.h
73
35.205479
81
0.718305
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,046
SC_Alloca.h
supercollider_supercollider/include/common/SC_Alloca.h
/* SuperCollider real time audio synthesis system Copyright (c) 2011 Tim Blechmann. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #ifdef __linux__ # include <alloca.h> #elif defined(_WIN32) # include <malloc.h> # ifndef alloca # define alloca _alloca # endif #endif
1,044
C++
.h
25
38.2
81
0.742829
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,047
clz.h
supercollider_supercollider/include/common/clz.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* count leading zeroes function and those that can be derived from it */ #pragma once #include "SC_Types.h" #ifdef __MWERKS__ # define __PPC__ 1 # define __X86__ 0 // powerpc native count leading zeroes instruction: # define CLZ(x) ((int)__cntlzw((unsigned int)x)) #elif defined(__GNUC__) /* use gcc's builtins */ static __inline__ int32 CLZ(int32 arg) { if (arg) return __builtin_clz(arg); else return 32; } #elif defined(_MSC_VER) # include <intrin.h> # pragma intrinsic(_BitScanReverse) __forceinline static int32 CLZ(int32 arg) { unsigned long idx; if (_BitScanReverse(&idx, (unsigned long)arg)) { return (int32)(31 - idx); } return 32; } #elif defined(__ppc__) || defined(__powerpc__) || defined(__PPC__) static __inline__ int32 CLZ(int32 arg) { __asm__ volatile("cntlzw %0, %1" : "=r"(arg) : "r"(arg)); return arg; } #elif defined(__i386__) || defined(__x86_64__) static __inline__ int32 CLZ(int32 arg) { if (arg) { __asm__ volatile("bsrl %0, %0\nxorl $31, %0\n" : "=r"(arg) : "0"(arg)); } else { arg = 32; } return arg; } #elif defined(SC_IPHONE) static __inline__ int32 CLZ(int32 arg) { return __builtin_clz(arg); } #else # error "clz.h: Unsupported architecture" #endif // count trailing zeroes inline int32 CTZ(int32 x) { return 32 - CLZ(~x & (x - 1)); } // count leading ones inline int32 CLO(int32 x) { return CLZ(~x); } // count trailing ones inline int32 CTO(int32 x) { return 32 - CLZ(x & (~x - 1)); } // number of bits required to represent x. inline int32 NUMBITS(int32 x) { return 32 - CLZ(x); } // log2 of the next power of two greater than or equal to x. inline int32 LOG2CEIL(int32 x) { return 32 - CLZ(x - 1); } // is x a power of two inline bool ISPOWEROFTWO(int32 x) { return (x & (x - 1)) == 0; } // next power of two greater than or equal to x inline int32 NEXTPOWEROFTWO(int32 x) { return (int32)1L << LOG2CEIL(x); } // previous power of two less than or equal to x inline int32 PREVIOUSPOWEROFTWO(int32 x) { if (ISPOWEROFTWO(x)) return x; return (int32)1L << (LOG2CEIL(x) - 1); } // input a series of counting integers, outputs a series of gray codes . inline int32 GRAYCODE(int32 x) { return x ^ (x >> 1); } // find least significant bit inline int32 LSBit(int32 x) { return x & -x; } // find least significant bit position inline int32 LSBitPos(int32 x) { return CTZ(x & -x); } // find most significant bit position inline int32 MSBitPos(int32 x) { return 31 - CLZ(x); } // find most significant bit inline int32 MSBit(int32 x) { return (int32)1L << MSBitPos(x); } // count number of one bits inline uint32 ONES(uint32 x) { uint32 t; x = x - ((x >> 1) & 0x55555555); t = ((x >> 2) & 0x33333333); x = (x & 0x33333333) + t; x = (x + (x >> 4)) & 0x0F0F0F0F; x = x + (x << 8); x = x + (x << 16); return x >> 24; } // count number of zero bits inline uint32 ZEROES(uint32 x) { return ONES(~x); } // reverse bits in a word inline uint32 BitReverse(uint32 x) { x = ((x & 0xAAAAAAAA) >> 1) | ((x & 0x55555555) << 1); x = ((x & 0xCCCCCCCC) >> 2) | ((x & 0x33333333) << 2); x = ((x & 0xF0F0F0F0) >> 4) | ((x & 0x0F0F0F0F) << 4); x = ((x & 0xFF00FF00) >> 8) | ((x & 0x00FF00FF) << 8); return (x >> 16) | (x << 16); } // barrel shifts inline uint32 RotateRight(uint32 x, uint32 s) { s = s & 31; return (x << (32 - s)) | (x >> s); } inline uint32 RotateLeft(uint32 x, uint32 s) { s = s & 31; return (x >> (32 - s)) | (x << s); }
4,447
C++
.h
123
32.97561
81
0.646125
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,048
SC_StringBuffer.h
supercollider_supercollider/include/common/SC_StringBuffer.h
// emacs: -*- c++ -*- // file: SC_StringBuffer.h // copyright: 2003 stefan kersten <steve@k-hornz.de> // cvs: $Id$ // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 // USA #pragma once #include <stdarg.h> #include <stdlib.h> // ===================================================================== // SC_StringBuffer - Autogrowing string buffer. // ===================================================================== class SC_StringBuffer { public: SC_StringBuffer(size_t initialSize = 0); SC_StringBuffer(const SC_StringBuffer& other); ~SC_StringBuffer(); size_t getCapacity() const { return mCapacity; } size_t getSize() const { return mPtr - mData; } size_t getRemaining() const { return mCapacity - getSize(); } char* getData() const { return mData; } bool isEmpty() const { return getSize() == 0; } void finish() { append('\0'); } void reset() { mPtr = mData; } void append(const char* src, size_t len); void append(char c); void append(const char* str); void vappendf(const char* fmt, va_list vargs); void appendf(const char* fmt, ...); protected: enum { kGrowAlign = 256, kGrowMask = kGrowAlign - 1 }; void growBy(size_t request); private: size_t mCapacity; char* mPtr; char* mData; };
1,952
C++
.h
49
36.979592
75
0.650106
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,049
function_attributes.h
supercollider_supercollider/include/common/function_attributes.h
/* SuperCollider real time audio synthesis system Copyright (c) 2011 Tim Blechmann. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #ifdef __GNUC__ # ifdef _WIN32 # undef PURE # endif # define CONST_FUNCTION __attribute__((const)) # define PURE __attribute__((pure)) # define MALLOC __attribute__((malloc)) # define ASSUME_ALIGNED(Alignment) __attribute__((assume_aligned(Alignment))) # define HOT __attribute__((hot)) # define COLD __attribute__((cold)) # define FLATTEN __attribute__((flatten)) #endif #ifdef __clang__ # undef HOT # undef FLATTEN # undef ASSUME_ALIGNED #endif #ifdef __PATHCC__ # undef HOT # undef FLATTEN #endif #ifdef _MSC_VER # ifndef PURE # define PURE /*PURE*/ # endif # ifndef CONST_FUNCTION # define CONST_FUNCTION /*CONST_FUNCTION*/ # endif #endif #ifndef MALLOC # define MALLOC /*MALLOC*/ #endif #ifndef HOT # define HOT /*HOT*/ #endif #ifndef COLD # define COLD /*COLD*/ #endif #ifndef FLATTEN # define FLATTEN /*FLATTEN*/ #endif #ifndef ASSUME_ALIGNED # define ASSUME_ALIGNED(Alignment) /* assume aligned Alignment */ #endif // provide c99-style __restrict__ #if defined(__GNUC__) || defined(__CLANG__) // __restrict__ defined #else # define __restrict__ /* __restrict */ #endif // force inlining in release mode #ifndef NDEBUG # define force_inline inline #else # if defined(__GNUC__) # define force_inline inline __attribute__((always_inline)) # elif defined(_MSVER) # define force_inline __forceinline # else # define force_inline inline # endif #endif
2,357
C++
.h
78
28.25641
81
0.699911
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,050
SC_Types.h
supercollider_supercollider/include/common/SC_Types.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <stddef.h> #include <stdint.h> #if !defined(__cplusplus) # include <stdbool.h> #endif // __cplusplus typedef int SCErr; typedef int64_t int64; typedef uint64_t uint64; typedef int32_t int32; typedef uint32_t uint32; typedef int16_t int16; typedef uint16_t uint16; typedef int8_t int8; typedef uint8_t uint8; typedef float float32; typedef double float64; typedef union { uint32 u; int32 i; float32 f; } elem32; typedef union { uint64 u; int64 i; float64 f; } elem64; const unsigned int kSCNameLen = 8; const unsigned int kSCNameByteLen = 8 * sizeof(int32); // Do not use this. C casting is bad and causes many subtle issues. #ifdef __GXX_EXPERIMENTAL_CXX0X__ # define sc_typeof_cast(x) (decltype(x)) #elif defined(__GNUC__) # define sc_typeof_cast(x) (__typeof__(x)) #else # define sc_typeof_cast(x) /* (typeof(x)) */ #endif
1,769
C++
.h
53
30.566038
81
0.742353
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,051
SC_BoundsMacros.h
supercollider_supercollider/include/common/SC_BoundsMacros.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include <cstdlib> /* std::abs */ #include <cmath> /* std::abs */ #include <algorithm> #define sc_abs(a) std::abs(a) #define sc_max(a, b) (((a) > (b)) ? (a) : (b)) #define sc_min(a, b) (((a) < (b)) ? (a) : (b)) template <typename T, typename U, typename V> inline T sc_clip(T x, U lo, V hi) { return std::max(std::min(x, (T)hi), (T)lo); }
1,233
C++
.h
26
43.846154
81
0.705833
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,052
ErrorMessage.hpp
supercollider_supercollider/include/server/ErrorMessage.hpp
/** * \file ErrorMessage.hpp * * \brief Error message generation. * * This header provides generation of complex error messages and warnings for scsynth/supernova. * The messages currently provided are: * - API version mismatch * - API version not found * * $Author: Brian Heim $ * * \version 1.0 * * $Date: 2017-08-22 $ * * $Contact: brianlheim@gmail.com $ * * Created on: 2017-08-22 * * Original revision by Brian Heim, 2017-08-22 */ /* * Copyright (C) Brian Heim, 2017. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ // PLEASE NOTE: // libscsynth API might change across minor versions. // Always make sure, when using libscsynth as a shared library, that binary and headers come from the same minor // version. #pragma once #include <string> #include <cassert> #include <sstream> #include <map> namespace scsynth { namespace ErrorMessage { /// String used to indent all messages. std::string const indent = " "; /** \brief Formats a helpful multiline error string in the case of a plugin API mismatch. * * Extra lines are added to help clarify problems caused by the recent upgrade to API * version 3 in SuperCollider 3.9. * * \param utf8Filename the filename of the plugin represented as a UTF-8 string. * \param expectedVersion the API version of this server * \param actualVersion the API version reported by the plugin * \returns A multiline string with info about how to correct the error. */ std::string apiVersionMismatch(std::string const& utf8Filename, int const expectedVersion, int const actualVersion) { using namespace std; assert(expectedVersion != actualVersion); // both 1 and 2 were introduced in 3.6 static map<int, string> const scVersionForAPIVersion = { { 1, "3.6.0" }, { 2, "3.6.0" }, { 3, "3.9.0" } }; stringstream message; message << "ERROR: API version mismatch: " << utf8Filename << "\n"; try { // actualVersion+1: the version that broke compatibility string const& scVersion = scVersionForAPIVersion.at(actualVersion + 1); message << indent << "This plugin is not compatible with SuperCollider >=" << scVersion << "\n"; message << indent << "The plugin has not been loaded; please find or compile a newer version.\n"; } catch (std::out_of_range const& exception) { message << indent << "This plugin uses an unknown version of the interface.\n"; message << indent << "You may need to update SuperCollider in order to use it.\n"; } // if it looks like sc3-plugins, give specific info to help if (utf8Filename.find("SC3plugins") != string::npos) { message << indent << "Releases of sc3-plugins can be downloaded from " << "https://github.com/supercollider/sc3-plugins/releases\n"; } message << indent << "(Plugin's API version: " << actualVersion << ". Expected: " << expectedVersion << ")\n"; return message.str(); } /** \brief Formats a helpful error string in the case that the API version function wasn't found. * * \param utf8Filename the filename of the plugin represented as a UTF-8 string. */ std::string apiVersionNotFound(std::string const& utf8Filename) { return "ERROR: API version not found: " + utf8Filename + "\n" + indent + "This file may not be a SuperCollider plugin.\n"; } } // namespace ErrorMessage } // namespace scsynth
4,088
C++
.h
96
39.447917
117
0.710083
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
true
false
true
true
true
false
34,053
SC_OSC_Commands.h
supercollider_supercollider/include/server/SC_OSC_Commands.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ // PLEASE NOTE: // libscsynth API might change across minor versions. // Always make sure, when using libscsynth as a shared library, that binary and headers come from the same minor // version. #pragma once // command numbers: enum { cmd_none = 0, cmd_notify = 1, cmd_status = 2, cmd_quit = 3, cmd_cmd = 4, cmd_d_recv = 5, cmd_d_load = 6, cmd_d_loadDir = 7, cmd_d_freeAll = 8, cmd_s_new = 9, cmd_n_trace = 10, cmd_n_free = 11, cmd_n_run = 12, cmd_n_cmd = 13, cmd_n_map = 14, cmd_n_set = 15, cmd_n_setn = 16, cmd_n_fill = 17, cmd_n_before = 18, cmd_n_after = 19, cmd_u_cmd = 20, cmd_g_new = 21, cmd_g_head = 22, cmd_g_tail = 23, cmd_g_freeAll = 24, cmd_c_set = 25, cmd_c_setn = 26, cmd_c_fill = 27, cmd_b_alloc = 28, cmd_b_allocRead = 29, cmd_b_read = 30, cmd_b_write = 31, cmd_b_free = 32, cmd_b_close = 33, cmd_b_zero = 34, cmd_b_set = 35, cmd_b_setn = 36, cmd_b_fill = 37, cmd_b_gen = 38, cmd_dumpOSC = 39, cmd_c_get = 40, cmd_c_getn = 41, cmd_b_get = 42, cmd_b_getn = 43, cmd_s_get = 44, cmd_s_getn = 45, cmd_n_query = 46, cmd_b_query = 47, cmd_n_mapn = 48, cmd_s_noid = 49, cmd_g_deepFree = 50, cmd_clearSched = 51, cmd_sync = 52, cmd_d_free = 53, cmd_b_allocReadChannel = 54, cmd_b_readChannel = 55, cmd_g_dumpTree = 56, cmd_g_queryTree = 57, cmd_error = 58, cmd_s_newargs = 59, cmd_n_mapa = 60, cmd_n_mapan = 61, cmd_n_order = 62, cmd_p_new = 63, cmd_version = 64, cmd_rtMemoryStatus = 65, NUMBER_OF_COMMANDS = 66 };
2,592
C++
.h
91
23.593407
112
0.6293
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,054
SC_WorldOptions.h
supercollider_supercollider/include/server/SC_WorldOptions.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ // PLEASE NOTE: // libscsynth API might change across minor versions. // Always make sure, when using libscsynth as a shared library, that binary and headers come from the same minor // version. #pragma once #include <stdarg.h> #include "SC_Reply.h" #include "SC_Types.h" #include "SC_Export.h" typedef int (*PrintFunc)(const char* format, va_list ap); struct WorldOptions { WorldOptions() {} const char* mPassword = nullptr; uint32 mNumBuffers = 1024; uint32 mMaxLogins = 64; uint32 mMaxNodes = 1024; uint32 mMaxGraphDefs = 1024; uint32 mMaxWireBufs = 64; uint32 mNumAudioBusChannels = 1024; uint32 mNumInputBusChannels = 8; uint32 mNumOutputBusChannels = 8; uint32 mNumControlBusChannels = 16384; uint32 mBufLength = 64; uint32 mRealTimeMemorySize = 8192; // in kilobytes int mNumSharedControls = 0; float* mSharedControls = nullptr; bool mRealTime = true; bool mMemoryLocking = false; float mSafetyClipThreshold = 1.26; // ca. 2 dB const char* mNonRealTimeCmdFilename = nullptr; const char* mNonRealTimeInputFilename = nullptr; const char* mNonRealTimeOutputFilename = nullptr; const char* mNonRealTimeOutputHeaderFormat = nullptr; const char* mNonRealTimeOutputSampleFormat = nullptr; uint32 mPreferredSampleRate = 0; uint32 mNumRGens = 64; uint32 mPreferredHardwareBufferFrameSize = 0; uint32 mLoadGraphDefs = 1; const char* mInputStreamsEnabled = nullptr; const char* mOutputStreamsEnabled = nullptr; const char* mInDeviceName = nullptr; int mVerbosity = 0; bool mRendezvous = true; const char* mUGensPluginPath = nullptr; const char* mOutDeviceName = nullptr; const char* mRestrictedPath = nullptr; int mSharedMemoryID = 0; #ifdef SC_BELA uint32 mBelaAnalogInputChannels; uint32 mBelaAnalogOutputChannels; uint32 mBelaDigitalChannels; float mBelaHeadphoneLevel; float mBelaPgaGainLeft; float mBelaPgaGainRight; bool mBelaSpeakerMuted; float mBelaDacLevel; float mBelaAdcLevel; uint32 mBelaNumMuxChannels; uint32 mBelaPru; uint32 mBelaMaxScopeChannels; #endif // SC_BELA }; struct SndBuf; SCSYNTH_DLLEXPORT_C void SetPrintFunc(PrintFunc func); SCSYNTH_DLLEXPORT_C struct World* World_New(struct WorldOptions* inOptions); SCSYNTH_DLLEXPORT_C void World_Cleanup(struct World* inWorld, bool unload_plugins = false); SCSYNTH_DLLEXPORT_C void World_NonRealTimeSynthesis(struct World* inWorld, struct WorldOptions* inOptions); SCSYNTH_DLLEXPORT_C int World_OpenUDP(struct World* inWorld, const char* bindTo, int inPort); SCSYNTH_DLLEXPORT_C int World_OpenTCP(struct World* inWorld, const char* bindTo, int inPort, int inMaxConnections, int inBacklog); SCSYNTH_DLLEXPORT_C void World_WaitForQuit(struct World* inWorld, bool unload_plugins = false); SCSYNTH_DLLEXPORT_C bool World_SendPacket(struct World* inWorld, int inSize, char* inData, ReplyFunc inFunc); SCSYNTH_DLLEXPORT_C bool World_SendPacketWithContext(struct World* inWorld, int inSize, char* inData, ReplyFunc inFunc, void* inContext); SCSYNTH_DLLEXPORT_C int World_CopySndBuf(struct World* world, uint32 index, struct SndBuf* outBuf, bool onlyIfChanged, bool* didChange); SCSYNTH_DLLEXPORT_C int scprintf(const char* fmt, ...);
4,309
C++
.h
93
40.967742
119
0.74463
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
34,055
SC_LanguageConfig.hpp
supercollider_supercollider/lang/LangSource/SC_LanguageConfig.hpp
/* * Copyright 2003 Maurizio Umberto Puxeddu <umbpux@tin.it> * Copyright 2011 Jakob Leben * * This file is part of SuperCollider. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * */ #pragma once #include <vector> #include <string> #include <filesystem> class SC_LanguageConfig; extern SC_LanguageConfig* gLanguageConfig; extern const char* SCLANG_YAML_CONFIG_FILENAME; /** * \brief Language configuration settings. * * \c sclang uses a global instance of this class to manage knowledge of * compilation paths. * * \c SC_LanguageConfig also provides services for the global language * configuration file and the option for warning on function inlining. */ class SC_LanguageConfig { public: typedef std::filesystem::path Path; typedef std::vector<Path> DirVector; const DirVector& includedDirectories() const { return mIncludedDirectories; } const DirVector& excludedDirectories() const { return mExcludedDirectories; } const DirVector& defaultClassLibraryDirectories() const { return mDefaultClassLibraryDirectories; } void postExcludedDirectories(void) const; bool pathIsExcluded(const Path&) const; // true iff the path is in mExcludedDirectories bool addIncludedDirectory(const Path&); // false iff the path was already in the vector bool addExcludedDirectory(const Path&); bool removeIncludedDirectory(const Path&); // false iff there was nothing to remove bool removeExcludedDirectory(const Path&); bool forEachIncludedDirectory(bool (*)(const Path&)) const; bool getExcludeDefaultPaths() const { return mExcludeDefaultPaths; } void setExcludeDefaultPaths(bool value); static bool readLibraryConfigYAML(const Path&, bool standalone); static bool writeLibraryConfigYAML(const Path&); static void freeLibraryConfig(); static bool defaultLibraryConfig(bool standalone); static bool readLibraryConfig(bool standalone); static bool getPostInlineWarnings() { return gPostInlineWarnings; } static void setPostInlineWarnings(bool b) { gPostInlineWarnings = b; } static const Path& getConfigPath() { return gConfigFile; } static void setConfigPath(const Path& p) { gConfigFile = p; } private: static bool findPath(const DirVector&, const Path&); static bool addPath(DirVector&, const Path&); static bool removePath(DirVector&, const Path&); DirVector mIncludedDirectories; DirVector mExcludedDirectories; DirVector mDefaultClassLibraryDirectories; bool mExcludeDefaultPaths = true; static Path gConfigFile; static bool gPostInlineWarnings; };
3,285
C++
.h
74
41.067568
103
0.770964
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
34,056
PyrKernelProto.h
supercollider_supercollider/lang/LangSource/PyrKernelProto.h
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once PyrClass* newClassObj(PyrClass* classObjSuperClass, PyrSymbol* className, PyrSymbol* superClassName, int numInstVars, int numClassVars, int numConsts, int numInstMethods, int instFormat, int instFlags); void reallocClassObj(PyrClass* classobj, int numInstVars, int numClassVars, int numConsts, int numMethods, int instFormat, int instFlags); int numInstVars(PyrClass* classobj); int numClassVars(PyrClass* classobj); int numSuperInstVars(PyrClass* superclassobj); bool classFindInstVar(PyrClass* classobj, PyrSymbol* name, int* index); bool classFindClassVar(PyrClass** classobj, PyrSymbol* name, int* index); bool classFindConst(PyrClass** classobj, PyrSymbol* name, int* index); void buildClassTree(); void indexClassTree(PyrClass* classobj, int numSuperMethods); void postClassTree(PyrClass* classobj, int level); void setSelectorFlags(); void buildBigMethodMatrix(); bool funcFindArg(PyrBlock* func, PyrSymbol* name, int* index); bool funcFindVar(PyrBlock* func, PyrSymbol* name, int* index); void addMethod(PyrClass* classobj, PyrMethod* method); PyrMethod* classFindDirectMethod(PyrClass* classobj, PyrSymbol* name); PyrBlock* newPyrBlock(int flags); PyrMethod* newPyrMethod(); PyrClass* makeIntrinsicClass(PyrSymbol* className, PyrSymbol* superClassName, int numInstVars, int numClassVars); void addIntrinsicVar(PyrClass* classobj, const char* varName, PyrSlot* slot);
2,315
C++
.h
40
54.075
117
0.78382
supercollider/supercollider
5,424
745
915
GPL-3.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false