bool ChannelInternalState::RealChannelPlay() { assert(is_real()); if (!sound_source_->Play(channel_id_, SoundHandleLoops(handle_))) { SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Could not play sound %s\n", Mix_GetError()); return false; } return true; }
Node<T>* min_element(Node<T>* node) { if(is_real(node)) { node = min_node(node, min_element(node->left)); node = min_node(node, min_element(node->right)); } return node; }
/*GRAMMAR GET TYPES*/ struct expression_data_t* get_expr_expr_data(struct expression_t *expr, struct attribute_table_t* attr_hash_table, struct function_declaration_t *statement_func, int line_number) { if(expr->expr != NULL && expr->expr->type != NULL) { return expr->expr; /*we already have type*/ } else if(expr->se2 == NULL) /* if se2 is null then the expression type is the type of se1 */ { return get_simple_expr_expr_data(expr->se1, attr_hash_table, statement_func, line_number); } else { struct expression_data_t *se1_data = get_simple_expr_expr_data(expr->se1, attr_hash_table, statement_func, line_number); struct expression_data_t *se2_data = get_simple_expr_expr_data(expr->se2, attr_hash_table, statement_func, line_number); switch(expr->relop) { case RELOP_EQUAL: case RELOP_NOTEQUAL: if(strcmp(se1_data->type, se2_data->type)) { error_type_mismatch(line_number, se1_data->type, se2_data->type); } break; case RELOP_LT: case RELOP_GT: case RELOP_LE: case RELOP_GE: if( !is_integer(se1_data->type) && !is_real(se1_data->type) ) { error_datatype_is_not(line_number, se1_data->type, "real or integer"); } if( !is_integer(se2_data->type) && !is_real(se2_data->type) ) { error_datatype_is_not(line_number, se2_data->type, "real or integer"); } break; } return set_expression_data(EXPRESSION_DATA_BOOLEAN, "boolean"); } }
void ChannelInternalState::UpdateState() { switch (channel_state_) { case kChannelStatePaused: case kChannelStateStopped: { break; } case kChannelStatePlaying: if (is_real() && !RealChannelPlaying()) { channel_state_ = kChannelStateStopped; } break; case kChannelStateFadingOut: { if (!is_real() || !RealChannelPlaying()) { channel_state_ = kChannelStateStopped; } break; } default: { assert(false); } } }
bool ChannelInternalState::RealChannelPlaying() const { assert(is_real()); if (IsStream()) { #ifdef PINDROP_MULTISTREAM return Mix_PlayingMusicCh(channel_id_) != 0; #else return Mix_PlayingMusic() != 0 && channel_id_ == GetMusicChannel(); #endif // PINDROP_MULTISTREAM } else { return Mix_Playing(channel_id_) != 0; } }
void ChannelInternalState::RealChannelResume() { assert(is_real()); if (IsStream()) { #ifdef PINDROP_MULTISTREAM Mix_ResumeMusicCh(channel_id_); #else Mix_ResumeMusic(); #endif // PINDROP_MULTISTREAM } else { Mix_Resume(channel_id_); } }
bool ChannelInternalState::RealChannelPaused() const { assert(is_real()); if (IsStream()) { #ifdef PINDROP_MULTISTREAM return Mix_PausedMusicCh(channel_id_) != 0; #else return Mix_PausedMusic() != 0; #endif // PINDROP_MULTISTREAM } else { return Mix_Paused(channel_id_) != 0; } }
pgsOperand pgsNumber::pgs_plus(const pgsVariable &rhs) const { if (rhs.is_number()) { return pnew pgsNumber(pgsMapm::pgs_mapm_str(num(m_data) + num(rhs.value())), is_real() || rhs.is_real()); } else { throw pgsArithmeticException(m_data, rhs.value()); } }
void ChannelInternalState::SetPan(const mathfu::Vector<float, 2>& pan) { if (!is_real()) { return; } static const Uint8 kMaxPanValue = 255; // This formula is explained in the following paper: // http://www.rs-met.com/documents/tutorials/PanRules.pdf float p = static_cast<float>(M_PI) * (pan.x() + 1.0f) / 4.0f; Uint8 left = static_cast<Uint8>(cos(p) * kMaxPanValue); Uint8 right = static_cast<Uint8>(sin(p) * kMaxPanValue); Mix_SetPanning(channel_id_, left, right); }
void ChannelInternalState::SetRealChannelGain(const float gain) { assert(is_real()); int mix_volume = static_cast<int>(gain * MIX_MAX_VOLUME); if (IsStream()) { #ifdef PINDROP_MULTISTREAM Mix_VolumeMusicCh(channel_id_, mix_volume); #else Mix_VolumeMusic(mix_volume); #endif // PINDROP_MULTISTREAM } else { Mix_Volume(channel_id_, mix_volume); } }
pgsOperand pgsNumber::pgs_over(const pgsVariable &rhs) const { if (rhs.is_number()) { if (num(rhs.value()) != 0) { if (is_real() || rhs.is_real()) return pnew pgsNumber(pgsMapm::pgs_mapm_str(num(m_data) / num(rhs.value())), is_real() || rhs.is_real()); else return pnew pgsNumber(pgsMapm::pgs_mapm_str(num(m_data) .div(num(rhs.value()))), is_real() || rhs.is_real()); } else { throw pgsArithmeticException(m_data, rhs.value()); } } else { throw pgsArithmeticException(m_data, rhs.value()); } }
Node<T>* min_node(Node<T>* node) { assert(is_bst(node)); if(is_nil(node)) { return node; } while(is_real(node->left)) { node = node->left; } return node; }
float ChannelInternalState::RealChannelGain() const { assert(is_real()); // Special value to query volume rather than set volume. static const int kQueryVolume = -1; int volume; if (IsStream()) { #ifdef PINDROP_MULTISTREAM volume = Mix_VolumeMusicCh(channel_id_, kQueryVolume); #else volume = Mix_VolumeMusic(kQueryVolume); #endif // PINDROP_MULTISTREAM } else { volume = Mix_Volume(channel_id_, kQueryVolume); } return volume / static_cast<float>(MIX_MAX_VOLUME); }
void ChannelInternalState::RealChannelHalt() { assert(is_real()); // If this channel loops, we may want to resume it later. If this is a one // shot sound that does not loop, just halt it now. // TODO(amablue): What we really want is for one shot sounds to change to the // stopped state when the sound would have finished. However, SDL mixer does // not give good visibility into the length of loaded audio, which makes this // difficult. b/20697050 if (!SoundHandleLoops(handle_)) { channel_state_ = kChannelStateStopped; } if (IsStream()) { #ifdef PINDROP_MULTISTREAM Mix_HaltMusicCh(channel_id_); #else Mix_HaltMusic(); #endif // PINDROP_MULTISTREAM } else { Mix_HaltChannel(channel_id_); } }
bool MCVariableValue::coerce_to_real(MCExecPoint& ep) { assert(!is_real()); if (is_empty()) { assign_real(0.0); return true; } if (is_string()) { if (MCU_stor8(MCString(strnum . svalue . string, strnum . svalue . length), strnum . nvalue, ep . getconvertoctals()) != True) return false; set_type(VF_BOTH); return true; } assert(is_array()); assign_real(0.0); return true; }
float strtof(FAR const char *str, FAR char **endptr) { float number; int exponent; int negative; FAR char *p = (FAR char *) str; float p10; int n; int num_digits; int num_decimals; const float infinite = 1.0F/0.0F; /* Skip leading whitespace */ while (isspace(*p)) { p++; } /* Handle optional sign */ negative = 0; switch (*p) { case '-': negative = 1; /* Fall through to increment position */ case '+': p++; default: break; } number = 0.0F; exponent = 0; num_digits = 0; num_decimals = 0; /* Process string of digits */ while (isdigit(*p)) { number = number * 10.0F + (float)(*p - '0'); p++; num_digits++; } /* Process decimal part */ if (*p == '.') { p++; while (isdigit(*p)) { number = number * 10.0F + (float)(*p - '0'); p++; num_digits++; num_decimals++; } exponent -= num_decimals; } if (num_digits == 0) { set_errno(ERANGE); number = 0.0F; goto errout; } /* Correct for sign */ if (negative) { number = -number; } /* Process an exponent string */ if (*p == 'e' || *p == 'E') { /* Handle optional sign */ negative = 0; switch (*++p) { case '-': negative = 1; /* Fall through to increment pos */ case '+': p++; default: break; } /* Process string of digits */ n = 0; while (isdigit(*p)) { n = n * 10 + (*p - '0'); p++; } if (negative) { exponent -= n; } else { exponent += n; } } if (exponent < __FLT_MIN_EXP__ || exponent > __FLT_MAX_EXP__) { set_errno(ERANGE); number = infinite; goto errout; } /* Scale the result */ p10 = 10.0F; n = exponent; if (n < 0) { n = -n; } while (n) { if (n & 1) { if (exponent < 0) { number /= p10; } else { number *= p10; } } n >>= 1; p10 *= p10; } if (!is_real(number)) { set_errno(ERANGE); } errout: if (endptr) { *endptr = p; } return number; }
double_t strtod(const char *str, char **endptr) { double_t number; int exponent; int negative; char *p = (char *) str; double p10; int n; int num_digits; int num_decimals; const double_t infinite = 1.0/0.0; /* Skip leading whitespace */ while (isspace(*p)) { p++; } /* Handle optional sign */ negative = 0; switch (*p) { case '-': negative = 1; /* Fall through to increment position */ case '+': p++; } number = 0.; exponent = 0; num_digits = 0; num_decimals = 0; /* Process string of digits */ while (isdigit(*p)) { number = number * 10. + (*p - '0'); p++; num_digits++; } /* Process decimal part */ if (*p == '.') { p++; while (isdigit(*p)) { number = number * 10. + (*p - '0'); p++; num_digits++; num_decimals++; } exponent -= num_decimals; } if (num_digits == 0) { set_errno(ERANGE); return 0.0; } /* Correct for sign */ if (negative) { number = -number; } /* Process an exponent string */ if (*p == 'e' || *p == 'E') { /* Handle optional sign */ negative = 0; switch(*++p) { case '-': negative = 1; /* Fall through to increment pos */ case '+': p++; } /* Process string of digits */ n = 0; while (isdigit(*p)) { n = n * 10 + (*p - '0'); p++; } if (negative) { exponent -= n; } else { exponent += n; } } if (exponent < __DBL_MIN_EXP__ || exponent > __DBL_MAX_EXP__) { set_errno(ERANGE); return infinite; } /* Scale the result */ p10 = 10.; n = exponent; if (n < 0) n = -n; while (n) { if (n & 1) { if (exponent < 0) { number /= p10; } else { number *= p10; } } n >>= 1; p10 *= p10; } if (!is_real(number)) { set_errno(ERANGE); } if (endptr) { *endptr = p; } return number; }
void corr_matrix(Data_Obj *dpto,Data_Obj *dpfr) { int had_err=0; float *op1, *op2; float *dest, *dest2; dimension_t i,j; Vec_Args args; if( ! is_real(dpto,"corr_matrix") ) return; if( ! is_real(dpfr,"corr_matrix") ) return; if( OBJ_COLS(dpto) != OBJ_ROWS(dpto) ){ sprintf(ERROR_STRING,"target matrix %s (%dx%d) must be square",OBJ_NAME(dpto), OBJ_ROWS(dpto),OBJ_COLS(dpto)); WARN(ERROR_STRING); had_err++; } if( OBJ_COLS(dpto) != OBJ_ROWS(dpfr) ){ sprintf(ERROR_STRING, "target matrix %s size %d not equal to source matrix %s rows (%d)", OBJ_NAME(dpto),OBJ_COLS(dpto),OBJ_NAME(dpfr),OBJ_ROWS(dpfr)); WARN(ERROR_STRING); had_err++; } if( had_err ) return; if( IS_COMPLEX(dpto) ) args.arg_argstype = COMPLEX_ARGS; else args.arg_argstype = REAL_ARGS; args.arg_inc1 = OBJ_PXL_INC(dpfr); args.arg_inc2 = OBJ_PXL_INC(dpfr); args.arg_n1 = OBJ_COLS(dpfr); args.arg_n2 = OBJ_COLS(dpfr); args.arg_prec1 = OBJ_PREC(dpfr); args.arg_prec2 = OBJ_PREC(dpfr); op1 = OBJ_DATA_PTR(dpfr); for(i=0;i<OBJ_ROWS(dpfr);i++){ dest = dest2 = OBJ_DATA_PTR(dpto); dest += i*OBJ_ROW_INC(dpto); dest += i*OBJ_PXL_INC(dpto); dest2 += i*OBJ_PXL_INC(dpto); dest2 += i*OBJ_ROW_INC(dpto); op2 = OBJ_DATA_PTR(dpfr); op2 += i*OBJ_ROW_INC(dpfr); for(j=i;j<OBJ_ROWS(dpfr);j++){ args.arg_v1 = op1; args.arg_v2 = op2; vdot(&args); *dest2 = *dest; /* symmetric matrix */ op2 += OBJ_ROW_INC(dpfr); dest += OBJ_PXL_INC(dpto); dest2 += OBJ_ROW_INC(dpto); } op1 += OBJ_ROW_INC(dpfr); } } /* end corr_matrix() */
const char& trans(const t & a = 1)const{ return *details::lapack_option(transa_ ? (!is_real(a)? 'c':'t') :'n'); }
bool pgsVariable::is_number() const { return is_integer() || is_real(); }
void ChannelInternalState::Halt() { if (is_real()) { RealChannelHalt(); } channel_state_ = kChannelStateStopped; }
bool pgsNumber::is_valid() const { pgsTypes type = num_type(m_data); return (type == pgsTInt) || (type == pgsTReal && is_real()); }
bool Cell::isReal() const { return m_value && is_real(m_value); }
void ChannelInternalState::Pause() { if (is_real()) { RealChannelPause(); } channel_state_ = kChannelStatePaused; }
void ChannelInternalState::Resume() { if (is_real()) { RealChannelResume(); } channel_state_ = kChannelStatePlaying; }
bool ChannelInternalState::Play(SoundHandle handle) { handle_ = handle; sound_source_ = handle->Select(); channel_state_ = kChannelStatePlaying; return is_real() ? RealChannelPlay() : true; }