Compare commits
2 Commits
3c188efa60
...
974b2ac941
Author | SHA1 | Date | |
---|---|---|---|
|
974b2ac941 | ||
|
12189efe88 |
@ -1,9 +1,9 @@
|
||||
#if defined(STFU_MAIN) && !defined(STFU_TROJKA)
|
||||
#define STFU_TROJKA
|
||||
|
||||
#include "../../phaser.c"
|
||||
#include "../../envelope.c"
|
||||
#include "../../config.h"
|
||||
#include "../../envelope.c"
|
||||
#include "../../phaser.c"
|
||||
|
||||
#define STFU_TROJKA_OP_COUNT 3
|
||||
|
||||
@ -23,19 +23,25 @@ struct stfu_trojka {
|
||||
float left_feedback, right_feedback;
|
||||
};
|
||||
|
||||
static struct stfu_trojka stfu_sample_trojka(struct stfu_trojka synth, float buffer[static 2]) {
|
||||
static struct stfu_trojka stfu_sample_trojka(struct stfu_trojka synth,
|
||||
float buffer[static 2]) {
|
||||
for (int i = 0; i < STFU_TROJKA_OP_COUNT; ++i) {
|
||||
synth.phasers[i] = stfu_pump_phaser(synth.phasers[i]);
|
||||
synth.envelopes[i] = stfu_pump_envelope(synth.envelopes[i]);
|
||||
}
|
||||
|
||||
float left_modulator_stack = synth.envelopes[1].v * synth.indices[1] * sinf(synth.phasers[1].v + synth.envelopes[0].v * synth.indices[0] * sinf(synth.phasers[0].v)) + synth.left_feedback * synth.feedback_gain;
|
||||
float left_modulator_stack =
|
||||
synth.envelopes[1].v * synth.indices[1] *
|
||||
sinf(synth.phasers[1].v + synth.envelopes[0].v * synth.indices[0] *
|
||||
sinf(synth.phasers[0].v)) +
|
||||
synth.left_feedback * synth.feedback_gain;
|
||||
float right_modulator_stack = left_modulator_stack;
|
||||
|
||||
synth.left_feedback = left_modulator_stack;
|
||||
synth.right_feedback = right_modulator_stack;
|
||||
|
||||
float left = synth.envelopes[2].v * sinf(synth.phasers[2].v + left_modulator_stack);
|
||||
float left =
|
||||
synth.envelopes[2].v * sinf(synth.phasers[2].v + left_modulator_stack);
|
||||
float right =
|
||||
synth.envelopes[2].v * sinf(synth.phasers[2].v + right_modulator_stack);
|
||||
|
||||
@ -45,9 +51,11 @@ static struct stfu_trojka stfu_sample_trojka(struct stfu_trojka synth, float buf
|
||||
return synth;
|
||||
}
|
||||
|
||||
static struct stfu_trojka stfu_press_trojka(struct stfu_trojka synth, float key_frequency) {
|
||||
static struct stfu_trojka stfu_press_trojka(struct stfu_trojka synth,
|
||||
float key_frequency) {
|
||||
for (int i = 0; i < STFU_TROJKA_OP_COUNT; ++i) {
|
||||
synth.phasers[i] = stfu_set_phaser_frequency(synth.phasers[i], key_frequency * synth.freq_scales[i]);
|
||||
synth.phasers[i] = stfu_set_phaser_frequency(
|
||||
synth.phasers[i], key_frequency * synth.freq_scales[i]);
|
||||
synth.envelopes[i] = stfu_trigger_envelope(synth.envelopes[i]);
|
||||
}
|
||||
|
||||
|
26
Source/Maker/Widgets/border.c
Normal file
26
Source/Maker/Widgets/border.c
Normal file
@ -0,0 +1,26 @@
|
||||
#if defined(STFU_MAIN) && !defined(STFU_BORDER)
|
||||
#define STFU_BORDER
|
||||
|
||||
struct stfu_border {
|
||||
float x, y;
|
||||
float width, height;
|
||||
float r, g, b;
|
||||
};
|
||||
|
||||
static void stfu_draw_border(struct stfu_border border) {
|
||||
{
|
||||
sgl_begin_lines();
|
||||
sgl_c3f(border.r, border.g, border.b);
|
||||
sgl_v2f(border.x, border.y);
|
||||
sgl_v2f(border.x + border.width, border.y);
|
||||
sgl_v2f(border.x + border.width, border.y);
|
||||
sgl_v2f(border.x + border.width, border.y + border.height);
|
||||
sgl_v2f(border.x + border.width, border.y + border.height);
|
||||
sgl_v2f(border.x, border.y + border.height);
|
||||
sgl_v2f(border.x, border.y + border.height);
|
||||
sgl_v2f(border.x, border.y);
|
||||
sgl_end();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
62
Source/Maker/Widgets/slider.c
Normal file
62
Source/Maker/Widgets/slider.c
Normal file
@ -0,0 +1,62 @@
|
||||
#if defined(STFU_MAIN) && !defined(STFU_SLIDER)
|
||||
#define STFU_SLIDER
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../config.h"
|
||||
#include "border.c"
|
||||
|
||||
#define STFU_SLIDER_WIDTH 16
|
||||
|
||||
struct stfu_slider {
|
||||
float x, y;
|
||||
float width, height;
|
||||
float r, g, b;
|
||||
float min, max, cur;
|
||||
bool integeric;
|
||||
};
|
||||
|
||||
static void stfu_draw_slider(struct stfu_slider slider) {
|
||||
/* Border */
|
||||
stfu_draw_border((struct stfu_border){
|
||||
.x = slider.x,
|
||||
.y = slider.y,
|
||||
.width = slider.width,
|
||||
.height = slider.height,
|
||||
.r = slider.r,
|
||||
.g = slider.g,
|
||||
.b = slider.b,
|
||||
});
|
||||
|
||||
/* Slider */
|
||||
{
|
||||
float progress = (slider.cur - slider.min) / (slider.max - slider.min);
|
||||
float x = slider.x + (slider.width - STFU_SLIDER_WIDTH) * progress;
|
||||
|
||||
sgl_begin_quads();
|
||||
sgl_c3f(slider.r, slider.g, slider.b);
|
||||
sgl_v2f(x, slider.y);
|
||||
sgl_v2f(x + STFU_SLIDER_WIDTH, slider.y);
|
||||
sgl_v2f(x + STFU_SLIDER_WIDTH, slider.y + slider.height);
|
||||
sgl_v2f(x, slider.y + slider.height);
|
||||
sgl_end();
|
||||
}
|
||||
}
|
||||
|
||||
static struct stfu_slider stfu_press_slider(struct stfu_slider slider, float x,
|
||||
float y) {
|
||||
if (x < slider.x || x > slider.x + slider.width)
|
||||
return slider;
|
||||
if (y < slider.y || y > slider.y + slider.height)
|
||||
return slider;
|
||||
|
||||
slider.cur = slider.min +
|
||||
((x - slider.x) / (slider.width)) * (slider.max - slider.min);
|
||||
|
||||
if (slider.integeric)
|
||||
slider.cur = floorf(slider.cur);
|
||||
|
||||
return slider;
|
||||
}
|
||||
|
||||
#endif
|
3
Source/Maker/config.h
Normal file
3
Source/Maker/config.h
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
#define STFU_MAKER_WINDOW_WIDTH 480
|
||||
#define STFU_MAKER_WINDOW_HEIGHT 640
|
@ -1,311 +0,0 @@
|
||||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
# define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
# define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
/*
|
||||
* To support platform where unsigned long cannot be used interchangeably with
|
||||
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
|
||||
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
|
||||
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
|
||||
* unsigned long long or similar (this results in different C++ name mangling).
|
||||
* To avoid changes for existing platforms, we restrict usage of intptr_t to
|
||||
* platforms where the size of a pointer is larger than the size of long.
|
||||
*/
|
||||
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
|
||||
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
|
||||
#define KHRONOS_USE_INTPTR_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef KHRONOS_USE_INTPTR_T
|
||||
typedef intptr_t khronos_intptr_t;
|
||||
typedef uintptr_t khronos_uintptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -5,17 +5,20 @@
|
||||
#define SOKOL_IMPL
|
||||
#include "sokol_app.h"
|
||||
#include "sokol_audio.h"
|
||||
#include "sokol_gfx.h"
|
||||
#include "sokol_gl.h"
|
||||
#include "sokol_glue.h"
|
||||
#include "sokol_log.h"
|
||||
|
||||
#include "glad/src/glad.c"
|
||||
|
||||
#define STFU_MAIN
|
||||
#include "../config.h"
|
||||
#include "../envelope.c"
|
||||
#include "../oscillators.c"
|
||||
#include "../phaser.c"
|
||||
#include "config.h"
|
||||
|
||||
#include "../Instruments/Trojka/trojka.c"
|
||||
#include "Widgets/slider.c"
|
||||
|
||||
static struct stfu_trojka synth = {0};
|
||||
|
||||
@ -29,6 +32,14 @@ static unsigned int crossfade_frames_left = 0;
|
||||
// 1.0 is with A at 440
|
||||
static float octave = 0.5;
|
||||
|
||||
static struct stfu_slider feedback_slider = {.x = 16,
|
||||
.y = 16,
|
||||
.width = 120,
|
||||
.height = 16,
|
||||
.min = 0,
|
||||
.max = 1,
|
||||
.cur = 0.25};
|
||||
|
||||
static void stream(float *buffer, int num_frames, int num_channels) {
|
||||
/* Fade away */
|
||||
for (size_t i = 0; crossfade_frames_left > 0;
|
||||
@ -45,19 +56,28 @@ static void stream(float *buffer, int num_frames, int num_channels) {
|
||||
buffer[0] = crossfade_ring[crossfade_ring_needle % CROSSFADE_RING_RANGE];
|
||||
buffer[1] =
|
||||
crossfade_ring[(crossfade_ring_needle + 1) % CROSSFADE_RING_RANGE];
|
||||
synth = stfu_sample_trojka(synth, &crossfade_ring[crossfade_ring_needle % CROSSFADE_RING_RANGE]);
|
||||
synth = stfu_sample_trojka(
|
||||
synth, &crossfade_ring[crossfade_ring_needle % CROSSFADE_RING_RANGE]);
|
||||
buffer = &buffer[2];
|
||||
crossfade_ring_needle += 2;
|
||||
}
|
||||
}
|
||||
|
||||
static void init(void) {
|
||||
gladLoadGL();
|
||||
|
||||
saudio_setup(&(saudio_desc){
|
||||
.sample_rate = STFU_AUDIO_FRAME_RATE,
|
||||
.num_channels = STFU_AUDIO_CHANNEL_COUNT,
|
||||
// .stream_cb = stream,
|
||||
.logger.func = slog_func,
|
||||
});
|
||||
|
||||
sg_setup(&(sg_desc){
|
||||
.environment = sglue_environment(),
|
||||
.logger.func = slog_func,
|
||||
});
|
||||
|
||||
sgl_setup(&(sgl_desc_t){
|
||||
.logger.func = slog_func,
|
||||
});
|
||||
|
||||
synth.freq_scales[0] = 1.0;
|
||||
@ -83,6 +103,16 @@ static void cleanup(void) { saudio_shutdown(); }
|
||||
|
||||
static void event(const sapp_event *e) {
|
||||
switch (e->type) {
|
||||
case SAPP_EVENTTYPE_MOUSE_DOWN: {
|
||||
if (e->mouse_button != SAPP_MOUSEBUTTON_LEFT)
|
||||
break;
|
||||
|
||||
feedback_slider =
|
||||
stfu_press_slider(feedback_slider, e->mouse_x, e->mouse_y);
|
||||
synth.feedback_gain = feedback_slider.cur;
|
||||
|
||||
break;
|
||||
}
|
||||
case SAPP_EVENTTYPE_KEY_DOWN: {
|
||||
if (e->key_repeat)
|
||||
break;
|
||||
@ -203,12 +233,23 @@ static void frame(void) {
|
||||
saudio_push(buffer, now);
|
||||
frames -= now;
|
||||
}
|
||||
|
||||
sg_pass pass = {.swapchain = sglue_swapchain()};
|
||||
sg_begin_pass(&pass);
|
||||
sgl_load_default_pipeline();
|
||||
sgl_load_identity();
|
||||
sgl_ortho(0, STFU_MAKER_WINDOW_WIDTH, STFU_MAKER_WINDOW_HEIGHT, 0, -1, 1);
|
||||
stfu_draw_slider(feedback_slider);
|
||||
// sgl_pop_matrix();
|
||||
sgl_draw();
|
||||
sg_end_pass();
|
||||
sg_commit();
|
||||
}
|
||||
|
||||
sapp_desc sokol_main(int argc, char *argv[]) {
|
||||
return (sapp_desc){
|
||||
.width = 640,
|
||||
.height = 480,
|
||||
.width = STFU_MAKER_WINDOW_WIDTH,
|
||||
.height = STFU_MAKER_WINDOW_HEIGHT,
|
||||
.init_cb = init,
|
||||
.frame_cb = frame,
|
||||
.cleanup_cb = cleanup,
|
||||
|
1790
Source/Maker/sokol_fontstash.h
Normal file
1790
Source/Maker/sokol_fontstash.h
Normal file
File diff suppressed because it is too large
Load Diff
19454
Source/Maker/sokol_gfx.h
Normal file
19454
Source/Maker/sokol_gfx.h
Normal file
File diff suppressed because it is too large
Load Diff
4259
Source/Maker/sokol_gl.h
Normal file
4259
Source/Maker/sokol_gl.h
Normal file
File diff suppressed because it is too large
Load Diff
162
Source/Maker/sokol_glue.h
Normal file
162
Source/Maker/sokol_glue.h
Normal file
@ -0,0 +1,162 @@
|
||||
#if defined(SOKOL_IMPL) && !defined(SOKOL_GLUE_IMPL)
|
||||
#define SOKOL_GLUE_IMPL
|
||||
#endif
|
||||
#ifndef SOKOL_GLUE_INCLUDED
|
||||
/*
|
||||
sokol_glue.h -- glue helper functions for sokol headers
|
||||
|
||||
Project URL: https://github.com/floooh/sokol
|
||||
|
||||
Do this:
|
||||
#define SOKOL_IMPL or
|
||||
#define SOKOL_GLUE_IMPL
|
||||
before you include this file in *one* C or C++ file to create the
|
||||
implementation.
|
||||
|
||||
...optionally provide the following macros to override defaults:
|
||||
|
||||
SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
|
||||
SOKOL_GLUE_API_DECL - public function declaration prefix (default: extern)
|
||||
SOKOL_API_DECL - same as SOKOL_GLUE_API_DECL
|
||||
SOKOL_API_IMPL - public function implementation prefix (default: -)
|
||||
|
||||
If sokol_glue.h is compiled as a DLL, define the following before
|
||||
including the declaration or implementation:
|
||||
|
||||
SOKOL_DLL
|
||||
|
||||
On Windows, SOKOL_DLL will define SOKOL_GLUE_API_DECL as __declspec(dllexport)
|
||||
or __declspec(dllimport) as needed.
|
||||
|
||||
OVERVIEW
|
||||
========
|
||||
sokol_glue.h provides glue helper functions between sokol_gfx.h and sokol_app.h,
|
||||
so that sokol_gfx.h doesn't need to depend on sokol_app.h but can be
|
||||
used with different window system glue libraries.
|
||||
|
||||
PROVIDED FUNCTIONS
|
||||
==================
|
||||
|
||||
sg_environment sglue_environment(void)
|
||||
|
||||
Returns an sg_environment struct initialized by calling sokol_app.h
|
||||
functions. Use this in the sg_setup() call like this:
|
||||
|
||||
sg_setup(&(sg_desc){
|
||||
.environment = sglue_environment(),
|
||||
...
|
||||
});
|
||||
|
||||
sg_swapchain sglue_swapchain(void)
|
||||
|
||||
Returns an sg_swapchain struct initialized by calling sokol_app.h
|
||||
functions. Use this in sg_begin_pass() for a 'swapchain pass' like
|
||||
this:
|
||||
|
||||
sg_begin_pass(&(sg_pass){ .swapchain = sglue_swapchain(), ... });
|
||||
|
||||
LICENSE
|
||||
=======
|
||||
zlib/libpng license
|
||||
|
||||
Copyright (c) 2018 Andre Weissflog
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the
|
||||
use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software in a
|
||||
product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
#define SOKOL_GLUE_INCLUDED
|
||||
|
||||
#if defined(SOKOL_API_DECL) && !defined(SOKOL_GLUE_API_DECL)
|
||||
#define SOKOL_GLUE_API_DECL SOKOL_API_DECL
|
||||
#endif
|
||||
#ifndef SOKOL_GLUE_API_DECL
|
||||
#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_GLUE_IMPL)
|
||||
#define SOKOL_GLUE_API_DECL __declspec(dllexport)
|
||||
#elif defined(_WIN32) && defined(SOKOL_DLL)
|
||||
#define SOKOL_GLUE_API_DECL __declspec(dllimport)
|
||||
#else
|
||||
#define SOKOL_GLUE_API_DECL extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SOKOL_GFX_INCLUDED
|
||||
#error "Please include sokol_gfx.h before sokol_glue.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
SOKOL_GLUE_API_DECL sg_environment sglue_environment(void);
|
||||
SOKOL_GLUE_API_DECL sg_swapchain sglue_swapchain(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
#endif /* SOKOL_GLUE_INCLUDED */
|
||||
|
||||
/*-- IMPLEMENTATION ----------------------------------------------------------*/
|
||||
#ifdef SOKOL_GLUE_IMPL
|
||||
#define SOKOL_GLUE_IMPL_INCLUDED (1)
|
||||
#include <string.h> /* memset */
|
||||
|
||||
#ifndef SOKOL_APP_INCLUDED
|
||||
#error "Please include sokol_app.h before the sokol_glue.h implementation"
|
||||
#endif
|
||||
|
||||
#ifndef SOKOL_API_IMPL
|
||||
#define SOKOL_API_IMPL
|
||||
#endif
|
||||
|
||||
|
||||
SOKOL_API_IMPL sg_environment sglue_environment(void) {
|
||||
sg_environment env;
|
||||
memset(&env, 0, sizeof(env));
|
||||
env.defaults.color_format = (sg_pixel_format) sapp_color_format();
|
||||
env.defaults.depth_format = (sg_pixel_format) sapp_depth_format();
|
||||
env.defaults.sample_count = sapp_sample_count();
|
||||
env.metal.device = sapp_metal_get_device();
|
||||
env.d3d11.device = sapp_d3d11_get_device();
|
||||
env.d3d11.device_context = sapp_d3d11_get_device_context();
|
||||
env.wgpu.device = sapp_wgpu_get_device();
|
||||
return env;
|
||||
}
|
||||
|
||||
SOKOL_API_IMPL sg_swapchain sglue_swapchain(void) {
|
||||
sg_swapchain swapchain;
|
||||
memset(&swapchain, 0, sizeof(swapchain));
|
||||
swapchain.width = sapp_width();
|
||||
swapchain.height = sapp_height();
|
||||
swapchain.sample_count = sapp_sample_count();
|
||||
swapchain.color_format = (sg_pixel_format)sapp_color_format();
|
||||
swapchain.depth_format = (sg_pixel_format)sapp_depth_format();
|
||||
swapchain.metal.current_drawable = sapp_metal_get_current_drawable();
|
||||
swapchain.metal.depth_stencil_texture = sapp_metal_get_depth_stencil_texture();
|
||||
swapchain.metal.msaa_color_texture = sapp_metal_get_msaa_color_texture();
|
||||
swapchain.d3d11.render_view = sapp_d3d11_get_render_view();
|
||||
swapchain.d3d11.resolve_view = sapp_d3d11_get_resolve_view();
|
||||
swapchain.d3d11.depth_stencil_view = sapp_d3d11_get_depth_stencil_view();
|
||||
swapchain.wgpu.render_view = sapp_wgpu_get_render_view();
|
||||
swapchain.wgpu.resolve_view = sapp_wgpu_get_resolve_view();
|
||||
swapchain.wgpu.depth_stencil_view = sapp_wgpu_get_depth_stencil_view();
|
||||
swapchain.gl.framebuffer = sapp_gl_get_framebuffer();
|
||||
return swapchain;
|
||||
}
|
||||
|
||||
#endif /* SOKOL_GLUE_IMPL */
|
@ -17,20 +17,16 @@
|
||||
static const float STFU_SCALE[12] = {
|
||||
STFU_C4_FREQUENCY,
|
||||
STFU_C4_FREQUENCY *STFU_NOTE_UPSCALE_FACTOR,
|
||||
STFU_C4_FREQUENCY * STFU_NOTE_UPSCALE_FACTOR *
|
||||
STFU_NOTE_UPSCALE_FACTOR,
|
||||
STFU_C4_FREQUENCY * STFU_NOTE_UPSCALE_FACTOR *
|
||||
STFU_NOTE_UPSCALE_FACTOR * STFU_NOTE_UPSCALE_FACTOR,
|
||||
STFU_C4_FREQUENCY * STFU_NOTE_UPSCALE_FACTOR *
|
||||
STFU_NOTE_UPSCALE_FACTOR * STFU_NOTE_UPSCALE_FACTOR *
|
||||
STFU_NOTE_UPSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY * STFU_NOTE_DOWNSCALE_FACTOR *
|
||||
STFU_NOTE_DOWNSCALE_FACTOR * STFU_NOTE_DOWNSCALE_FACTOR *
|
||||
STFU_NOTE_DOWNSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY * STFU_NOTE_DOWNSCALE_FACTOR *
|
||||
STFU_NOTE_DOWNSCALE_FACTOR * STFU_NOTE_DOWNSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY * STFU_NOTE_DOWNSCALE_FACTOR *
|
||||
STFU_NOTE_DOWNSCALE_FACTOR,
|
||||
STFU_C4_FREQUENCY *STFU_NOTE_UPSCALE_FACTOR *STFU_NOTE_UPSCALE_FACTOR,
|
||||
STFU_C4_FREQUENCY *STFU_NOTE_UPSCALE_FACTOR *STFU_NOTE_UPSCALE_FACTOR
|
||||
*STFU_NOTE_UPSCALE_FACTOR,
|
||||
STFU_C4_FREQUENCY *STFU_NOTE_UPSCALE_FACTOR *STFU_NOTE_UPSCALE_FACTOR
|
||||
*STFU_NOTE_UPSCALE_FACTOR *STFU_NOTE_UPSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY *STFU_NOTE_DOWNSCALE_FACTOR *STFU_NOTE_DOWNSCALE_FACTOR
|
||||
*STFU_NOTE_DOWNSCALE_FACTOR *STFU_NOTE_DOWNSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY *STFU_NOTE_DOWNSCALE_FACTOR *STFU_NOTE_DOWNSCALE_FACTOR
|
||||
*STFU_NOTE_DOWNSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY *STFU_NOTE_DOWNSCALE_FACTOR *STFU_NOTE_DOWNSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY *STFU_NOTE_DOWNSCALE_FACTOR,
|
||||
STFU_A4_FREQUENCY,
|
||||
STFU_A4_FREQUENCY *STFU_NOTE_UPSCALE_FACTOR,
|
||||
|
Loading…
Reference in New Issue
Block a user